Skip to content

Commit fb1faf8

Browse files
Generate openvino.pc pkg-config file (openvinotoolkit#12779)
* Generate openvino.pc pkg-config file * Added libva-dev as a dependency * Fixed typo in install_build_dependencies.sh * samples on CI * Revert changes in samples; use pkg-config in tests * Debug print * Revert changes in fuzz tests * Fixed TBB usage * Fixed pkg-config usage for cross-compilation * Fixed pkg_config_tbb_lib_dir * Don't use PKG_CONFIG_EXECUTABLE unconditionally * Fixed copy-patse * Fixe * Generate pkg-config file for Apple as well * Fixes for ubuntu 22.04 * Disable apple
1 parent 89fa308 commit fb1faf8

File tree

17 files changed

+176
-39
lines changed

17 files changed

+176
-39
lines changed

.ci/azure/linux.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,27 @@ jobs:
305305
condition: ne(variables['CMAKE_CPACK_GENERATOR'], 'DEB')
306306
displayName: 'List install files'
307307

308-
- script: rm -fr $(BUILD_DIR)
309-
displayName: 'Clean build dir'
310-
continueOnError: false
311-
312-
- script: $(SAMPLES_INSTALL_DIR)/cpp/build_samples.sh -i $(INSTALL_DIR)
308+
- script: $(SAMPLES_INSTALL_DIR)/cpp/build_samples.sh -i $(INSTALL_DIR) -b $(BUILD_DIR)/cpp_samples
313309
displayName: 'Build cpp samples'
314310
continueOnError: false
315311

316312
- script: |
317313
export CC=clang
318314
export CXX=clang++
319-
$(SAMPLES_INSTALL_DIR)/cpp/build_samples.sh -i $(INSTALL_DIR)
315+
$(SAMPLES_INSTALL_DIR)/cpp/build_samples.sh -b $(BUILD_DIR)/cpp_samples_clang
320316
displayName: 'Build cpp samples - clang'
321317
continueOnError: false
322318
323-
- script: $(SAMPLES_INSTALL_DIR)/c/build_samples.sh -i $(INSTALL_DIR)
319+
- script: |
320+
export VERBOSE=1
321+
$(SAMPLES_INSTALL_DIR)/c/build_samples.sh -i $(INSTALL_DIR) -b $(BUILD_DIR)/c_samples
324322
displayName: 'Build c samples'
325323
continueOnError: false
326324
325+
- script: rm -fr $(BUILD_DIR)
326+
displayName: 'Clean build dir'
327+
continueOnError: false
328+
327329
- script: $(RUN_PREFIX) $(INSTALL_TEST_DIR)/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:$(INSTALL_TEST_DIR)/TEST-NGraphUT.xml
328330
displayName: 'OV Core UT'
329331
continueOnError: false

cmake/templates/openvino.pc.in

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2018-2022 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
5+
pc_path=${pcfiledir}
6+
prefix=${pc_path}/@PKGCONFIG_OpenVINO_PREFIX@
7+
8+
exec_prefix=${prefix}/@OV_CPACK_RUNTIMEDIR@
9+
libdir=${exec_prefix}/@PKGCONFIG_OpenVINO_TRIPLET@
10+
11+
include_prefix=${prefix}/@OV_CPACK_INCLUDEDIR@
12+
includedir_old=${include_prefix}/ie
13+
includedir_new=${include_prefix}
14+
15+
Name: OpenVINO
16+
Description: OpenVINO™ Toolkit
17+
URL: https://docs.openvino.ai/latest/index.html
18+
Version: @OpenVINO_VERSION@
19+
Requires.private: @PKGCONFIG_OpenVINO_REQUIRES_PRIVATE@
20+
Conflicts: openvino < @OpenVINO_VERSION@
21+
Cflags: -I${includedir_old} -I${includedir_new}
22+
Libs: -L${libdir} @PKGCONFIG_OpenVINO_FRONTENDS@ -lopenvino_c -lopenvino @PKGCONFIG_OpenVINO_PRIVATE_DEPS@
23+
Libs.private: -ldl -lm -lpthread -lrt

install_build_dependencies.sh

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ if [ -f /etc/lsb-release ]; then
5454
`# openvino` \
5555
libtbb-dev \
5656
libpugixml-dev \
57+
`# gpu plugin extensions` \
58+
libva-dev \
5759
`# python` \
5860
python3-pip \
5961
python3-venv \

scripts/setupvars/setupvars.sh

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ if [ -e "$INSTALLDIR/runtime" ]; then
3232
system_type=$(ls "$INSTALLDIR/runtime/lib/")
3333
IE_PLUGINS_PATH=$INSTALLDIR/runtime/lib/$system_type
3434

35+
export PKG_CONFIG_PATH=$IE_PLUGINS_PATH/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
36+
3537
export HDDL_INSTALL_DIR=$INSTALLDIR/runtime/3rdparty/hddl
3638
if [[ "$OSTYPE" == "darwin"* ]]; then
3739
export DYLD_LIBRARY_PATH=${IE_PLUGINS_PATH}/Release:${IE_PLUGINS_PATH}/Debug${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}

src/cmake/install_tbb.cmake

+16-13
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ function(_ov_get_tbb_location tbb_target _tbb_lib_location_var)
1212
return()
1313
endif()
1414

15-
# i.e. yocto case
16-
get_target_property(_tbb_lib_location ${tbb_target} INTERFACE_LINK_LIBRARIES)
17-
if(_tbb_lib_location)
18-
set(${_tbb_lib_location_var} "${_tbb_lib_location}" PARENT_SCOPE)
19-
return()
20-
endif()
21-
22-
# usual imported library
23-
get_target_property(_tbb_lib_location ${tbb_target} IMPORTED_LOCATION_RELEASE)
24-
if(_tbb_lib_location)
25-
set(${_tbb_lib_location_var} "${_tbb_lib_location}" PARENT_SCOPE)
26-
return()
27-
endif()
15+
foreach(properties INTERFACE_LINK_LIBRARIES
16+
IMPORTED_LOCATION_RELEASE
17+
IMPORTED_LOCATION_NONE
18+
IMPORTED_LOCATION)
19+
get_target_property(_tbb_lib_location ${tbb_target} ${properties})
20+
if(_tbb_lib_location)
21+
set(${_tbb_lib_location_var} "${_tbb_lib_location}" PARENT_SCOPE)
22+
return()
23+
endif()
24+
endforeach()
2825

2926
message(FATAL_ERROR "Failed to detect TBB library location")
3027
endfunction()
@@ -146,6 +143,8 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
146143
endif()
147144
endforeach()
148145
endforeach()
146+
147+
set(pkg_config_tbb_lib_dir "runtime/3rdparty/tbb/lib")
149148
elseif(tbb_custom)
150149
# for custom TBB we need to install it to our package
151150
# to simplify life for our customers
@@ -190,6 +189,8 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
190189
COMPONENT tbb)
191190
endif()
192191
endforeach()
192+
193+
set(pkg_config_tbb_lib_dir "${IE_TBBROOT_INSTALL}/${tbb_libs_dir}")
193194
elseif(tbb_downloaded)
194195
set(IE_TBB_DIR_INSTALL "runtime/3rdparty/tbb/")
195196

@@ -228,6 +229,8 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
228229
DESTINATION "${IE_TBB_DIR_INSTALL}"
229230
COMPONENT tbb_dev)
230231
endif()
232+
233+
set(pkg_config_tbb_lib_dir "${IE_TBB_DIR_INSTALL}/lib")
231234
else()
232235
message(WARNING "TBB of unknown origin. TBB files are not installed")
233236
endif()

src/cmake/openvino.cmake

+97
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,100 @@ install(FILES "${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake"
180180
"${CMAKE_BINARY_DIR}/OpenVINOConfig-version.cmake"
181181
DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR}
182182
COMPONENT ${OV_CPACK_COMP_CORE_DEV})
183+
184+
# Generate and install openvino.pc pkg-config file
185+
186+
# TODO: fix apple later
187+
if(LINUX)
188+
find_package(PkgConfig QUIET)
189+
if(PkgConfig_FOUND)
190+
set(generate_pkgconfig ON)
191+
endif()
192+
193+
# temporary skip generator of pkg-config file for static libraries
194+
if(NOT BUILD_SHARED_LIBS)
195+
set(generate_pkgconfig OFF)
196+
endif()
197+
198+
# fill in PKGCONFIG_OpenVINO_FRONTENDS
199+
get_target_property(PKGCONFIG_OpenVINO_FRONTENDS_LIST ov_frontends MANUALLY_ADDED_DEPENDENCIES)
200+
if(ENABLE_OV_IR_FRONTEND)
201+
list(REMOVE_ITEM PKGCONFIG_OpenVINO_FRONTENDS_LIST openvino_ir_frontend)
202+
endif()
203+
if(ENABLE_OV_TF_FRONTEND)
204+
list(REMOVE_ITEM PKGCONFIG_OpenVINO_FRONTENDS_LIST openvino_tensorflow_frontend)
205+
endif()
206+
207+
foreach(frontend IN LISTS PKGCONFIG_OpenVINO_FRONTENDS_LIST)
208+
if(PKGCONFIG_OpenVINO_FRONTENDS)
209+
set(PKGCONFIG_OpenVINO_FRONTENDS "${PKGCONFIG_OpenVINO_FRONTENDS} -l${frontend}")
210+
else()
211+
set(PKGCONFIG_OpenVINO_FRONTENDS "-l${frontend}")
212+
endif()
213+
endforeach()
214+
215+
# fill in PKGCONFIG_OpenVINO_REQUIRES_PRIVATE and PKGCONFIG_OpenVINO_PRIVATE_DEPS
216+
217+
if(ENABLE_SYSTEM_TBB)
218+
set(PKGCONFIG_OpenVINO_REQUIRES_PRIVATE "tbb")
219+
elseif(TBB_FOUND)
220+
if(NOT pkg_config_tbb_lib_dir)
221+
message(FATAL_ERROR "Internal error: variable 'pkg_config_tbb_lib_dir' is not defined")
222+
endif()
223+
224+
set(PKGCONFIG_OpenVINO_PRIVATE_DEPS "-L\${prefix}/${pkg_config_tbb_lib_dir} -ltbb")
225+
endif()
226+
227+
if(ENABLE_SYSTEM_PUGIXML AND PkgConfig_FOUND)
228+
pkg_check_modules(PKGCONFIG_pugixml QUIET
229+
NO_CMAKE_PATH
230+
NO_CMAKE_ENVIRONMENT_PATH
231+
pugixml)
232+
set(pugixml_dep "pugixml = ${PKGCONFIG_pugixml_VERSION}")
233+
234+
if(PKGCONFIG_OpenVINO_REQUIRES_PRIVATE)
235+
set(PKGCONFIG_OpenVINO_REQUIRES_PRIVATE "${PKGCONFIG_OpenVINO_REQUIRES_PRIVATE}, ${pugixml_dep}")
236+
else()
237+
set(PKGCONFIG_OpenVINO_REQUIRES_PRIVATE "${pugixml_dep}")
238+
endif()
239+
endif()
240+
241+
# detect <multiarch-triplet>
242+
if(CPACK_GENERATOR STREQUAL "DEB" AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
243+
# TODO: find a better way to detect <multiarch-triplet>
244+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
245+
# note: clang provides different output like 'x86_64-pc-linux-gnu', so it's not used
246+
execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
247+
OUTPUT_VARIABLE PKGCONFIG_OpenVINO_TRIPLET
248+
ERROR_VARIABLE error_message
249+
RESULT_VARIABLE exit_code
250+
OUTPUT_STRIP_TRAILING_WHITESPACE)
251+
if(NOT exit_code EQUAL 0)
252+
message(WARNING "Internal error: failed to detect library <multiarch-triplet> ${error_message}")
253+
set(generate_pkgconfig OFF)
254+
endif()
255+
else()
256+
# cannot detect <multiarch-triplet>
257+
set(generate_pkgconfig OFF)
258+
endif()
259+
endif()
260+
261+
# define relative paths
262+
file(RELATIVE_PATH PKGCONFIG_OpenVINO_PREFIX "/${OV_CPACK_RUNTIMEDIR}/pkgconfig" "/")
263+
264+
if(generate_pkgconfig)
265+
set(pkgconfig_in "${OpenVINO_SOURCE_DIR}/cmake/templates/openvino.pc.in")
266+
set(pkgconfig_out "${OpenVINO_BINARY_DIR}/share/openvino.pc")
267+
configure_file("${pkgconfig_in}" "${pkgconfig_out}" @ONLY)
268+
269+
install(FILES "${pkgconfig_out}"
270+
DESTINATION "${OV_CPACK_RUNTIMEDIR}/pkgconfig"
271+
COMPONENT ${OV_CPACK_COMP_CORE_DEV})
272+
273+
add_custom_command(TARGET openvino PRE_BUILD
274+
COMMAND "${PKG_CONFIG_EXECUTABLE}" --validate "${pkgconfig_out}"
275+
COMMAND cat "${pkgconfig_out}"
276+
COMMENT "[pkg-config] validating openvino.pc"
277+
VERBATIM)
278+
endif()
279+
endif()

src/core/include/openvino/core/type.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ struct OPENVINO_API DiscreteTypeInfo {
3737
// exact type identification
3838
const DiscreteTypeInfo* parent;
3939

40-
DiscreteTypeInfo() = default;
4140
OPENVINO_SUPPRESS_DEPRECATED_START
41+
DiscreteTypeInfo() = default;
4242
DiscreteTypeInfo(const DiscreteTypeInfo&) = default;
4343
DiscreteTypeInfo(DiscreteTypeInfo&&) = default;
4444
DiscreteTypeInfo& operator=(const DiscreteTypeInfo&) = default;

src/tests/functional/inference_engine/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,14 @@ function(ie_headers_compilation_with_custom_flags)
159159
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_dx.hpp"
160160
"openvino/runtime/intel_gpu/ocl/dx.hpp")
161161
endif()
162-
if(NOT LIBVA_FOUND)
162+
# try to find VA libraries
163+
if(NOT CMAKE_CROSSCOMPILING)
164+
find_host_package(PkgConfig QUIET)
165+
if(PkgConfig_FOUND)
166+
pkg_search_module(libva QUIET IMPORTED_TARGET libva)
167+
endif()
168+
endif()
169+
if(NOT libva_FOUND)
163170
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_va.hpp"
164171
"openvino/runtime/intel_gpu/ocl/va.hpp")
165172
endif()

tests/lib/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,17 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5+
# Search OpenVINO Runtime installed
6+
find_package(PkgConfig QUIET)
7+
# TODO: fix apple and cross-compilation later
8+
if(PkgConfig_FOUND AND NOT CMAKE_CROSSCOMPILING AND NOT APPLE)
9+
pkg_search_module(openvino REQUIRED
10+
IMPORTED_TARGET
11+
openvino)
12+
set(ov_link_libraries PkgConfig::openvino)
13+
else()
14+
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
15+
set(ov_link_libraries openvino::runtime)
16+
endif()
17+
518
add_subdirectory(src)

tests/lib/src/CMakeLists.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ add_library(${TARGET_NAME} STATIC ${SRC})
99

1010
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1111

12-
# Search OpenVINO Runtime installed
13-
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
14-
15-
target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime)
12+
target_link_libraries(${TARGET_NAME} PUBLIC ${ov_link_libraries})

tests/memory_tests/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ set(OUTPUT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
2121

2222
set(OpenVINO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../")
2323

24-
# Search OpenVINO Inference Engine installed
25-
find_package(OpenVINO REQUIRED)
26-
2724
add_subdirectory(src)
2825

2926
install(DIRECTORY test_runner/ DESTINATION tests/memory_tests/test_runner COMPONENT tests EXCLUDE_FROM_ALL)

tests/memory_tests/src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5+
add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)
6+
57
add_subdirectory(memory_tests)
68
add_subdirectory(memory_tests_helper)

tests/memory_tests/src/memory_tests/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ add_custom_target(memory_tests)
99
# Test target name is source file name without extension.
1010
FILE(GLOB tests "*.cpp")
1111

12-
add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)
13-
1412
foreach(test_source ${tests})
1513
get_filename_component(test_name ${test_source} NAME_WE)
1614
add_executable(${test_name} ${test_source})

tests/stress_tests/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithD
1717
# Define directory where artifacts will be placed
1818
set(OUTPUT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
1919

20-
# Search OpenVINO Inference Engine installed
21-
find_package(OpenVINO REQUIRED)
22-
2320
set(OpenVINO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../")
2421

2522
add_subdirectory(common)

tests/time_tests/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ project(time_tests)
1717

1818
set(OpenVINO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../")
1919

20-
# Search OpenVINO Inference Engine installed
21-
find_package(OpenVINO REQUIRED)
22-
2320
add_subdirectory(src)
2421

2522
install(DIRECTORY test_runner/ DESTINATION tests/time_tests/test_runner COMPONENT tests EXCLUDE_FROM_ALL)

tests/time_tests/src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5+
add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)
6+
57
add_subdirectory(timetests)
68
add_subdirectory(timetests_helper)

tests/time_tests/src/timetests/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ add_custom_target(time_tests)
99
# Test target name is source file name without extension.
1010
FILE(GLOB tests "*.cpp")
1111

12-
add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)
13-
1412
foreach(test_source ${tests})
1513
get_filename_component(test_name ${test_source} NAME_WE)
1614
add_executable(${test_name} ${test_source})

0 commit comments

Comments
 (0)