Browse Source

Merge branch 'find_package-restore-considered-configs' into release-3.9

Brad King 8 years ago
parent
commit
916b7d5195

+ 2 - 1
Source/cmFindPackageCommand.cxx

@@ -739,7 +739,8 @@ bool cmFindPackageCommand::HandlePackageMode()
   if (result && !found) {
   if (result && !found) {
     // warn if package required or neither quiet nor in config mode
     // warn if package required or neither quiet nor in config mode
     if (this->Required ||
     if (this->Required ||
-        !(this->Quiet || (this->UseConfigFiles && !this->UseFindModules))) {
+        !(this->Quiet || (this->UseConfigFiles && !this->UseFindModules &&
+                          this->ConsideredConfigs.empty()))) {
       // The variable is not set.
       // The variable is not set.
       std::ostringstream e;
       std::ostringstream e;
       std::ostringstream aw;
       std::ostringstream aw;

+ 2 - 0
Tests/RunCMake/find_package/RunCMakeTest.cmake

@@ -17,3 +17,5 @@ run_cmake(PackageRoot)
 run_cmake(PolicyPush)
 run_cmake(PolicyPush)
 run_cmake(PolicyPop)
 run_cmake(PolicyPop)
 run_cmake(SetFoundFALSE)
 run_cmake(SetFoundFALSE)
+run_cmake(WrongVersion)
+run_cmake(WrongVersionConfig)

+ 9 - 0
Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt

@@ -0,0 +1,9 @@
+CMake Warning at SetFoundFALSE.cmake:2 \(find_package\):
+  Found package configuration file:
+
+    .*/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake
+
+  but it set SetFoundFALSE_FOUND to FALSE so package "SetFoundFALSE" is
+  considered to be NOT FOUND.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)

+ 0 - 1
Tests/RunCMake/find_package/SetFoundFALSE-stdout.txt

@@ -1 +0,0 @@
--- Could NOT find SetFoundFALSE \(missing: SetFoundFALSE_DIR\)

+ 0 - 0
Tests/RunCMake/find_package/VersionedA-1/VersionedAConfig.cmake


+ 4 - 0
Tests/RunCMake/find_package/VersionedA-1/VersionedAConfigVersion.cmake

@@ -0,0 +1,4 @@
+set(PACKAGE_VERSION 1)
+if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1)
+  set(PACKAGE_VERSION_COMPATIBLE 1)
+endif()

+ 0 - 0
Tests/RunCMake/find_package/VersionedA-2/VersionedAConfig.cmake


+ 4 - 0
Tests/RunCMake/find_package/VersionedA-2/VersionedAConfigVersion.cmake

@@ -0,0 +1,4 @@
+set(PACKAGE_VERSION 2)
+if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 2)
+  set(PACKAGE_VERSION_COMPATIBLE 1)
+endif()

+ 11 - 0
Tests/RunCMake/find_package/WrongVersion-stderr.txt

@@ -0,0 +1,11 @@
+^CMake Warning at WrongVersion.cmake:[0-9]+ \(find_package\):
+  Could not find a configuration file for package "VersionedA" that is
+  compatible with requested version "3".
+
+  The following configuration files were considered but not accepted:
+
+    .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig.cmake, version: [12]
+    .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig.cmake, version: [12]
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$

+ 2 - 0
Tests/RunCMake/find_package/WrongVersion.cmake

@@ -0,0 +1,2 @@
+set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+find_package(VersionedA 3)

+ 11 - 0
Tests/RunCMake/find_package/WrongVersionConfig-stderr.txt

@@ -0,0 +1,11 @@
+^CMake Warning at WrongVersionConfig.cmake:[0-9]+ \(find_package\):
+  Could not find a configuration file for package "VersionedA" that is
+  compatible with requested version "3".
+
+  The following configuration files were considered but not accepted:
+
+    .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig.cmake, version: [12]
+    .*/Tests/RunCMake/find_package/VersionedA-[12]/VersionedAConfig.cmake, version: [12]
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$

+ 2 - 0
Tests/RunCMake/find_package/WrongVersionConfig.cmake

@@ -0,0 +1,2 @@
+set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+find_package(VersionedA 3)