From e55c154c5b1cbecd826ac216d69ce88845a56cdc Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Mon, 27 Jun 2022 07:10:27 +0400 Subject: cmFindPackageCommand: Add one more search path The `PREFIX/(Foo|foo|FOO).*/(cmake|CMake)/(Foo|foo|FOO).*/` search path is the similar to the one already exists `PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/`. --- Help/command/find_package.rst | 1 + Help/release/dev/find_package-one-more-path.rst | 6 ++++++ Source/cmFindPackageCommand.cxx | 14 ++++++++++---- .../cmake/SearchPaths-1.2.3/SearchPathsConfig.cmake | 0 .../SearchPaths_prefix_pkg_cmake_pkg-stderr.txt | 14 ++++++++++++++ .../find_package/SearchPaths_prefix_pkg_cmake_pkg.cmake | 1 + 6 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/find_package-one-more-path.rst create mode 100644 Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1.2.3/cmake/SearchPaths-1.2.3/SearchPathsConfig.cmake create mode 100644 Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-stderr.txt create mode 100644 Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg.cmake diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index ee52c41..d6c5105 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -291,6 +291,7 @@ Each entry is meant for installation trees following Windows (``W``), UNIX /(cmake|CMake)/ (W) /*/ (W) /*/(cmake|CMake)/ (W) + /*/(cmake|CMake)/*/ (W) /(lib/|lib*|share)/cmake/*/ (U) /(lib/|lib*|share)/*/ (U) /(lib/|lib*|share)/*/(cmake|CMake)/ (U) diff --git a/Help/release/dev/find_package-one-more-path.rst b/Help/release/dev/find_package-one-more-path.rst new file mode 100644 index 0000000..554b67d --- /dev/null +++ b/Help/release/dev/find_package-one-more-path.rst @@ -0,0 +1,6 @@ +find_package-one-more-path +-------------------------- + +* The :command:`find_package` command now considers paths of + the form ``/*/(cmake|CMake)/*/`` when + searching for package configuration files. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index f260ec7..92e98c5 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -2524,6 +2524,16 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) return true; } + auto secondPkgDirGen = + cmProjectDirectoryListGenerator{ this->Names, this->SortOrder, + this->SortDirection }; + + // PREFIX/(Foo|foo|FOO).*/(cmake|CMake)/(Foo|foo|FOO).*/ + if (TryGeneratedPaths(searchFn, prefix, firstPkgDirGen, iCMakeGen, + secondPkgDirGen)) { + return true; + } + // Construct list of common install locations (lib and share). std::vector common; std::string libArch; @@ -2561,10 +2571,6 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) return true; } - auto secondPkgDirGen = - cmProjectDirectoryListGenerator{ this->Names, this->SortOrder, - this->SortDirection }; - // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/ if (TryGeneratedPaths(searchFn, prefix, firstPkgDirGen, cmnGen, cmakeGen, secondPkgDirGen)) { diff --git a/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1.2.3/cmake/SearchPaths-1.2.3/SearchPathsConfig.cmake b/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1.2.3/cmake/SearchPaths-1.2.3/SearchPathsConfig.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-stderr.txt b/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-stderr.txt new file mode 100644 index 0000000..812c607 --- /dev/null +++ b/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-stderr.txt @@ -0,0 +1,14 @@ + find_package considered the following locations for SearchPaths's Config + module: + + .*/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-build/CMakeFiles/pkgRedirects/SearchPathsConfig\.cmake + .*/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg-build/CMakeFiles/pkgRedirects/searchpaths-config\.cmake + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPathsConfig\.cmake + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/searchpaths-config\.cmake + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1\.2\.3/SearchPathsConfig\.cmake + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1\.2\.3/searchpaths-config\.cmake + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1\.2\.3/cmake/SearchPaths-1\.2\.3/SearchPathsConfig\.cmake + + The file was found at + + .*/Tests/RunCMake/find_package/SearchPaths/prefix_pkg_cmake_pkg/SearchPaths-1\.2\.3/cmake/SearchPaths-1\.2\.3/SearchPathsConfig\.cmake diff --git a/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg.cmake b/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg.cmake new file mode 100644 index 0000000..d831313 --- /dev/null +++ b/Tests/RunCMake/find_package/SearchPaths_prefix_pkg_cmake_pkg.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/SearchPaths.cmake") -- cgit v0.12 From 19366408fe4fedaec19e7e964adb02d090e8c0b7 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Wed, 3 Aug 2022 21:43:29 +0400 Subject: cmFindPackageCommand: Protect overrides of `cmDirectoryListGenerator` Move virtual function overrides into a protected section of class. --- Source/cmFindPackageCommand.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 92e98c5..3f8378b 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -291,6 +291,7 @@ public: { } +protected: void OnMatchesLoaded() override { // check if there is a specific sorting order to perform @@ -316,6 +317,7 @@ public: { } +protected: std::string TransformNameBeforeCmp(std::string name) override { return cmStrCat(name, this->Extension); -- cgit v0.12