瀏覽代碼

ENH: Add useful search locations to find_package

This teaches find_package to search

  <prefix>/(share|lib)/cmake/<name>*/

for package configuration files.  Packages that do not already have
files in a <prefix>/lib/<name>* directory can use this location to avoid
cluttering the lib directory.
Brad King 17 年之前
父節點
當前提交
e51969ac49

+ 15 - 0
Source/cmFindPackageCommand.cxx

@@ -222,6 +222,7 @@ cmFindPackageCommand::cmFindPackageCommand()
     "UNIX (U), or Apple (A) conventions.\n"
     "UNIX (U), or Apple (A) conventions.\n"
     "  <prefix>/                                               (W)\n"
     "  <prefix>/                                               (W)\n"
     "  <prefix>/(cmake|CMake)/                                 (W)\n"
     "  <prefix>/(cmake|CMake)/                                 (W)\n"
+    "  <prefix>/(share|lib)/cmake/<name>*/                     (U)\n"
     "  <prefix>/(share|lib)/<name>*/                           (U)\n"
     "  <prefix>/(share|lib)/<name>*/                           (U)\n"
     "  <prefix>/(share|lib)/<name>*/(cmake|CMake)/             (U)\n"
     "  <prefix>/(share|lib)/<name>*/(cmake|CMake)/             (U)\n"
     "On systems supporting OS X Frameworks and Application Bundles "
     "On systems supporting OS X Frameworks and Application Bundles "
@@ -1789,6 +1790,20 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
   common.push_back("lib");
   common.push_back("lib");
   common.push_back("share");
   common.push_back("share");
 
 
+  //  PREFIX/(share|lib)/cmake/(Foo|foo|FOO).*/
+  {
+  cmFindPackageFileList lister(this);
+  lister
+    / cmFileListGeneratorFixed(prefix)
+    / cmFileListGeneratorEnumerate(common)
+    / cmFileListGeneratorFixed("cmake")
+    / cmFileListGeneratorProject(this->Names);
+  if(lister.Search())
+    {
+    return true;
+    }
+  }
+
   //  PREFIX/(share|lib)/(Foo|foo|FOO).*/
   //  PREFIX/(share|lib)/(Foo|foo|FOO).*/
   {
   {
   cmFindPackageFileList lister(this);
   cmFindPackageFileList lister(this);

+ 2 - 2
Tests/FindPackageTest/CMakeLists.txt

@@ -85,12 +85,12 @@ SET(TApp_EXPECTED
 SET(Tapp_EXPECTED
 SET(Tapp_EXPECTED
   "TApp.app/Contents/Resources/cmake/tapp-config.cmake")
   "TApp.app/Contents/Resources/cmake/tapp-config.cmake")
 SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake")
 SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake")
-SET(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake")
+SET(VersionedB_EXPECTED "lib/cmake/zot-3.1/zot-config.cmake")
 SET(wibbleA_EXPECTED "A/wibble-config.cmake")
 SET(wibbleA_EXPECTED "A/wibble-config.cmake")
 SET(wibbleB_EXPECTED "B/wibble-config.cmake")
 SET(wibbleB_EXPECTED "B/wibble-config.cmake")
 SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake")
 SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake")
 SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake")
 SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake")
-SET(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake")
+SET(RecursiveC_EXPECTED "lib/cmake/zot-3.1/zot-config.cmake")
 
 
 # Check the results.
 # Check the results.
 FOREACH(p ${PACKAGES})
 FOREACH(p ${PACKAGES})

+ 0 - 0
Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake → Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake


+ 0 - 0
Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake → Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake