Updated ia32 toolchain with system / processor (#12784)

* Updated ia32 toolchain with system / processor

* Allow pkg-config during cross-compilation

* added error message

* Search TBB using tbb.pc as well

* WA

* Fix for yocto

* Added print

* Use tbb.pc only when system libs are enabled

* Improved OpenVINOConfig.cmake

* Don't find pkg-config as required
This commit is contained in:
Ilya Lavrenov 2022-09-01 14:33:47 +04:00 committed by GitHub
parent 6c4cc81465
commit e19df6f85f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 176 additions and 67 deletions

View File

@ -25,7 +25,11 @@ fetch_models_and_validation_set()
get_linux_name(LINUX_OS_NAME)
if(CMAKE_CROSSCOMPILING AND CMAKE_HOST_SYSTEM_NAME MATCHES Linux AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
if(CMAKE_CROSSCOMPILING AND CMAKE_HOST_SYSTEM_NAME MATCHES Linux AND
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*" AND
# for x86 we have to install libc6-amd64 to enable binary compiled for x86_64
# to run with proper loader; more safer just to disable system protoc on x86
NOT X86)
set(protoc_version "3.18.2")
RESOLVE_DEPENDENCY(SYSTEM_PROTOC_ROOT

View File

@ -34,7 +34,7 @@ set_ci_build_number()
include(target_flags)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH_FOLDER)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_FOLDER)
if(X86_64)
set(ARCH_FOLDER intel64)
elseif(X86)

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#
set(FRONTEND_INSTALL_INCLUDE "${OV_CPACK_INCLUDEDIR}/")
set(FRONTEND_INSTALL_INCLUDE "${OV_CPACK_INCLUDEDIR}")
set(FRONTEND_NAME_PREFIX "openvino_")
set(FRONTEND_NAME_SUFFIX "_frontend")
@ -261,7 +261,7 @@ macro(ov_add_frontend)
if(OV_FRONTEND_LINKABLE_FRONTEND)
# install library development files
install(DIRECTORY ${${TARGET_NAME}_INCLUDE_DIR}/openvino
DESTINATION ${FRONTEND_INSTALL_INCLUDE}/
DESTINATION ${FRONTEND_INSTALL_INCLUDE}
COMPONENT ${dev_component}
FILES_MATCHING PATTERN "*.hpp")

View File

@ -91,7 +91,6 @@ macro(ov_debian_specific_settings)
# with current WA automatic deps detection via dpkg-shlibdeps for "our libraries"
# is ignored; but dependencies between our components are here because of
# CPACK_COMPONENT_<UCOMP>_DEPENDS variables
# More proper WA is try to enable INSTALL_RPATH
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

View File

@ -147,39 +147,72 @@ set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}")
set(THREADING "@THREADING@")
if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND)
set(enable_system_tbb "@ENABLE_SYSTEM_TBB@")
if(NOT enable_system_tbb)
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
set(enable_pkgconfig_tbb "@tbb_FOUND@")
# see https://stackoverflow.com/questions/28070810/cmake-generate-error-on-windows-as-it-uses-as-escape-seq
if(DEFINED ENV{TBBROOT})
file(TO_CMAKE_PATH $ENV{TBBROOT} ENV_TBBROOT)
endif()
if(DEFINED ENV{TBB_DIR})
file(TO_CMAKE_PATH $ENV{TBB_DIR} ENV_TBB_DIR)
endif()
# try tbb.pc
if(enable_pkgconfig_tbb AND NOT ANDROID)
_ov_find_dependency(PkgConfig)
if(PkgConfig_FOUND)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(pkg_config_quiet_arg QUIET)
endif()
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(pkg_config_required_arg REQUIRED)
endif()
set(find_package_tbb_extra_args
CONFIG
PATHS
# oneTBB case exposed via export TBBROOT=<custom TBB root>
"${ENV_TBBROOT}/lib64/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/tbb"
"${ENV_TBB_DIR}"
# for custom TBB exposed via cmake -DTBBROOT=<custom TBB root>
"${TBBROOT}/cmake"
# _tbb_dir points to TBB_DIR (custom | temp | system) used to build OpenVINO
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
unset(_tbb_dir)
pkg_search_module(tbb
${pkg_config_quiet_arg}
${pkg_config_required_arg}
IMPORTED_TARGET GLOBAL
tbb)
unset(pkg_config_quiet_arg)
unset(pkg_config_required_arg)
if(tbb_FOUND)
add_library(TBB::tbb ALIAS PkgConfig::tbb)
set(TBB_VERSION ${tbb_VERSION})
set(TBB_FOUND ${tbb_FOUND})
set(TBB_IMPORTED_TARGETS TBB::tbb)
message(STATUS "tbb (${tbb_VERSION}) is found at ${tbb_PREFIX}")
endif()
endif()
else()
# try cmake TBB interface
set(enable_system_tbb "@ENABLE_SYSTEM_TBB@")
if(NOT enable_system_tbb)
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
# see https://stackoverflow.com/questions/28070810/cmake-generate-error-on-windows-as-it-uses-as-escape-seq
if(DEFINED ENV{TBBROOT})
file(TO_CMAKE_PATH $ENV{TBBROOT} ENV_TBBROOT)
endif()
if(DEFINED ENV{TBB_DIR})
file(TO_CMAKE_PATH $ENV{TBB_DIR} ENV_TBB_DIR)
endif()
set(find_package_tbb_extra_args
CONFIG
PATHS
# oneTBB case exposed via export TBBROOT=<custom TBB root>
"${ENV_TBBROOT}/lib64/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/tbb"
"${ENV_TBB_DIR}"
# for custom TBB exposed via cmake -DTBBROOT=<custom TBB root>
"${TBBROOT}/cmake"
# _tbb_dir points to TBB_DIR (custom | temp | system) used to build OpenVINO
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
unset(_tbb_dir)
endif()
unset(enable_system_tbb)
_ov_find_dependency(TBB
COMPONENTS tbb tbbmalloc
${find_package_tbb_extra_args})
endif()
unset(enable_system_tbb)
_ov_find_dependency(TBB
COMPONENTS tbb tbbmalloc
${find_package_tbb_extra_args})
set(install_tbbbind "@install_tbbbind@")
if(install_tbbbind)
@ -213,10 +246,23 @@ set(_OV_ENABLE_INTEL_MYRIAD "@ENABLE_INTEL_MYRIAD@")
if(_OV_ENABLE_INTEL_MYRIAD AND NOT _OV_ENABLE_OPENVINO_BUILD_SHARED)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND AND NOT ANDROID)
pkg_search_module(libusb REQUIRED
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(pkg_config_quiet_arg QUIET)
endif()
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(pkg_config_required_arg REQUIRED)
endif()
pkg_search_module(libusb
${pkg_config_quiet_arg}
${pkg_config_required_arg}
IMPORTED_TARGET GLOBAL
libusb-1.0)
message(STATUS "libusb-1.0 (${libusb_VERSION}) is found at ${libusb_PREFIX}")
unset(pkg_config_quiet_arg)
unset(pkg_config_required_arg)
if(libusb_FOUND)
message(STATUS "libusb-1.0 (${libusb_VERSION}) is found at ${libusb_PREFIX}")
endif()
endif()
endif()
unset(_OV_ENABLE_INTEL_MYRIAD)
@ -229,8 +275,12 @@ if(NOT TARGET openvino)
# WA for cmake version < 3.16 which does not export
# IMPORTED_LINK_DEPENDENT_LIBRARIES_** properties if no PUBLIC dependencies for the library
if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND TBB_FOUND)
foreach (type RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
set_property(TARGET openvino::runtime APPEND PROPERTY IMPORTED_LINK_DEPENDENT_LIBRARIES_${type} "TBB::tbb;TBB::tbbmalloc")
foreach(type RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
foreach(tbb_target TBB::tbb TBB::tbbmalloc)
if(TARGET ${tbb_target})
set_property(TARGET openvino::runtime APPEND PROPERTY IMPORTED_LINK_DEPENDENT_LIBRARIES_${type} "${tbb_target}")
endif()
endforeach()
endforeach()
endif()
endif()

View File

@ -2,6 +2,11 @@
# SPDX-License-Identifier: Apache-2.0
#
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(PKG_CONFIG_EXECUTABLE i686-linux-gnu-pkg-config CACHE PATH "Path to 32-bits pkg-config")
set(CMAKE_CXX_FLAGS_INIT "-m32")
set(CMAKE_C_FLAGS_INIT "-m32")

View File

@ -53,10 +53,13 @@ if (NOT (OpenCL_FOUND AND OpenCL_HEADERS))
endif()
# try to find VA libraries
if(NOT CMAKE_CROSSCOMPILING)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(libva QUIET IMPORTED_TARGET libva)
if(libva_FOUND)
message(STATUS "${PKG_CONFIG_EXECUTABLE}: libva (${libva_VERSION}) is found at ${libva_PREFIX}")
endif()
endif()
endif()

View File

@ -121,7 +121,7 @@ if(NOT TARGET gflags)
endif()
if(NOT TARGET zlib::zlib)
if(NOT CMAKE_CROSSCOMPILING)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(zlib QUIET
@ -135,7 +135,7 @@ if(NOT TARGET zlib::zlib)
endif()
if(zlib_FOUND)
message(STATUS "zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib")
add_subdirectory(thirdparty/zlib EXCLUDE_FROM_ALL)
endif()

View File

@ -8,7 +8,7 @@ include(cmake/install_tbb.cmake)
# CC library should be registered before other cc targets
add_subdirectory(common)
# TODO: Fix Wall for core, frontends, tests and c binding
# TODO: Fix Wall for core, frontends and tests
add_subdirectory(core)
add_subdirectory(frontends)
# TODO: remove ngraph/ngraph.hpp usage

View File

@ -14,28 +14,46 @@ macro(ov_find_package_tbb)
${_find_package_no_args})
if(NOT TBB_FOUND)
# system TBB failed to be found
set(ENABLE_SYSTEM_TBB OFF)
# remove invalid TBB_DIR=TBB_DIR-NOTFOUND from cache
unset(TBB_DIR CACHE)
unset(TBB_DIR)
# TBB on system is not found, download prebuilt one
# if TBBROOT env variable is not defined
ov_download_tbb()
# fallback variant for TBB 2018 and older where TBB have not had cmake interface
if(DEFINED TBBROOT OR DEFINED ENV{TBBROOT})
set(_tbb_paths PATHS ${IEDevScripts_DIR})
# try tbb.pc from system
if(NOT ANDROID AND ENABLE_SYSTEM_TBB)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(tbb QUIET
IMPORTED_TARGET GLOBAL
tbb)
if(tbb_FOUND)
add_library(TBB::tbb ALIAS PkgConfig::tbb)
set(TBB_VERSION ${tbb_VERSION})
set(TBB_FOUND ${tbb_FOUND})
message(STATUS "${PKG_CONFIG_EXECUTABLE}: tbb (${tbb_VERSION}) is found at ${tbb_PREFIX}")
endif()
endif()
endif()
# try to find one more time
find_package(TBB QUIET COMPONENTS tbb tbbmalloc
# can be provided by ov_download_tbb
HINTS ${TBB_DIR}
${_tbb_paths}
${_find_package_no_args})
if(NOT TBB_FOUND)
# system TBB failed to be found
set(ENABLE_SYSTEM_TBB OFF)
# TBB on system is not found, download prebuilt one
# if TBBROOT env variable is not defined
ov_download_tbb()
# fallback variant for TBB 2018 and older where TBB have not had cmake interface
if(DEFINED TBBROOT OR DEFINED ENV{TBBROOT})
set(_tbb_paths PATHS ${IEDevScripts_DIR})
endif()
# try to find one more time
find_package(TBB QUIET COMPONENTS tbb tbbmalloc
# can be provided by ov_download_tbb
HINTS ${TBB_DIR}
${_tbb_paths}
${_find_package_no_args})
endif()
endif()
# WA for oneTBB: it does not define TBB_IMPORTED_TARGETS

View File

@ -7,6 +7,30 @@ include(cmake/ie_parallel.cmake)
# pre-find TBB: need to provide TBB_IMPORTED_TARGETS used for installation
ov_find_package_tbb()
function(_ov_get_tbb_library_path tbb_lib tbb_libs_dir)
if(NOT TBB_FOUND)
return()
endif()
# i.e. yocto case
get_target_property(_tbb_lib_location ${tbb_lib} INTERFACE_LINK_LIBRARIES)
if(_tbb_lib_location)
get_filename_component(_tbb_libs_dir "${_tbb_lib_location}" DIRECTORY)
set(${tbb_libs_dir} "${_tbb_libs_dir}" PARENT_SCOPE)
return()
endif()
# usual imported library
get_target_property(_tbb_lib_location ${tbb_lib} IMPORTED_LOCATION_RELEASE)
if(_tbb_lib_location)
get_filename_component(_tbb_libs_dir "${_tbb_lib_location}" DIRECTORY)
set(${tbb_libs_dir} "${_tbb_libs_dir}" PARENT_SCOPE)
return()
endif()
message(FATAL_ERROR "Failed to detect TBB library location")
endfunction()
# check whether TBB has TBBBind 2.5 with hwloc 2.5 or higher which is required
# to detect hybrid cores
function(_ov_detect_dynamic_tbbbind_2_5 var)
@ -15,8 +39,7 @@ function(_ov_detect_dynamic_tbbbind_2_5 var)
endif()
# try to select proper library directory
get_target_property(_tbb_lib_location TBB::tbb IMPORTED_LOCATION_RELEASE)
get_filename_component(_tbb_libs_dir "${_tbb_lib_location}" DIRECTORY)
_ov_get_tbb_library_path(TBB::tbb _tbb_libs_dir)
# unset for cases if user specified different TBB_DIR / TBBROOT
unset(_ov_tbbbind_2_5 CACHE)
@ -103,7 +126,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
# for system libraries we still need to install TBB libraries
# so, need to take locations of actual libraries and install them
foreach(tbb_lib IN LISTS TBB_IMPORTED_TARGETS)
get_target_property(tbb_loc ${tbb_lib} IMPORTED_LOCATION_RELEASE)
_ov_get_tbb_library_path(${tbb_lib} tbb_loc)
# depending on the TBB, tbb_loc can be in form:
# - libtbb.so.x.y
# - libtbb.so.x

View File

@ -61,8 +61,8 @@ function(ie_add_onednn)
# WA for old TBBConfig.cmake like tbb2019_20180718oss
# they don't check that imported target is already created
if(TBB_FOUND AND TBB_VERSION VERSION_GREATER_EQUAL 2018 AND TBB_VERSION VERSION_LESS_EQUAL 2019.4)
set(Threading_cmake_included ON)
if(TBB_FOUND)
set(TBB_cmake_included ON)
set(DNNL_CPU_THREADING_RUNTIME "${THREADING}")
function(find_package_tbb)
# dummy

View File

@ -22,7 +22,7 @@ addIeTargetTest(
)
# try to find VA libraries
if(NOT CMAKE_CROSSCOMPILING)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(libva QUIET IMPORTED_TARGET libva)

View File

@ -33,7 +33,7 @@ if(NOT ANDROID)
zlib)
if(zlib_FOUND)
add_library(zlib::zlib ALIAS PkgConfig::zlib)
message(STATUS "zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
endif()
endif()
endif()

View File

@ -33,15 +33,22 @@ if(NOT DEFINED protobuf_MSVC_STATIC_RUNTIME)
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link protobuf to static runtime libraries" FORCE)
endif()
if(CMAKE_CROSSCOMPILING)
# WA: see CVS-90227 about X86
if(CMAKE_CROSSCOMPILING AND NOT X86)
find_host_program(SYSTEM_PROTOC protoc PATHS ENV PATH)
if(SYSTEM_PROTOC)
execute_process(
COMMAND ${SYSTEM_PROTOC} --version
OUTPUT_VARIABLE PROTOC_VERSION
ERROR_VARIABLE error_message
RESULT_VARIABLE exit_code
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT exit_code EQUAL 0)
message(FATAL_ERROR "Internal error: failed to get ${SYSTEM_PROTOC} version ${error_message}")
endif()
string(REPLACE " " ";" PROTOC_VERSION ${PROTOC_VERSION})
list(GET PROTOC_VERSION -1 PROTOC_VERSION)