Disable pkg-config search on Android via CMAKE_DISABLE_FIND_PACKAGE_PkgConfig (#20179)

This commit is contained in:
Ilya Lavrenov 2023-10-03 09:16:56 +04:00 committed by Alexander Nesterov
parent 159518f325
commit c06e359536
9 changed files with 34 additions and 39 deletions

View File

@ -8,6 +8,14 @@ if(NOT DEFINED IEDevScripts_DIR)
message(FATAL_ERROR "IEDevScripts_DIR is not defined")
endif()
# disable FindPkgConfig.cmake for Android
if(ANDROID)
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
# build system pkg-config executable, which finds packages on build system. Such
# libraries cannot be linked into Android binaries.
set(CMAKE_DISABLE_FIND_PACKAGE_PkgConfig ON)
endif()
macro(ov_set_if_not_defined var value)
if(NOT DEFINED ${var})
set(${var} ${value})

View File

@ -60,11 +60,7 @@ Usage: -DSELECTIVE_BUILD=ON -DSELECTIVE_BUILD_STAT=/path/*.csv" OFF
ie_option (ENABLE_DOCS "Build docs using Doxygen" OFF)
if(NOT ANDROID)
# on Android build FindPkgConfig.cmake finds host system pkg-config, which is not appropriate
find_package(PkgConfig QUIET)
endif()
find_package(PkgConfig QUIET)
ie_dependent_option (ENABLE_PKGCONFIG_GEN "Enable openvino.pc pkg-config file generation" ON "LINUX OR APPLE;PkgConfig_FOUND;BUILD_SHARED_LIBS" OFF)
#

View File

@ -26,13 +26,11 @@ if(TARGET OpenCL::OpenCL)
endif()
# try to find VA libraries
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()
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()

View File

@ -21,6 +21,14 @@ elseif(NOT OV_GENERATOR_MULTI_CONFIG)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release;Debug;RelWithDebInfo;MinSizeRel")
endif()
# disable FindPkgConfig.cmake for Android
if(ANDROID)
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
# build system pkg-config executable, which finds packages on build system. Such
# libraries cannot be linked into Android binaries.
set(CMAKE_DISABLE_FIND_PACKAGE_PkgConfig ON)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (NOT BIN_FOLDER)

View File

@ -14,11 +14,8 @@ ie_add_sample(NAME ${TARGET_NAME}
# Required nlohmann_json dependency
if(NOT ANDROID)
find_package(PkgConfig QUIET)
endif()
if(NOT TARGET nlohmann_json::nlohmann_json)
find_package(PkgConfig QUIET)
find_package(nlohmann_json QUIET
# exception for Ubuntu 18.04, where cmake files for nlohmann_json
# are located in a wrong directory

View File

@ -8,13 +8,10 @@ file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
# Required zlib and cnpy dependencies
if(NOT ANDROID)
find_package(PkgConfig QUIET)
endif()
find_package(ZLIB QUIET)
if(NOT TARGET ZLIB::ZLIB)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(zlib QUIET
IMPORTED_TARGET GLOBAL

View File

@ -2,9 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#
if(NOT ANDROID)
find_package(PkgConfig QUIET)
endif()
find_package(PkgConfig QUIET)
function(_ov_get_tbb_location tbb_target _tbb_lib_location_var)
if(NOT TBB_FOUND)

View File

@ -39,11 +39,9 @@ if(ENABLE_PROXY)
endif()
# try to find VA libraries
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(libva QUIET IMPORTED_TARGET libva)
endif()
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(libva QUIET IMPORTED_TARGET libva)
endif()
if(libva_FOUND)

View File

@ -11,17 +11,12 @@ endif()
set(_old_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(_old_CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE})
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
# build system pkg-config executable, which finds packages on build system. Such
# libraries cannot be linked into Android binaries.
if(NOT ANDROID)
find_package(PkgConfig QUIET)
# see https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
# cmake older than 3.18 cannot create an alias for imported non-GLOBAL targets
# so, we have to use 'IMPORTED_GLOBAL' property
if(CMAKE_VERSION VERSION_LESS 3.18)
set(OV_PkgConfig_VISILITY GLOBAL)
endif()
find_package(PkgConfig QUIET)
# see https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
# cmake older than 3.18 cannot create an alias for imported non-GLOBAL targets
# so, we have to use 'IMPORTED_GLOBAL' property
if(CMAKE_VERSION VERSION_LESS 3.18)
set(OV_PkgConfig_VISILITY GLOBAL)
endif()
if(SUGGEST_OVERRIDE_SUPPORTED)