diff options
author | Daniele E. Domenichelli <daniele.domenichelli@iit.it> | 2015-05-29 16:50:59 (GMT) |
---|---|---|
committer | Daniele E. Domenichelli <daniele.domenichelli@iit.it> | 2015-05-29 17:22:57 (GMT) |
commit | d4c6531a945564d230200512c680ca8570b10a6c (patch) | |
tree | eab48d50c247b06273edea41453c8c99dc93076b /Tests/RunCMake/FindPkgConfig | |
parent | ec12336f15c0fb0181274ac0fe972898e24fb018 (diff) | |
download | CMake-d4c6531a945564d230200512c680ca8570b10a6c.zip CMake-d4c6531a945564d230200512c680ca8570b10a6c.tar.gz CMake-d4c6531a945564d230200512c680ca8570b10a6c.tar.bz2 |
FindPkgConfig: Fix extra paths for CMAKE_{FRAMEWORK,APPBUNDLE}_PATH vars
The CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH cache variables are
supposed to be used to generate the extra paths passed to pkg-config,
but instead the CMAKE_PREFIX_PATH variable is used.
This bug was introduced by the refactor in commit v3.1.0-rc1~747^2~1.
Diffstat (limited to 'Tests/RunCMake/FindPkgConfig')
3 files changed, 107 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_APPBUNDLE_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_APPBUNDLE_PATH.cmake new file mode 100644 index 0000000..9d4826f --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_APPBUNDLE_PATH.cmake @@ -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_APPBUNDLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_APPBUNDLE_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_APPBUNDLE_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:${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-foo/lib/pkgconfig:${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-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${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-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}") + +if(NOT FOO_FOUND) + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_FRAMEWORK_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_FRAMEWORK_PATH.cmake new file mode 100644 index 0000000..d9943d4 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMAKE_FRAMEWORK_PATH.cmake @@ -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_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_FRAMEWORK_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_FRAMEWORK_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:${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-foo/lib/pkgconfig:${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-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${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-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}") + +if(NOT FOO_FOUND) + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index bca93bb..29301d7 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -4,3 +4,8 @@ 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) + +if(APPLE) + run_cmake(FindPkgConfig_CMAKE_FRAMEWORK_PATH) + run_cmake(FindPkgConfig_CMAKE_APPBUNDLE_PATH) +endif() |