[Cmake-commits] CMake branch, next, updated. v2.8.7-3192-gf524357

Alexander Neundorf neundorf at kde.org
Sun Mar 18 06:53:32 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  f5243578b93208ede6243223e2ae800196976a66 (commit)
       via  0cf84472d7bf7c62b4f7db5052765cb88ec29eef (commit)
       via  56ae3f94129aebd03af6778895a322a86dc9db77 (commit)
       via  16c0c7376c4ab26a4f0ec667f5888ba746a0617e (commit)
      from  61e71612d6e39d3366a0a08ae0fd0da82a000339 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f5243578b93208ede6243223e2ae800196976a66
commit f5243578b93208ede6243223e2ae800196976a66
Merge: 61e7161 0cf8447
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Sun Mar 18 06:53:26 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Mar 18 06:53:26 2012 -0400

    Merge topic 'find_package_set_FOUND_VariableInConfigFile' into next
    
    0cf8447 find_package: additional test for checking the error message
    56ae3f9 find_package: add test for setting Foo_FOUND to FALSE in a Config file
    16c0c73 find_package: allow <pkg>Config.cmake to set <pkg>_FOUND to FALSE


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cf84472d7bf7c62b4f7db5052765cb88ec29eef
commit 0cf84472d7bf7c62b4f7db5052765cb88ec29eef
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Mar 13 21:19:56 2012 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 13 16:56:52 2012 -0400

    find_package: additional test for checking the error message
    
    This patch adds a test which checks the error message, which is
    produced in the case that a Config file has set Foo_FOUND to FALSE
    by itself.
    
    Alex

diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index ba57f99..34fa733 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -12,3 +12,4 @@ run_cmake(MissingConfigOneName)
 run_cmake(MissingConfigRequired)
 run_cmake(MissingConfigVersion)
 run_cmake(MixedModeOptions)
+run_cmake(SetFoundFALSE)
diff --git a/Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt b/Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt
new file mode 100644
index 0000000..695f645
--- /dev/null
+++ b/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\)
diff --git a/Tests/RunCMake/find_package/SetFoundFALSE.cmake b/Tests/RunCMake/find_package/SetFoundFALSE.cmake
new file mode 100644
index 0000000..fbcec3c
--- /dev/null
+++ b/Tests/RunCMake/find_package/SetFoundFALSE.cmake
@@ -0,0 +1,2 @@
+set(SetFoundFALSE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+find_package(SetFoundFALSE CONFIG)
diff --git a/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake b/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake
new file mode 100644
index 0000000..ae6bd14
--- /dev/null
+++ b/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake
@@ -0,0 +1 @@
+set(SetFoundFALSE_FOUND FALSE)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56ae3f94129aebd03af6778895a322a86dc9db77
commit 56ae3f94129aebd03af6778895a322a86dc9db77
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sat Mar 10 12:18:58 2012 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 13 16:56:52 2012 -0400

    find_package: add test for setting Foo_FOUND to FALSE in a Config file
    
    Alex

diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index 73f24e0..eba9db9 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -82,6 +82,7 @@ SET(PACKAGES
   RecursiveA RecursiveB RecursiveC
   ArchA ArchB ArchC ArchD
   EnvA EnvB
+  SetFoundTRUE SetFoundFALSE
   ${CMakeTestSystemPackage}
   )
 FOREACH(p ${PACKAGES})
@@ -117,6 +118,10 @@ FIND_PACKAGE(VersionedC 4.0 EXACT NAMES zot)
 FIND_PACKAGE(VersionedD 1.1 EXACT NAMES Baz)
 FIND_PACKAGE(VersionedE 1.2 EXACT NAMES Baz)
 
+# Test Config files which set Xyz_FOUND themselves:
+FIND_PACKAGE(SetFoundTRUE NO_MODULE)
+FIND_PACKAGE(SetFoundFALSE NO_MODULE)
+
 # Test wrong initial path when result is present.
 SET(WrongA_DIR "${VersionedD_DIR}")
 FIND_PACKAGE(WrongA 1.2 EXACT NAMES Baz)
@@ -201,6 +206,8 @@ SET(ArchC_EXPECTED "lib/arch/zot-3.1/zot-config.cmake")
 SET(ArchD_EXPECTED "lib/arch/cmake/zot-4.0/zot-config.cmake")
 SET(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake")
 SET(EnvB_MISSING "EnvB_DIR-NOTFOUND")
+SET(SetFoundTRUE_EXPECTED "cmake/SetFoundTRUEConfig.cmake")
+SET(SetFoundFALSE_MISSING "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 SET(CMakeTestSystemPackage_EXPECTED "SystemPackage/CMakeTestSystemPackageConfig.cmake")
 
 # Check the results.
@@ -212,6 +219,11 @@ FOREACH(p ${PACKAGES})
         "Package ${p} should have been [${${p}_MISSING}] but "
         "was [${${p}_DIR}]")
     ENDIF()
+    IF(${p}_FOUND)
+      MESSAGE(SEND_ERROR
+        "Package ${p} should not have been found, but ${p}_FOUND is set to "
+        "\"${${p}_FOUND}\"")
+    ENDIF()
   ELSEIF(${p}_FOUND)
     # Convert to relative path for comparison to expected location.
     FILE(RELATIVE_PATH REL_${p}_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}"
diff --git a/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake
new file mode 100644
index 0000000..ae6bd14
--- /dev/null
+++ b/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake
@@ -0,0 +1 @@
+set(SetFoundFALSE_FOUND FALSE)
diff --git a/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake
new file mode 100644
index 0000000..19d0711
--- /dev/null
+++ b/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake
@@ -0,0 +1 @@
+set(SetFoundTRUE_FOUND TRUE)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=16c0c7376c4ab26a4f0ec667f5888ba746a0617e
commit 16c0c7376c4ab26a4f0ec667f5888ba746a0617e
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sat Mar 10 11:21:05 2012 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 13 16:56:23 2012 -0400

    find_package: allow <pkg>Config.cmake to set <pkg>_FOUND to FALSE
    
    Before, find_package in Config mode always set Foo_FOUND to true if the
    Config file has been found and could be executed.
    If the Config file itself detected some problem, like a missing dependency,
    it did not have a way to signal to the outside that the package is not working.
    With this patch, if a Config file sets Foo_FOUND to FALSE, this is taken into
    account and not overridden.
    
    Alex

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index f17002e..3541ca3 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -952,11 +952,26 @@ bool cmFindPackageCommand::HandlePackageMode()
       }
     }
 
+  std::string foundVar = this->Name;
+  foundVar += "_FOUND";
+
   // If the directory for the config file was found, try to read the file.
   bool result = true;
   bool found = false;
+  bool configFileSetFOUNDFalse = false;
+
   if(fileFound)
     {
+    if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
+      && (this->Makefile->IsOn(foundVar.c_str()) == false))
+      {
+      // by removing Foo_FOUND here if it is FALSE, we don't really change
+      // the situation for the Config file which is about to be included,
+      // but we make it possible to detect later on whether the Config file
+      // has set Foo_FOUND to FALSE itself:
+      this->Makefile->RemoveDefinition(foundVar.c_str());
+      }
+
     // Set the version variables before loading the config file.
     // It may override them.
     this->StoreVersionFound();
@@ -966,6 +981,15 @@ bool cmFindPackageCommand::HandlePackageMode()
       {
       // The package has been found.
       found = true;
+
+      // Check whether the Config file has set Foo_FOUND to FALSE:
+      if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
+           && (this->Makefile->IsOn(foundVar.c_str()) == false))
+        {
+        // we get here if the Config file has set Foo_FOUND actively to FALSE
+        found = false;
+        configFileSetFOUNDFalse = true;
+        }
       }
     else
       {
@@ -973,14 +997,22 @@ bool cmFindPackageCommand::HandlePackageMode()
       result = false;
       }
     }
-  else if(!this->Quiet || this->Required)
+
+  if (result && !found && (!this->Quiet || this->Required))
     {
     // The variable is not set.
     cmOStringStream e;
     cmOStringStream aw;
+    if (configFileSetFOUNDFalse)
+      {
+      e << "Found package configuration file:\n"
+        "  " << this->FileFound << "\n"
+        "but it set " << foundVar << " to FALSE so package \"" <<
+        this->Name << "\" is considered to be NOT FOUND.";
+      }
     // If there are files in ConsideredConfigs, it means that FooConfig.cmake
     // have been found, but they didn't have appropriate versions.
-    if (this->ConsideredConfigs.size() > 0)
+    else if (this->ConsideredConfigs.size() > 0)
       {
       e << "Could not find a configuration file for package \""
         << this->Name << "\" that "
@@ -1074,8 +1106,6 @@ bool cmFindPackageCommand::HandlePackageMode()
     }
 
   // Set a variable marking whether the package was found.
-  std::string foundVar = this->Name;
-  foundVar += "_FOUND";
   this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0");
 
   // Set a variable naming the configuration file that was found.

-----------------------------------------------------------------------

Summary of changes:
 Source/cmFindPackageCommand.cxx                    |   38 +++++++++++++++++--
 Tests/FindPackageTest/CMakeLists.txt               |   12 ++++++
 .../cmake/SetFoundFALSEConfig.cmake                |    1 +
 .../FindPackageTest/cmake/SetFoundTRUEConfig.cmake |    1 +
 Tests/RunCMake/find_package/RunCMakeTest.cmake     |    1 +
 .../RunCMake/find_package/SetFoundFALSE-stderr.txt |    9 +++++
 Tests/RunCMake/find_package/SetFoundFALSE.cmake    |    2 +
 .../find_package/SetFoundFALSEConfig.cmake         |    1 +
 8 files changed, 61 insertions(+), 4 deletions(-)
 create mode 100644 Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake
 create mode 100644 Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake
 create mode 100644 Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt
 create mode 100644 Tests/RunCMake/find_package/SetFoundFALSE.cmake
 create mode 100644 Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list