diff --git a/CMakeLists.txt b/CMakeLists.txt index 759de6ece6..4048378626 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -719,7 +719,7 @@ ocv_cmake_hook(POST_COMPILER_OPTIONS) # ---------------------------------------------------------------------------- if(UNIX) if(NOT APPLE_FRAMEWORK OR OPENCV_ENABLE_PKG_CONFIG) - if(CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{PKG_CONFIG_LIBDIR} + if(CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{PKG_CONFIG_LIBDIR} AND NOT DEFINED ENV{PKG_CONFIG_SYSROOT_DIR} AND NOT OPENCV_ENABLE_PKG_CONFIG ) if(NOT PkgConfig_FOUND) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index c530a4c983..f8ff242948 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -743,7 +743,7 @@ macro(ocv_check_modules define) endif() unset(${define}_${__modname}_FOUND) endforeach() - if(COMMAND pkg_check_modules) + if(PKG_CONFIG_FOUND OR PkgConfig_FOUND) pkg_check_modules(${define} ${ARGN}) endif() if(${define}_FOUND)