diff options
author | Brad King <brad.king@kitware.com> | 2023-02-24 13:30:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-02-24 13:31:28 (GMT) |
commit | d19b61bf4317282909c897f7dae61f2cc2c4ca61 (patch) | |
tree | 29397da786bd19f413ea7ec1543ef9670b52e2f1 | |
parent | 0eb6c31551d58e53eb99316570e8ec684080c0ee (diff) | |
parent | df9c4b18720c6c8263c13641bc0a6452138d6fba (diff) | |
download | CMake-d19b61bf4317282909c897f7dae61f2cc2c4ca61.zip CMake-d19b61bf4317282909c897f7dae61f2cc2c4ca61.tar.gz CMake-d19b61bf4317282909c897f7dae61f2cc2c4ca61.tar.bz2 |
Merge topic 'find_package-PACKAGENAME_ROOT'
df9c4b1872 find_package: Use <PACKAGENAME>_ROOT variables as search prefixes
4da27a73bd Help: Document <PackageName>_ROOT variable ordering using an ordered list
bfeb16bd5b cmFindPackageCommand: Refactor CMP0074 logic to de-duplicate lookups
c0fcd07e6f cmFindPackageCommand: Factor out methods for package root stack management
acd9636d9d cmSystemTools: Add helpers for reading and parsing PATH env vars
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8240
30 files changed, 761 insertions, 75 deletions
diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index bd55e24..21236fa 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -140,21 +140,40 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: |prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_SYSTEM_PREFIX_PATH` -1. .. versionadded:: 3.12 - If called from within a find module or any other script loaded by a call to - :command:`find_package(<PackageName>)`, search prefixes unique to the - current package being found. Specifically, look in the - :variable:`<PackageName>_ROOT` CMake variable and the - :envvar:`<PackageName>_ROOT` environment variable. - The package root variables are maintained as a stack, so if called from - nested find modules or config packages, root paths from the parent's find - module or config package will be searched after paths from the current - module or package. In other words, the search order would be - ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``, - ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc. - This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting - the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. - See policy :policy:`CMP0074`. +1. If called from within a find module or any other script loaded by a call to + :command:`find_package(<PackageName>)`, search prefixes unique to the + current package being found. See policy :policy:`CMP0074`. + + .. versionadded:: 3.12 + + Specifically, search paths specified by the following variables, in order: + + a. :variable:`<PackageName>_ROOT` CMake variable, + where ``<PackageName>`` is the case-preserved package name. + + b. :variable:`<PACKAGENAME>_ROOT` CMake variable, + where ``<PACKAGENAME>`` is the upper-cased package name. + See policy :policy:`CMP0144`. + + .. versionadded:: 3.27 + + c. :envvar:`<PackageName>_ROOT` environment variable, + where ``<PackageName>`` is the case-preserved package name. + + d. :envvar:`<PACKAGENAME>_ROOT` environment variable, + where ``<PACKAGENAME>`` is the upper-cased package name. + See policy :policy:`CMP0144`. + + .. versionadded:: 3.27 + + The package root variables are maintained as a stack, so if called from + nested find modules or config packages, root paths from the parent's find + module or config package will be searched after paths from the current + module or package. In other words, the search order would be + ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``, + ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc. + This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting + the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index de4cb88..b82088e 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -367,17 +367,37 @@ The set of installation prefixes is constructed using the following steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are enabled. -1. .. versionadded:: 3.12 - Search paths specified in the :variable:`<PackageName>_ROOT` CMake - variable and the :envvar:`<PackageName>_ROOT` environment variable, - where ``<PackageName>`` is the package to be found - (the case-preserved first argument to ``find_package``). - The package root variables are maintained as a stack so if - called from within a find module, root paths from the parent's find - module will also be searched after paths for the current package. - This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting - the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. - See policy :policy:`CMP0074`. +1. Search prefixes unique to the current ``<PackageName>`` being found. + See policy :policy:`CMP0074`. + + .. versionadded:: 3.12 + + Specifically, search prefixes specified by the following variables, + in order: + + a. :variable:`<PackageName>_ROOT` CMake variable, + where ``<PackageName>`` is the case-preserved package name. + + b. :variable:`<PACKAGENAME>_ROOT` CMake variable, + where ``<PACKAGENAME>`` is the upper-cased package name. + See policy :policy:`CMP0144`. + + .. versionadded:: 3.27 + + c. :envvar:`<PackageName>_ROOT` environment variable, + where ``<PackageName>`` is the case-preserved package name. + + d. :envvar:`<PACKAGENAME>_ROOT` environment variable, + where ``<PACKAGENAME>`` is the upper-cased package name. + See policy :policy:`CMP0144`. + + .. versionadded:: 3.27 + + The package root variables are maintained as a stack so if + called from within a find module, root paths from the parent's find + module will also be searched after paths for the current package. + This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting + the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. 2. Search paths specified in cmake-specific cache variables. These are intended to be used on the command line with a :option:`-DVAR=VALUE <cmake -D>`. diff --git a/Help/envvar/PackageName_ROOT.rst b/Help/envvar/PackageName_ROOT.rst index fa8c385..6e9c744 100644 --- a/Help/envvar/PackageName_ROOT.rst +++ b/Help/envvar/PackageName_ROOT.rst @@ -17,3 +17,17 @@ by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment variable convention on those platforms). See also the :variable:`<PackageName>_ROOT` CMake variable. + +.. envvar:: <PACKAGENAME>_ROOT + + .. versionadded:: 3.27 + + Calls to :command:`find_package(<PackageName>)` will also search in + prefixes specified by the upper-case ``<PACKAGENAME>_ROOT`` environment + variable. See policy :policy:`CMP0144`. + +.. note:: + + Note that the ``<PackageName>_ROOT`` and ``<PACKAGENAME>_ROOT`` + environment variables are distinct only on platforms that have + case-sensitive environments. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 22e9eb2..e4c286d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -51,6 +51,14 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used to determine whether to report an error on use of deprecated macros or functions. +Policies Introduced by CMake 3.27 +================================= + +.. toctree:: + :maxdepth: 1 + + CMP0144: find_package uses upper-case PACKAGENAME_ROOT variables. </policy/CMP0144> + Policies Introduced by CMake 3.26 ================================= diff --git a/Help/policy/CMP0144.rst b/Help/policy/CMP0144.rst new file mode 100644 index 0000000..3959d96 --- /dev/null +++ b/Help/policy/CMP0144.rst @@ -0,0 +1,26 @@ +CMP0144 +------- + +.. versionadded:: 3.27 + +:command:`find_package` uses upper-case ``<PACKAGENAME>_ROOT`` variables. + +In CMake 3.27 and above the :command:`find_package(<PackageName>)` command now +searches prefixes specified by the upper-case :variable:`<PACKAGENAME>_ROOT` +CMake variable and the :envvar:`<PACKAGENAME>_ROOT` environment variable +in addition to the case-preserved :variable:`<PackageName>_ROOT` and +:envvar:`<PackageName>_ROOT` variables used since policy :policy:`CMP0074`. +This policy provides compatibility with projects that have not been +updated to avoid using ``<PACKAGENAME>_ROOT`` variables for other purposes. + +The ``OLD`` behavior for this policy is to ignore ``<PACKAGENAME>_ROOT`` +variables if the original ``<PackageName>`` has lower-case characters. +The ``NEW`` behavior for this policy is to use ``<PACKAGENAME>_ROOT`` +variables. + +This policy was introduced in CMake version 3.27. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. +Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` +explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/find_package-PACKAGENAME_ROOT.rst b/Help/release/dev/find_package-PACKAGENAME_ROOT.rst new file mode 100644 index 0000000..0388271 --- /dev/null +++ b/Help/release/dev/find_package-PACKAGENAME_ROOT.rst @@ -0,0 +1,7 @@ +find_package-PACKAGENAME_ROOT +----------------------------- + +* The :command:`find_package` command now searches prefixes specified by + upper-case :variable:`<PACKAGENAME>_ROOT` CMake variables and upper-case + :envvar:`<PACKAGENAME>_ROOT` environment variables. + See policy :policy:`CMP0144`. diff --git a/Help/variable/PackageName_ROOT.rst b/Help/variable/PackageName_ROOT.rst index 6b17be3..8b728ba 100644 --- a/Help/variable/PackageName_ROOT.rst +++ b/Help/variable/PackageName_ROOT.rst @@ -14,3 +14,11 @@ This variable may hold a single prefix or a :ref:`semicolon-separated list <CMake Language Lists>` of multiple prefixes. See also the :envvar:`<PackageName>_ROOT` environment variable. + +.. variable:: <PACKAGENAME>_ROOT + + .. versionadded:: 3.27 + + Calls to :command:`find_package(<PackageName>)` will also search in + prefixes specified by the upper-case ``<PACKAGENAME>_ROOT`` CMake + variable. See policy :policy:`CMP0144`. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index c1b82ab..5f1a2c5 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -975,35 +975,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } } - { - // Allocate a PACKAGE_ROOT_PATH for the current find_package call. - this->Makefile->FindPackageRootPathStack.emplace_back(); - std::vector<std::string>& rootPaths = - this->Makefile->FindPackageRootPathStack.back(); - - // Add root paths from <PackageName>_ROOT CMake and environment variables, - // subject to CMP0074. - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0074)) { - case cmPolicies::WARN: - this->Makefile->MaybeWarnCMP0074(this->Name); - CM_FALLTHROUGH; - case cmPolicies::OLD: - // OLD behavior is to ignore the <pkg>_ROOT variables. - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0074)); - break; - case cmPolicies::NEW: { - // NEW behavior is to honor the <pkg>_ROOT variables. - std::string const rootVar = this->Name + "_ROOT"; - this->Makefile->GetDefExpandList(rootVar, rootPaths, false); - cmSystemTools::GetPath(rootPaths, rootVar.c_str()); - } break; - } - } + this->PushFindPackageRootPathStack(); this->SetModuleVariables(components, componentVarDefs); @@ -1129,8 +1101,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) // Restore original state of "_FIND_" variables set in SetModuleVariables() this->RestoreFindDefinitions(); - // Pop the package stack - this->Makefile->FindPackageRootPathStack.pop_back(); + this->PopFindPackageRootPathStack(); if (!this->DebugBuffer.empty()) { this->DebugMessage(this->DebugBuffer); @@ -1834,6 +1805,99 @@ void cmFindPackageCommand::AppendSuccessInformation() } } +void cmFindPackageCommand::PushFindPackageRootPathStack() +{ + // Allocate a PACKAGE_ROOT_PATH for the current find_package call. + this->Makefile->FindPackageRootPathStack.emplace_back(); + std::vector<std::string>& rootPaths = + this->Makefile->FindPackageRootPathStack.back(); + + // Add root paths from <PackageName>_ROOT CMake and environment variables, + // subject to CMP0074. + std::string const rootVar = this->Name + "_ROOT"; + cmValue rootDef = this->Makefile->GetDefinition(rootVar); + if (rootDef && rootDef.IsEmpty()) { + rootDef = nullptr; + } + cm::optional<std::string> rootEnv = cmSystemTools::GetEnvVar(rootVar); + if (rootEnv && rootEnv->empty()) { + rootEnv = cm::nullopt; + } + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0074)) { + case cmPolicies::WARN: + this->Makefile->MaybeWarnCMP0074(rootVar, rootDef, rootEnv); + CM_FALLTHROUGH; + case cmPolicies::OLD: + // OLD behavior is to ignore the <PackageName>_ROOT variables. + return; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0074)); + return; + case cmPolicies::NEW: { + // NEW behavior is to honor the <PackageName>_ROOT variables. + } break; + } + + // Add root paths from <PACKAGENAME>_ROOT CMake and environment variables, + // if they are different than <PackageName>_ROOT, and subject to CMP0144. + std::string const rootVAR = cmSystemTools::UpperCase(rootVar); + cmValue rootDEF; + cm::optional<std::string> rootENV; + if (rootVAR != rootVar) { + rootDEF = this->Makefile->GetDefinition(rootVAR); + if (rootDEF && (rootDEF.IsEmpty() || rootDEF == rootDef)) { + rootDEF = nullptr; + } + rootENV = cmSystemTools::GetEnvVar(rootVAR); + if (rootENV && (rootENV->empty() || rootENV == rootEnv)) { + rootENV = cm::nullopt; + } + } + + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0144)) { + case cmPolicies::WARN: + this->Makefile->MaybeWarnCMP0144(rootVAR, rootDEF, rootENV); + CM_FALLTHROUGH; + case cmPolicies::OLD: + // OLD behavior is to ignore the <PACKAGENAME>_ROOT variables. + rootDEF = nullptr; + rootENV = cm::nullopt; + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0144)); + return; + case cmPolicies::NEW: { + // NEW behavior is to honor the <PACKAGENAME>_ROOT variables. + } break; + } + + if (rootDef) { + cmExpandList(*rootDef, rootPaths); + } + if (rootDEF) { + cmExpandList(*rootDEF, rootPaths); + } + if (rootEnv) { + std::vector<std::string> p = cmSystemTools::SplitEnvPath(*rootEnv); + std::move(p.begin(), p.end(), std::back_inserter(rootPaths)); + } + if (rootENV) { + std::vector<std::string> p = cmSystemTools::SplitEnvPath(*rootENV); + std::move(p.begin(), p.end(), std::back_inserter(rootPaths)); + } +} + +void cmFindPackageCommand::PopFindPackageRootPathStack() +{ + this->Makefile->FindPackageRootPathStack.pop_back(); +} + void cmFindPackageCommand::ComputePrefixes() { this->FillPrefixesPackageRedirect(); diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 28e00a1..18684c9 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -125,6 +125,9 @@ private: void StoreVersionFound(); void SetConfigDirCacheVariable(const std::string& value); + void PushFindPackageRootPathStack(); + void PopFindPackageRootPathStack(); + void ComputePrefixes(); void FillPrefixesPackageRedirect(); void FillPrefixesPackageRoot(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d963a5a..2fc2974 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -208,32 +208,47 @@ bool cmMakefile::CheckCMP0037(std::string const& targetName, return true; } -void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) +void cmMakefile::MaybeWarnCMP0074(std::string const& rootVar, cmValue rootDef, + cm::optional<std::string> const& rootEnv) { - // Warn if a <pkg>_ROOT variable we may use is set. - std::string const varName = pkg + "_ROOT"; - cmValue var = this->GetDefinition(varName); - std::string env; - cmSystemTools::GetEnv(varName, env); - - bool const haveVar = cmNonempty(var); - bool const haveEnv = !env.empty(); - if ((haveVar || haveEnv) && this->WarnedCMP0074.insert(varName).second) { + // Warn if a <PackageName>_ROOT variable we may use is set. + if ((rootDef || rootEnv) && this->WarnedCMP0074.insert(rootVar).second) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0074) << "\n"; - if (haveVar) { - w << "CMake variable " << varName << " is set to:\n" - << " " << *var << "\n"; + if (rootDef) { + w << "CMake variable " << rootVar << " is set to:\n" + << " " << *rootDef << "\n"; } - if (haveEnv) { - w << "Environment variable " << varName << " is set to:\n" - << " " << env << "\n"; + if (rootEnv) { + w << "Environment variable " << rootVar << " is set to:\n" + << " " << *rootEnv << "\n"; } w << "For compatibility, CMake is ignoring the variable."; this->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); } } +void cmMakefile::MaybeWarnCMP0144(std::string const& rootVAR, cmValue rootDEF, + cm::optional<std::string> const& rootENV) +{ + // Warn if a <PACKAGENAME>_ROOT variable we may use is set. + if ((rootDEF || rootENV) && this->WarnedCMP0144.insert(rootVAR).second) { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0144) << "\n"; + if (rootDEF) { + w << "CMake variable " << rootVAR << " is set to:\n" + << " " << *rootDEF << "\n"; + } + if (rootENV) { + w << "Environment variable " << rootVAR << " is set to:\n" + << " " << *rootENV << "\n"; + } + w << "For compatibility, find_package is ignoring the variable, but " + "code in a .cmake module might still use it."; + this->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + } +} + cmBTStringRange cmMakefile::GetIncludeDirectoriesEntries() const { return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7b19c97..3cf6e61 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1011,7 +1011,10 @@ public: bool GetDebugFindPkgMode() const; - void MaybeWarnCMP0074(std::string const& pkg); + void MaybeWarnCMP0074(std::string const& rootVar, cmValue rootDef, + cm::optional<std::string> const& rootEnv); + void MaybeWarnCMP0144(std::string const& rootVAR, cmValue rootDEF, + cm::optional<std::string> const& rootENV); void MaybeWarnUninitialized(std::string const& variable, const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; @@ -1189,6 +1192,7 @@ private: bool CheckSystemVars; bool CheckCMP0000; std::set<std::string> WarnedCMP0074; + std::set<std::string> WarnedCMP0144; bool IsSourceFileTryCompile; mutable bool SuppressSideEffects; ImportedTargetScope CurrentImportedTargetScope = ImportedTargetScope::Local; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 568eca3..1eca586 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -434,7 +434,10 @@ class cmMakefile; 3, 25, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0143, \ "Global property USE_FOLDERS treated as ON by default", 3, 26, 0, \ - cmPolicies::WARN) + cmPolicies::WARN) \ + SELECT(POLICY, CMP0144, \ + "find_package uses upper-case <PACKAGENAME>_ROOT variables.", 3, 27, \ + 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3d61270..1fb0079 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1648,6 +1648,32 @@ std::string cmSystemTools::RelativeIfUnder(std::string const& top, return out; } +cm::optional<std::string> cmSystemTools::GetEnvVar(std::string const& var) +{ + cm::optional<std::string> result; + { + std::string value; + if (cmSystemTools::GetEnv(var, value)) { + result = std::move(value); + } + } + return result; +} + +std::vector<std::string> cmSystemTools::SplitEnvPath(std::string const& value) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + static cm::string_view sep = ";"_s; +#else + static cm::string_view sep = ":"_s; +#endif + std::vector<std::string> paths = cmTokenize(value, sep); + for (std::string& p : paths) { + SystemTools::ConvertToUnixSlashes(p); + } + return paths; +} + #ifndef CMAKE_BOOTSTRAP bool cmSystemTools::UnsetEnv(const char* value) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 09f2bf0..7d55d4b 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -399,6 +399,9 @@ public: static std::string RelativeIfUnder(std::string const& top, std::string const& in); + static cm::optional<std::string> GetEnvVar(std::string const& var); + static std::vector<std::string> SplitEnvPath(std::string const& value); + #ifndef CMAKE_BOOTSTRAP /** Remove an environment variable */ static bool UnsetEnv(const char* value); diff --git a/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive-stderr.txt new file mode 100644 index 0000000..3ccd101 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive-stderr.txt @@ -0,0 +1,45 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive.cmake b/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive.cmake new file mode 100644 index 0000000..f0853ee --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-NEW-CaseInsensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +cmake_policy(SET CMP0144 NEW) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive-stderr.txt new file mode 100644 index 0000000..3ccd101 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive-stderr.txt @@ -0,0 +1,45 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive.cmake b/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive.cmake new file mode 100644 index 0000000..f0853ee --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-NEW-CaseSensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +cmake_policy(SET CMP0144 NEW) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive-stderr.txt new file mode 100644 index 0000000..3274b82 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive-stderr.txt @@ -0,0 +1,45 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive.cmake b/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive.cmake new file mode 100644 index 0000000..f1560a9 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-OLD-CaseInsensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +cmake_policy(SET CMP0144 OLD) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive-stderr.txt new file mode 100644 index 0000000..c02a797 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive-stderr.txt @@ -0,0 +1,45 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive.cmake b/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive.cmake new file mode 100644 index 0000000..f1560a9 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-OLD-CaseSensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +cmake_policy(SET CMP0144 OLD) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive-stderr.txt new file mode 100644 index 0000000..3540dc9 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive-stderr.txt @@ -0,0 +1,63 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' ++ +CMake Warning \(dev\) at CMP0144-common.cmake:[0-9]+ \(find_package\): + Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT + variables. Run "cmake --help-policy CMP0144" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + CMake variable FOO_ROOT is set to: + + [^ +]*/Tests/RunCMake/find_package/PackageRoot/foo/cmake_root + + For compatibility, find_package is ignoring the variable, but code in a + \.cmake module might still use it\. +Call Stack \(most recent call first\): + CMP0144-common.cmake:[0-9]+ \(RunTestCase\) + CMP0144-WARN-CaseInsensitive.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive.cmake b/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive.cmake new file mode 100644 index 0000000..10f6b66 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseInsensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +# (do not set CMP0144) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed-stderr.txt b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed-stderr.txt new file mode 100644 index 0000000..3ccd101 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed-stderr.txt @@ -0,0 +1,45 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/cmake_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/cmake_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/cmake_root/include +FOO_TEST_PATH_ZOT: <base>/foo/cmake_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/cmake_root/bin/foo.exe + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: <base>/foo/env_root/include/foo.h +FOO_TEST_FILE_ZOT: <base>/foo/env_root/include/zot/zot.h +FOO_TEST_PATH_FOO: <base>/foo/env_root/include +FOO_TEST_PATH_ZOT: <base>/foo/env_root/include/zot +FOO_TEST_PROG_FOO: <base>/foo/env_root/bin/foo.exe + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed.cmake b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed.cmake new file mode 100644 index 0000000..10f6b66 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-Mixed.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +# (do not set CMP0144) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-stderr.txt b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-stderr.txt new file mode 100644 index 0000000..b828f05 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive-stderr.txt @@ -0,0 +1,68 @@ +^---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '<base>/foo/env_root' ++ +CMake Warning \(dev\) at CMP0144-common.cmake:[0-9]+ \(find_package\): + Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT + variables. Run "cmake --help-policy CMP0144" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + CMake variable FOO_ROOT is set to: + + [^ +]*/Tests/RunCMake/find_package/PackageRoot/foo/cmake_root + + Environment variable FOO_ROOT is set to: + + [^ +]*/Tests/RunCMake/find_package/PackageRoot/foo/env_root + + For compatibility, find_package is ignoring the variable, but code in a + \.cmake module might still use it\. +Call Stack \(most recent call first\): + CMP0144-common.cmake:[0-9]+ \(RunTestCase\) + CMP0144-WARN-CaseSensitive.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '<base>/foo/cmake_root' +ENV{FOO_ROOT}: '' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +---------- +FOO_ROOT : '' +ENV{FOO_ROOT}: '<base>/foo/env_root' + +find_package\(Foo\) +FOO_TEST_FILE_FOO: FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT: FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO: FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT: FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO: FOO_TEST_PROG_FOO-NOTFOUND + +----------$ diff --git a/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive.cmake b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive.cmake new file mode 100644 index 0000000..10f6b66 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-WARN-CaseSensitive.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.26) +# (do not set CMP0144) +include(CMP0144-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0144-common.cmake b/Tests/RunCMake/find_package/CMP0144-common.cmake new file mode 100644 index 0000000..58eccca --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0144-common.cmake @@ -0,0 +1,78 @@ +# (includer selects CMP0144) +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) +set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) + +function(PrintPath label path) + string(REPLACE "${PackageRoot_BASE}" "<base>" out "${path}") + message("${label} ${out}") +endfunction() + +macro(RunTestCase) + message("----------") + PrintPath("FOO_ROOT :" "'${FOO_ROOT}'") + PrintPath("ENV{FOO_ROOT}:" "'$ENV{FOO_ROOT}'") + message("") + + find_package(Foo) + message("find_package(Foo)") + PrintPath("FOO_TEST_FILE_FOO:" "${FOO_TEST_FILE_FOO}") + PrintPath("FOO_TEST_FILE_ZOT:" "${FOO_TEST_FILE_ZOT}") + PrintPath("FOO_TEST_PATH_FOO:" "${FOO_TEST_PATH_FOO}") + PrintPath("FOO_TEST_PATH_ZOT:" "${FOO_TEST_PATH_ZOT}") + PrintPath("FOO_TEST_PROG_FOO:" "${FOO_TEST_PROG_FOO}") + message("") + + unset(FOO_ROOT) + unset(ENV{FOO_ROOT}) + if(NOT CMAKE_HOST_WIN32) + unset(Foo_ROOT) + unset(ENV{Foo_ROOT}) + endif() + unset(FOO_TEST_FILE_FOO) + unset(FOO_TEST_FILE_ZOT) + unset(FOO_TEST_PATH_FOO) + unset(FOO_TEST_PATH_ZOT) + unset(FOO_TEST_PROG_FOO) + unset(FOO_TEST_FILE_FOO CACHE) + unset(FOO_TEST_FILE_ZOT CACHE) + unset(FOO_TEST_PATH_FOO CACHE) + unset(FOO_TEST_PATH_ZOT CACHE) + unset(FOO_TEST_PROG_FOO CACHE) +endmacro() + +RunTestCase() + +set(FOO_ROOT ${PackageRoot_BASE}/foo/cmake_root) +set(ENV{FOO_ROOT} ${PackageRoot_BASE}/foo/env_root) +if(RunCMake_TEST MATCHES "CaseSensitive") + if(RunCMake_TEST STREQUAL "CMP0144-WARN-CaseSensitive-Mixed") + set(Foo_ROOT "${FOO_ROOT}") + set(ENV{Foo_ROOT} "$ENV{FOO_ROOT}") + else() + set(Foo_ROOT ${PackageRoot_BASE}/does_not_exist) + set(ENV{Foo_ROOT} ${PackageRoot_BASE}/does_not_exist) + endif() +endif() +RunTestCase() + +set(FOO_ROOT ${PackageRoot_BASE}/foo/cmake_root) +if(RunCMake_TEST MATCHES "CaseSensitive") + if(RunCMake_TEST STREQUAL "CMP0144-WARN-CaseSensitive-Mixed") + set(Foo_ROOT "${FOO_ROOT}") + else() + set(Foo_ROOT ${PackageRoot_BASE}/does_not_exist) + endif() +endif() +RunTestCase() + +set(ENV{FOO_ROOT} ${PackageRoot_BASE}/foo/env_root) +if(RunCMake_TEST MATCHES "CaseSensitive") + if(RunCMake_TEST STREQUAL "CMP0144-WARN-CaseSensitive-Mixed") + set(ENV{Foo_ROOT} "$ENV{FOO_ROOT}") + else() + set(ENV{Foo_ROOT} ${PackageRoot_BASE}/does_not_exist) + endif() +endif() +RunTestCase() + +message("----------") diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index fa41fc1..e7e3a0b 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -55,6 +55,17 @@ run_cmake(REGISTRY_VIEW-no-view) run_cmake(REGISTRY_VIEW-wrong-view) run_cmake(REGISTRY_VIEW-propagated) +if(CMAKE_HOST_WIN32) + run_cmake(CMP0144-WARN-CaseInsensitive) + run_cmake(CMP0144-OLD-CaseInsensitive) + run_cmake(CMP0144-NEW-CaseInsensitive) +else() + run_cmake(CMP0144-WARN-CaseSensitive) + run_cmake(CMP0144-WARN-CaseSensitive-Mixed) + run_cmake(CMP0144-OLD-CaseSensitive) + run_cmake(CMP0144-NEW-CaseSensitive) +endif() + file( GLOB SearchPaths_TEST_CASE_LIST LIST_DIRECTORIES TRUE |