diff options
author | Brad King <brad.king@kitware.com> | 2008-12-17 14:24:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-12-17 14:24:05 (GMT) |
commit | 3958b3e112b7c33d40129a16811a2eff69495a42 (patch) | |
tree | 4d525f2142dfba37efedd6eca78fdcb34453d67d | |
parent | d5c1191349778dd1c1d4646b28f8f532ea0bea9e (diff) | |
download | CMake-3958b3e112b7c33d40129a16811a2eff69495a42.zip CMake-3958b3e112b7c33d40129a16811a2eff69495a42.tar.gz CMake-3958b3e112b7c33d40129a16811a2eff69495a42.tar.bz2 |
ENH: Teach find_package about more install dirs
We now search in
<prefix>/<name>*/
<prefix>/<name>*/(cmake|CMake)
when looking for package configuration files. This is useful on Windows
since the Program Files folder is in CMAKE_SYSTEM_PREFIX_PATH. These
paths are the Windows equivalent to the Apple convention application and
framework paths we already search. See issue #8264.
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 27 | ||||
-rw-r--r-- | Tests/FindPackageTest/Baz 1.1/BazConfig.cmake | 1 | ||||
-rw-r--r-- | Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake | 8 | ||||
-rw-r--r-- | Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake | 1 | ||||
-rw-r--r-- | Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake | 8 | ||||
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 6 |
6 files changed, 50 insertions, 1 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9e998aa..9577b42 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -222,6 +222,8 @@ cmFindPackageCommand::cmFindPackageCommand() "UNIX (U), or Apple (A) conventions.\n" " <prefix>/ (W)\n" " <prefix>/(cmake|CMake)/ (W)\n" + " <prefix>/<name>*/ (W)\n" + " <prefix>/<name>*/(cmake|CMake)/ (W)\n" " <prefix>/(share|lib)/cmake/<name>*/ (U)\n" " <prefix>/(share|lib)/<name>*/ (U)\n" " <prefix>/(share|lib)/<name>*/(cmake|CMake)/ (U)\n" @@ -1783,6 +1785,31 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } + // PREFIX/(Foo|foo|FOO).*/ + { + cmFindPackageFileList lister(this); + lister + / cmFileListGeneratorFixed(prefix) + / cmFileListGeneratorProject(this->Names); + if(lister.Search()) + { + return true; + } + } + + // PREFIX/(Foo|foo|FOO).*/(cmake|CMake)/ + { + cmFindPackageFileList lister(this); + lister + / cmFileListGeneratorFixed(prefix) + / cmFileListGeneratorProject(this->Names) + / cmFileListGeneratorCaseInsensitive("cmake"); + if(lister.Search()) + { + return true; + } + } + // Construct list of common install locations (lib and share). std::vector<std::string> common; if(this->UseLib64Paths) diff --git a/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake b/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake b/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake new file mode 100644 index 0000000..321fa11 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 1.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + diff --git a/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake new file mode 100644 index 0000000..4576809 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 1.2) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 30a1dd1..fe901ad 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -36,7 +36,7 @@ FIND_PACKAGE(VersionTestD 1.2.3.4) # For purposes of the test wipe out previous find results. SET(PACKAGES foo Foo Bar TFramework Tframework TApp Tapp Special - VersionedA VersionedB VersionedC + VersionedA VersionedB VersionedC VersionedD VersionedE wibbleA wibbleB RecursiveA RecursiveB RecursiveC ) @@ -61,6 +61,8 @@ FIND_PACKAGE(Special NAMES Suffix SuffixTest PATH_SUFFIXES test) FIND_PACKAGE(VersionedA 2 NAMES zot) FIND_PACKAGE(VersionedB 3.1 EXACT NAMES zot) FIND_PACKAGE(VersionedC 4.0 EXACT NAMES zot) +FIND_PACKAGE(VersionedD 1.1 EXACT NAMES Baz) +FIND_PACKAGE(VersionedE 1.2 EXACT NAMES Baz) # HINTS should override the system but PATHS should not LIST(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A") @@ -88,6 +90,8 @@ SET(Tapp_EXPECTED SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake") SET(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake") SET(VersionedC_EXPECTED "lib/cmake/zot-4.0/zot-config.cmake") +SET(VersionedD_EXPECTED "Baz 1.1/BazConfig.cmake") +SET(VersionedE_EXPECTED "Baz 1.2/CMake/BazConfig.cmake") SET(wibbleA_EXPECTED "A/wibble-config.cmake") SET(wibbleB_EXPECTED "B/wibble-config.cmake") SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake") |