Commit 3958b3e1 authored by Brad King's avatar Brad King
Browse files

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.
parent d5c11913
......@@ -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)
......
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)
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)
......@@ -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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment