diff --git a/CMakeLists.txt b/CMakeLists.txt index 0262cd3a9711925216e979cece09c4b1e6180dd5..77378a1b295ae6f3a407b9772ad54c80d233f534 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -552,8 +552,22 @@ endif(WIN32 AND NOT MINGW) # CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC.. # ---------------------------------------------------------------------------- if(UNIX) - if(NOT APPLE_FRAMEWORK) - find_package(PkgConfig QUIET) + if(NOT APPLE_FRAMEWORK OR OPENCV_ENABLE_PKG_CONFIG) + if(CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{PKG_CONFIG_LIBDIR} + AND NOT OPENCV_ENABLE_PKG_CONFIG + ) + if(NOT PkgConfig_FOUND) + message(STATUS "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT") + elseif(OPENCV_SKIP_PKG_CONFIG_WARNING) + message(WARNING "pkg-config is enabled in cross-compilation mode without defining of PKG_CONFIG_LIBDIR environment variable. This may lead to misconfigured host-based dependencies.") + endif() + elseif(OPENCV_DISABLE_PKG_CONFIG) + if(PkgConfig_FOUND) + message(WARNING "OPENCV_DISABLE_PKG_CONFIG flag has no effect") + endif() + else() + find_package(PkgConfig QUIET) + endif() endif() include(CheckFunctionExists) include(CheckIncludeFile)