Modules: Guard calls to pkg_check_modules
Before calling pkg_check_modules, modules must check PKG_CONFIG_FOUND. When FindPkgConfig.cmake is loaded, pkg_check_modules is always defined regardless of pkg-config being present. However, the whole module might be disabled on user request with CMAKE_DISABLE_FIND_PACKAGE_PkgConfig. This must not break Find modules which just look for a hint or similar.
This commit is contained in:
parent
aa6b2180bf
commit
25b947589a
@ -293,12 +293,14 @@ if(BLA_PREFER_PKGCONFIG)
|
||||
set(BLA_PKGCONFIG_BLAS "blas")
|
||||
endif()
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKGC_BLAS QUIET ${BLA_PKGCONFIG_BLAS})
|
||||
if(PKGC_BLAS_FOUND)
|
||||
set(BLAS_FOUND ${PKGC_BLAS_FOUND})
|
||||
set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
|
||||
_add_blas_target()
|
||||
return()
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKGC_BLAS QUIET ${BLA_PKGCONFIG_BLAS})
|
||||
if(PKGC_BLAS_FOUND)
|
||||
set(BLAS_FOUND ${PKGC_BLAS_FOUND})
|
||||
set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
|
||||
_add_blas_target()
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -49,8 +49,9 @@ cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
pkg_check_modules(PC_EXPAT QUIET expat)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_EXPAT QUIET expat)
|
||||
endif()
|
||||
|
||||
# Look for the header file.
|
||||
find_path(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS})
|
||||
|
@ -40,7 +40,9 @@ cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
|
||||
endif()
|
||||
set(Fontconfig_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
|
||||
set(Fontconfig_VERSION ${PKG_FONTCONFIG_VERSION})
|
||||
|
||||
|
@ -81,10 +81,11 @@ endif()
|
||||
# This will return ``GSL_INCLUDEDIR`` and ``GSL_LIBDIR`` used below.
|
||||
if( GSL_USE_PKGCONFIG )
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules( GSL QUIET gsl )
|
||||
|
||||
if( EXISTS "${GSL_INCLUDEDIR}" )
|
||||
get_filename_component( GSL_ROOT_DIR "${GSL_INCLUDEDIR}" DIRECTORY CACHE)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules( GSL QUIET gsl )
|
||||
if( EXISTS "${GSL_INCLUDEDIR}" )
|
||||
get_filename_component( GSL_ROOT_DIR "${GSL_INCLUDEDIR}" DIRECTORY CACHE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -43,7 +43,9 @@ if (NOT WIN32)
|
||||
# in the find_path() and find_library() calls
|
||||
# also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
|
||||
find_package(PkgConfig QUIET)
|
||||
PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
|
||||
endif()
|
||||
set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
|
||||
set(GNUTLS_VERSION ${PC_GNUTLS_VERSION})
|
||||
# keep for backward compatibility
|
||||
|
@ -115,7 +115,9 @@ find_package(PkgConfig QUIET)
|
||||
function(FIND_IMAGEMAGICK_API component header)
|
||||
set(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
|
||||
|
||||
pkg_check_modules(PC_${component} QUIET ${component})
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_${component} QUIET ${component})
|
||||
endif()
|
||||
|
||||
find_path(ImageMagick_${component}_INCLUDE_DIR
|
||||
NAMES ${header}
|
||||
|
@ -289,15 +289,17 @@ if(BLA_PREFER_PKGCONFIG)
|
||||
set(BLA_PKGCONFIG_LAPACK "lapack")
|
||||
endif()
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKGC_LAPACK QUIET ${BLA_PKGCONFIG_LAPACK})
|
||||
if(PKGC_LAPACK_FOUND)
|
||||
set(LAPACK_FOUND TRUE)
|
||||
set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}")
|
||||
if (BLAS_LIBRARIES)
|
||||
list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARIES}")
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKGC_LAPACK QUIET ${BLA_PKGCONFIG_LAPACK})
|
||||
if(PKGC_LAPACK_FOUND)
|
||||
set(LAPACK_FOUND TRUE)
|
||||
set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}")
|
||||
if (BLAS_LIBRARIES)
|
||||
list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARIES}")
|
||||
endif()
|
||||
_add_lapack_target()
|
||||
return()
|
||||
endif()
|
||||
_add_lapack_target()
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -58,7 +58,9 @@ cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the find_path() and find_library() calls
|
||||
find_package(PkgConfig QUIET)
|
||||
PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0)
|
||||
endif()
|
||||
|
||||
find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
|
||||
HINTS
|
||||
|
@ -51,7 +51,9 @@ cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the find_path() and find_library() calls
|
||||
find_package(PkgConfig QUIET)
|
||||
PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt)
|
||||
endif()
|
||||
set(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER})
|
||||
|
||||
find_path(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h
|
||||
@ -75,7 +77,9 @@ find_library(LIBXSLT_LIBRARY NAMES xslt libxslt
|
||||
|
||||
set(LIBXSLT_LIBRARIES ${LIBXSLT_LIBRARY})
|
||||
|
||||
PKG_CHECK_MODULES(PC_LIBXSLT_EXSLT QUIET libexslt)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_LIBXSLT_EXSLT QUIET libexslt)
|
||||
endif()
|
||||
set(LIBXSLT_EXSLT_DEFINITIONS ${PC_LIBXSLT_EXSLT_CFLAGS_OTHER})
|
||||
|
||||
find_path(LIBXSLT_EXSLT_INCLUDE_DIR NAMES libexslt/exslt.h
|
||||
|
@ -38,7 +38,9 @@ This will define the following variables in your project:
|
||||
# Use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_Libinput QUIET libinput)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKG_Libinput QUIET libinput)
|
||||
endif()
|
||||
|
||||
set(Libinput_COMPILE_OPTIONS ${PKG_Libinput_CFLAGS_OTHER})
|
||||
set(Libinput_VERSION ${PKG_Libinput_VERSION})
|
||||
|
@ -207,7 +207,9 @@ endfunction()
|
||||
|
||||
if (UNIX)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(_OPENSSL QUIET openssl)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_OPENSSL QUIET openssl)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
|
Loading…
Reference in New Issue
Block a user