diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 59f9537ff2..a84b3e9518 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1789,7 +1789,8 @@ bool cmFindPackageCommand::HandlePackageMode( for (ConfigFileInfo const& info : cmMakeRange(this->ConsideredConfigs.cbegin(), duplicate_end)) { - e << " " << info.filename << ", version: " << info.version << '\n'; + e << " " << info.filename << ", version: " << info.version + << "\n " << info.message << '\n'; } } else { std::string requestedVersionString; @@ -2927,9 +2928,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir, foundMode = cmFindPackageCommand::FoundMode(config.Type); return true; } - this->ConsideredPaths.emplace_back(file, - cmFindPackageCommand::FoundMode(type), - SearchResult::InsufficientVersion); + this->ConsideredPaths.emplace_back( + file, cmFindPackageCommand::FoundMode(type), + this->ConsideredConfigs.back().result, + this->ConsideredConfigs.back().message); } else { this->ConsideredPaths.emplace_back( file, cmFindPackageCommand::FoundMode(type), SearchResult::NoExist); @@ -2943,6 +2945,8 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) bool result = false; // by default, assume the version is not ok. bool haveResult = false; std::string version = "unknown"; + std::string message; + SearchResult reason = SearchResult::InsufficientVersion; // Get the file extension. std::string::size_type pos = config_file.rfind('.'); @@ -2997,6 +3001,14 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) this->VersionMax, version); } } + + if (!result) { + message = + cmStrCat("Version \""_s, version, + "\" (compatibility version \""_s, *compatVersion, + "\") is not compatible " + "with the version requested."_s); + } } else { // If no, compat_version is assumed to be exactly the actual // version, so the result is whether the requested version is @@ -3007,6 +3019,12 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) } } } + + if (!result && message.empty()) { + message = + cmStrCat("Version \""_s, version, + "\" is not compatible with the version requested."_s); + } } if (result) { @@ -3037,7 +3055,13 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) allComponents.end(), std::back_inserter(missingComponents)); if (!missingComponents.empty()) { + bool const single = (missingComponents.size() == 1); result = false; + message = + cmStrCat((single ? "Required component was not found: "_s + : "Required components were not found: "_s), + cmJoin(missingComponents, ", "_s), '.'); + reason = SearchResult::InsufficientComponents; } if (result && hasVersion) { @@ -3073,6 +3097,14 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) this->CpsAppendices = std::move(appendices); this->RequiredComponents = std::move(requiredComponents); } + } else if (reader) { + message = + cmStrCat("The file describes the package \""_s, reader->GetName(), + "\", which is not the requested package."_s); + reason = SearchResult::Ignored; + } else { + message = "The package description file could not be read."; + reason = SearchResult::Error; } } else { // Get the filename without the .cmake extension. @@ -3092,15 +3124,26 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) haveResult = true; } + if (haveResult && !result) { + message = + "The version found is not compatible with the version requested."; + } + // If no version was requested a versionless package is acceptable. if (!haveResult && this->Version.empty()) { result = true; } } + if (result) { + reason = SearchResult::Acceptable; + } + ConfigFileInfo configFileInfo; configFileInfo.filename = config_file; configFileInfo.version = version; + configFileInfo.message = message; + configFileInfo.result = reason; this->ConsideredConfigs.push_back(std::move(configFileInfo)); return result; @@ -3738,8 +3781,14 @@ void cmFindPackageDebugState::WriteEvent(cmConfigureLog& log, auto search_result = [](cmFindPackageCommand::SearchResult type) -> std::string { switch (type) { + case cmFindPackageCommand::SearchResult::Acceptable: + return "acceptable"; case cmFindPackageCommand::SearchResult::InsufficientVersion: return "insufficient_version"; + case cmFindPackageCommand::SearchResult::InsufficientComponents: + return "insufficient_components"; + case cmFindPackageCommand::SearchResult::Error: + return "error"; case cmFindPackageCommand::SearchResult::NoExist: return "no_exist"; case cmFindPackageCommand::SearchResult::Ignored: diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index ff8ff27f93..ab083848e5 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -291,7 +291,10 @@ private: enum class SearchResult { + Acceptable, InsufficientVersion, + InsufficientComponents, + Error, NoExist, Ignored, NoConfigFile, @@ -300,10 +303,11 @@ private: struct ConsideredPath { ConsideredPath(std::string path, FoundPackageMode mode, - SearchResult reason) + SearchResult result, std::string message = {}) : Path(std::move(path)) , Mode(mode) - , Reason(reason) + , Reason(result) + , Message(std::move(message)) { } @@ -347,6 +351,8 @@ private: { std::string filename; std::string version; + std::string message; + SearchResult result; bool operator<(ConfigFileInfo const& rhs) const { diff --git a/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt b/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt index a72795f923..a0b10fd06d 100644 --- a/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt +++ b/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt @@ -5,6 +5,7 @@ CMake Error at .*/Modules/CMakeFindDependencyMacro\.cmake:[0-9]+ \(find_package\ The following configuration files were considered but not accepted: .*/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config\.cmake, version: 1\.3 + The version found is not compatible with the version requested\. Call Stack \(most recent call first\): [^ diff --git a/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt b/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt index 73f69464af..30048917f9 100644 --- a/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt +++ b/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt @@ -5,6 +5,7 @@ CMake Error at .*/Modules/CMakeFindDependencyMacro\.cmake:[0-9]+ \(find_package\ The following configuration files were considered but not accepted: .*/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config\.cmake, version: 1\.3 + The version found is not compatible with the version requested\. Call Stack \(most recent call first\): [^ diff --git a/Tests/RunCMake/find_package-CPS/BadPrefix-result.txt b/Tests/RunCMake/find_package-CPS/BadPrefix-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/BadPrefix-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package-CPS/BadPrefix-stderr.txt b/Tests/RunCMake/find_package-CPS/BadPrefix-stderr.txt new file mode 100644 index 0000000000..bec724e6bb --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/BadPrefix-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadPrefix\.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "BadPrefix" that is + compatible with requested version ""\. + + The following configuration files were considered but not accepted: +( + [^ +]*/Tests/RunCMake/find_package-CPS/cps/[Bb]ad[Pp]refix\.cps, version: unknown + The package description file could not be read\.)+ + +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/BadPrefix.cmake b/Tests/RunCMake/find_package-CPS/BadPrefix.cmake new file mode 100644 index 0000000000..483bbaca31 --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/BadPrefix.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 4.0) + +include(Setup.cmake) + +set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) + +############################################################################### +# Test reporting when trying to read a .cps whose absolute prefix cannot be +# determined. +find_package(BadPrefix REQUIRED) diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps1-result.txt b/Tests/RunCMake/find_package-CPS/InvalidCps1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps1-stderr.txt b/Tests/RunCMake/find_package-CPS/InvalidCps1-stderr.txt new file mode 100644 index 0000000000..c5c03618b7 --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps1-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at InvalidCps1\.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "Empty" that is compatible + with requested version ""\. + + The following configuration files were considered but not accepted: +( + [^ +]*/Tests/RunCMake/find_package-CPS/cps/[Ee]mpty\.cps, version: unknown + The package description file could not be read\.)+ + +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps1.cmake b/Tests/RunCMake/find_package-CPS/InvalidCps1.cmake new file mode 100644 index 0000000000..ba15b6fbb9 --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps1.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 4.0) + +include(Setup.cmake) + +set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) + +############################################################################### +# Test reporting when trying to read a .cps that is not valid JSON. +find_package(Empty REQUIRED) diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps2-result.txt b/Tests/RunCMake/find_package-CPS/InvalidCps2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps2-stderr.txt b/Tests/RunCMake/find_package-CPS/InvalidCps2-stderr.txt new file mode 100644 index 0000000000..e85651e854 --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps2-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at InvalidCps2\.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "NotAnObject" that is + compatible with requested version ""\. + + The following configuration files were considered but not accepted: +( + [^ +]*/Tests/RunCMake/find_package-CPS/cps/[Nn]ot[Aa]n[Oo]bject\.cps, version: unknown + The package description file could not be read\.)+ + +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/InvalidCps2.cmake b/Tests/RunCMake/find_package-CPS/InvalidCps2.cmake new file mode 100644 index 0000000000..c78c2a3e1c --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/InvalidCps2.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 4.0) + +include(Setup.cmake) + +set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) + +############################################################################### +# Test reporting when trying to read a .cps that is not a JSON object. +find_package(NotAnObject REQUIRED) diff --git a/Tests/RunCMake/find_package-CPS/MissingComponent-stderr.txt b/Tests/RunCMake/find_package-CPS/MissingComponent-stderr.txt index 2813b93fcd..bf160fa582 100644 --- a/Tests/RunCMake/find_package-CPS/MissingComponent-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/MissingComponent-stderr.txt @@ -5,7 +5,8 @@ CMake Error at MissingComponent\.cmake:[0-9]+ \(find_package\): The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/[Cc]omponent[Tt]est\.cps, version: 1\.0)+ +]*/Tests/RunCMake/find_package-CPS/cps/[Cc]omponent[Tt]est\.cps, version: 1\.0 + Required component was not found: DoesNotExist\.)+ Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package-CPS/MissingTransitiveComponentCPS-stderr.txt b/Tests/RunCMake/find_package-CPS/MissingTransitiveComponentCPS-stderr.txt index 1a2b9e8485..b4109e3dd4 100644 --- a/Tests/RunCMake/find_package-CPS/MissingTransitiveComponentCPS-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/MissingTransitiveComponentCPS-stderr.txt @@ -5,7 +5,8 @@ CMake Error in cps/[Tt]ransitive[Mm]issing[Cc][Pp][Ss]\.cps: The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/[Cc]omponent[Tt]est\.cps, version: 1\.0)+ +]*/Tests/RunCMake/find_package-CPS/cps/[Cc]omponent[Tt]est\.cps, version: 1\.0 + Required component was not found: DoesNotExist\.)+ Call Stack \(most recent call first\): MissingTransitiveComponentCPS\.cmake:[0-9]+ \(find_package\) diff --git a/Tests/RunCMake/find_package-CPS/MissingVersion1-stderr.txt b/Tests/RunCMake/find_package-CPS/MissingVersion1-stderr.txt index b3bfd9bde2..031851a459 100644 --- a/Tests/RunCMake/find_package-CPS/MissingVersion1-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/MissingVersion1-stderr.txt @@ -5,13 +5,17 @@ CMake Error at MissingVersion1\.cmake:[0-9]+ \(find_package\): The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven + Version "1\.5\.0\+niven" is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams + Version "1\.4\.2\+adams" \(compatibility version "1\.3\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke + Version "1\.2\.3\+clarke" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov)+ +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov + Version "1\.1\.0\+asimov" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+ Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/MissingVersion2-stderr.txt b/Tests/RunCMake/find_package-CPS/MissingVersion2-stderr.txt index cdb3a8d406..0af72130c9 100644 --- a/Tests/RunCMake/find_package-CPS/MissingVersion2-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/MissingVersion2-stderr.txt @@ -5,13 +5,17 @@ CMake Error at MissingVersion2\.cmake:[0-9]+ \(find_package\): The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven + Version "1\.5\.0\+niven" is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams + Version "1\.4\.2\+adams" \(compatibility version "1\.3\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke + Version "1\.2\.3\+clarke" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov)+ +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov + Version "1\.1\.0\+asimov" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+ Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/RunCMakeTest.cmake b/Tests/RunCMake/find_package-CPS/RunCMakeTest.cmake index b6749f7b19..f03b959d93 100644 --- a/Tests/RunCMake/find_package-CPS/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package-CPS/RunCMakeTest.cmake @@ -29,6 +29,12 @@ function(run_cmake_build test) endfunction() +# General failure tests +run_cmake(InvalidCps1) +run_cmake(InvalidCps2) +run_cmake(WrongName) +run_cmake(BadPrefix) + # Version-matching tests run_cmake(ExactVersion) run_cmake(CompatVersion) diff --git a/Tests/RunCMake/find_package-CPS/VersionLimit3-stderr.txt b/Tests/RunCMake/find_package-CPS/VersionLimit3-stderr.txt index e11db59f93..9c7c0b8beb 100644 --- a/Tests/RunCMake/find_package-CPS/VersionLimit3-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/VersionLimit3-stderr.txt @@ -5,13 +5,17 @@ CMake Error at VersionLimit3\.cmake:[0-9]+ \(find_package\): The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven + Version "1\.5\.0\+niven" is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams + Version "1\.4\.2\+adams" \(compatibility version "1\.3\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke + Version "1\.2\.3\+clarke" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov)+ +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov + Version "1\.1\.0\+asimov" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+ Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/VersionLimit4-stderr.txt b/Tests/RunCMake/find_package-CPS/VersionLimit4-stderr.txt index 3ae8004310..eca33f4089 100644 --- a/Tests/RunCMake/find_package-CPS/VersionLimit4-stderr.txt +++ b/Tests/RunCMake/find_package-CPS/VersionLimit4-stderr.txt @@ -5,13 +5,17 @@ CMake Error at VersionLimit4\.cmake:[0-9]+ \(find_package\): The following configuration files were considered but not accepted: ( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.5\.0/[Ss]ample\.cps, version: 1\.5\.0\+niven + Version "1\.5\.0\+niven" is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.4\.2/[Ss]ample\.cps, version: 1\.4\.2\+adams + Version "1\.4\.2\+adams" \(compatibility version "1\.3\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke)+( +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.2\.3/[Ss]ample\.cps, version: 1\.2\.3\+clarke + Version "1\.2\.3\+clarke" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+( [^ -]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov)+ +]*/Tests/RunCMake/find_package-CPS/cps/sample/1\.1\.0/[Ss]ample\.cps, version: 1\.1\.0\+asimov + Version "1\.1\.0\+asimov" \(compatibility version "1\.0\.0"\) is not compatible with the version requested\.)+ Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/WrongName-result.txt b/Tests/RunCMake/find_package-CPS/WrongName-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/WrongName-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package-CPS/WrongName-stderr.txt b/Tests/RunCMake/find_package-CPS/WrongName-stderr.txt new file mode 100644 index 0000000000..eead29ac0a --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/WrongName-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at WrongName\.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "WrongName" that is + compatible with requested version ""\. + + The following configuration files were considered but not accepted: +( + [^ +]*/Tests/RunCMake/find_package-CPS/cps/[Ww]rong[Nn]ame\.cps, version: unknown + The file describes the package "Mismatch", which is not the requested package\.)+ + +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package-CPS/WrongName.cmake b/Tests/RunCMake/find_package-CPS/WrongName.cmake new file mode 100644 index 0000000000..d2e77ef79a --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/WrongName.cmake @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 4.0) + +include(Setup.cmake) + +set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) + +############################################################################### +# Test reporting when trying to read a .cps that is not for the package +# requested. This is somewhat unlikely to occur in practice, since the most +# likely scenario would be searching for e.g. "a-b" and finding an appendix to +# a package named "a". However, we're likely to fail prefix resolution in that +# case, unless the appendix superfluously provides a "prefix" or "cps_path", +# and reject the file before getting as far as the name check. +find_package(WrongName REQUIRED) diff --git a/Tests/RunCMake/find_package-CPS/cps/badprefix.cps b/Tests/RunCMake/find_package-CPS/cps/badprefix.cps new file mode 100644 index 0000000000..54c11c26c5 --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/cps/badprefix.cps @@ -0,0 +1,6 @@ +{ + "cps_version": "0.13", + "name": "BadPrefix", + "cps_path": "@prefix@/share/cps", + "components": {} +} diff --git a/Tests/RunCMake/find_package-CPS/cps/empty.cps b/Tests/RunCMake/find_package-CPS/cps/empty.cps new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/find_package-CPS/cps/notanobject.cps b/Tests/RunCMake/find_package-CPS/cps/notanobject.cps new file mode 100644 index 0000000000..caab3c4bfc --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/cps/notanobject.cps @@ -0,0 +1,4 @@ +[ + "Answer", + 42 +] diff --git a/Tests/RunCMake/find_package-CPS/cps/wrongname.cps b/Tests/RunCMake/find_package-CPS/cps/wrongname.cps new file mode 100644 index 0000000000..c0b6e6314b --- /dev/null +++ b/Tests/RunCMake/find_package-CPS/cps/wrongname.cps @@ -0,0 +1,6 @@ +{ + "cps_version": "0.13", + "name": "Mismatch", + "cps_path": "@prefix@/cps", + "components": {} +} diff --git a/Tests/RunCMake/find_package/ConfigureLog-config.txt b/Tests/RunCMake/find_package/ConfigureLog-config.txt index 007d63b28b..4c39756e47 100644 --- a/Tests/RunCMake/find_package/ConfigureLog-config.txt +++ b/Tests/RunCMake/find_package/ConfigureLog-config.txt @@ -273,6 +273,7 @@ events:( path: "[^"]*/Tests/RunCMake/find_package/ConfigureLog/lib/cmake/VersionCheck-1.5/VersionCheckConfig.cmake" mode: "config" reason: "insufficient_version" + message: "The version found is not compatible with the version requested." - path: "[^"]*/Tests/RunCMake/find_package/ConfigureLog/lib/cmake/VersionCheck-1.5/versioncheck-config.cmake" mode: "config" diff --git a/Tests/RunCMake/find_package/WrongVersion-stderr.txt b/Tests/RunCMake/find_package/WrongVersion-stderr.txt index 88c8fc3a68..2dd59128de 100644 --- a/Tests/RunCMake/find_package/WrongVersion-stderr.txt +++ b/Tests/RunCMake/find_package/WrongVersion-stderr.txt @@ -5,7 +5,9 @@ The following configuration files were considered but not accepted: .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig\.cmake, version: [12] + The version found is not compatible with the version requested\. .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig\.cmake, version: [12] + The version found is not compatible with the version requested\. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/find_package/WrongVersionConfig-stderr.txt b/Tests/RunCMake/find_package/WrongVersionConfig-stderr.txt index 08e7bd62d4..2ef8660b8e 100644 --- a/Tests/RunCMake/find_package/WrongVersionConfig-stderr.txt +++ b/Tests/RunCMake/find_package/WrongVersionConfig-stderr.txt @@ -5,7 +5,9 @@ The following configuration files were considered but not accepted: .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig\.cmake, version: [12] + The version found is not compatible with the version requested\. .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig\.cmake, version: [12] + The version found is not compatible with the version requested\. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$