Merge topic 'FindPkgConfig_Extend-PKG_CONFIG_PATH_2'
cc5a0d8f
FindPkgConfig: More unit tests453d2b24
FindPkgConfig: small refactoring
This commit is contained in:
commit
b048a3edd0
|
@ -136,6 +136,31 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma
|
|||
list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
|
||||
endmacro()
|
||||
|
||||
# Add the content of a variable or an environment variable to a list of
|
||||
# paths
|
||||
# Usage:
|
||||
# - _pkgconfig_add_extra_path(_extra_paths VAR)
|
||||
# - _pkgconfig_add_extra_path(_extra_paths ENV VAR)
|
||||
function(_pkgconfig_add_extra_path _extra_paths_var _var)
|
||||
set(_is_env 0)
|
||||
if(_var STREQUAL "ENV")
|
||||
set(_var ${ARGV2})
|
||||
set(_is_env 1)
|
||||
endif()
|
||||
if(NOT _is_env)
|
||||
if(NOT "${${_var}}" STREQUAL "")
|
||||
list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH})
|
||||
endif()
|
||||
else()
|
||||
if(NOT "$ENV{${_var}}" STREQUAL "")
|
||||
file(TO_CMAKE_PATH "$ENV{${_var}}" _path)
|
||||
list(APPEND ${_extra_paths_var} ${_path})
|
||||
unset(_path)
|
||||
endif()
|
||||
endif()
|
||||
set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
###
|
||||
macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
|
||||
_pkgconfig_unset(${_prefix}_FOUND)
|
||||
|
@ -179,33 +204,15 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
|
|||
set(_extra_paths)
|
||||
|
||||
if(NOT _no_cmake_path)
|
||||
if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
|
||||
list(APPEND _extra_paths ${CMAKE_PREFIX_PATH})
|
||||
endif()
|
||||
if(NOT "${CMAKE_FRAMEWORK_PATH}" STREQUAL "")
|
||||
list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH})
|
||||
endif()
|
||||
if(NOT "${CMAKE_APPBUNDLE_PATH}" STREQUAL "")
|
||||
list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH})
|
||||
endif()
|
||||
_pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
|
||||
_pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
|
||||
_pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
|
||||
endif()
|
||||
|
||||
if(NOT _no_cmake_environment_path)
|
||||
if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
|
||||
file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _path)
|
||||
list(APPEND _extra_paths ${_path})
|
||||
unset(_path)
|
||||
endif()
|
||||
if(NOT "$ENV{CMAKE_FRAMEWORK_PATH}" STREQUAL "")
|
||||
file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _path)
|
||||
list(APPEND _extra_paths ${_path})
|
||||
unset(_path)
|
||||
endif()
|
||||
if(NOT "$ENV{CMAKE_APPBUNDLE_PATH}" STREQUAL "")
|
||||
file(TO_CMAKE_PATH "$ENV{CMAKE_APPBUNDLE_PATH}" _path)
|
||||
list(APPEND _extra_paths ${_path})
|
||||
unset(_path)
|
||||
endif()
|
||||
_pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
|
||||
_pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
|
||||
_pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
|
||||
endif()
|
||||
|
||||
if(NOT "${_extra_paths}" STREQUAL "")
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
|
||||
enable_language(C)
|
||||
|
||||
# Prepare environment and variables
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
|
||||
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
|
||||
if(WIN32)
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "C:\\baz")
|
||||
else()
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "/baz")
|
||||
endif()
|
||||
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
if(WIN32)
|
||||
set(expected_path "C:\\baz")
|
||||
else()
|
||||
set(expected_path "/baz")
|
||||
endif()
|
||||
|
||||
|
||||
pkg_check_modules(FOO "${expected_path}")
|
||||
|
||||
if(NOT "FOO_FOUND")
|
||||
message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
|
||||
|
||||
pkg_check_modules(BAR "${expected_path}" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
|
||||
if(NOT "BAR_FOUND")
|
||||
message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
|
||||
endif()
|
|
@ -44,7 +44,7 @@ else()
|
|||
endif()
|
||||
|
||||
|
||||
pkg_check_modules (FOO "${expected_path}")
|
||||
pkg_check_modules(FOO "${expected_path}")
|
||||
|
||||
if(NOT "FOO_FOUND")
|
||||
message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
|
||||
enable_language(C)
|
||||
|
||||
# Prepare environment and variables
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
|
||||
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
|
||||
if(WIN32)
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "C:\\baz")
|
||||
else()
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "/baz")
|
||||
endif()
|
||||
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
||||
if(NOT DEFINED CMAKE_SYSTEM_NAME
|
||||
OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
|
||||
AND NOT CMAKE_CROSSCOMPILING))
|
||||
if(EXISTS "/etc/debian_version") # is this a debian system ?
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
|
||||
# Cannot create directories for all the existing architectures...
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
|
||||
else()
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
|
||||
endif()
|
||||
else()
|
||||
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
|
||||
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||
if(uselib64)
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig")
|
||||
else()
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
pkg_check_modules(FOO "${expected_path}" NO_CMAKE_ENVIRONMENT_PATH)
|
||||
|
||||
if(NOT "FOO_FOUND")
|
||||
message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
|
||||
endif()
|
|
@ -0,0 +1,51 @@
|
|||
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
|
||||
enable_language(C)
|
||||
|
||||
# Prepare environment and variables
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
|
||||
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
|
||||
if(WIN32)
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "C:\\baz")
|
||||
else()
|
||||
set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
|
||||
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
|
||||
set(ENV{PKG_CONFIG_PATH} "/baz")
|
||||
endif()
|
||||
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
||||
if(NOT DEFINED CMAKE_SYSTEM_NAME
|
||||
OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
|
||||
AND NOT CMAKE_CROSSCOMPILING))
|
||||
if(EXISTS "/etc/debian_version") # is this a debian system ?
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
|
||||
# Cannot create directories for all the existing architectures...
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
|
||||
else()
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
|
||||
endif()
|
||||
else()
|
||||
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
|
||||
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||
if(uselib64)
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
|
||||
else()
|
||||
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
pkg_check_modules(FOO "${expected_path}" NO_CMAKE_PATH)
|
||||
|
||||
if(NOT "FOO_FOUND")
|
||||
message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
|
||||
endif()
|
|
@ -1,3 +1,6 @@
|
|||
include(RunCMake)
|
||||
|
||||
run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH)
|
||||
run_cmake(FindPkgConfig_PKGCONFIG_PATH)
|
||||
run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH)
|
||||
run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH)
|
||||
|
|
|
@ -9,6 +9,8 @@ IF "%1"=="--version" (
|
|||
|
||||
IF "%1"=="--exists" (
|
||||
SHIFT
|
||||
ECHO Expected: %*
|
||||
ECHO Found: %PKG_CONFIG_PATH%
|
||||
IF NOT "%*"=="%PKG_CONFIG_PATH%" (
|
||||
EXIT /B 1
|
||||
)
|
||||
|
|
|
@ -10,8 +10,8 @@ case $1 in
|
|||
;;
|
||||
--exists)
|
||||
shift
|
||||
echo "$@"
|
||||
echo "${PKG_CONFIG_PATH}"
|
||||
echo "Expected: $@"
|
||||
echo "Found: ${PKG_CONFIG_PATH}"
|
||||
[ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Reference in New Issue