[Cmake-commits] CMake branch, next, updated. v2.8.11.2-4023-ga13d3b8

Stephen Kelly steveire at gmail.com
Wed Aug 28 04:39:04 EDT 2013


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  a13d3b82a69f325413fc859caa8b4e59d9bd4fb6 (commit)
       via  0ddfd4d4eceb25e55153ba9d55820530cc938c3a (commit)
      from  88e94650dc5781d842fef548d5d0feb5a7fccb45 (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=a13d3b82a69f325413fc859caa8b4e59d9bd4fb6
commit a13d3b82a69f325413fc859caa8b4e59d9bd4fb6
Merge: 88e9465 0ddfd4d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Aug 28 04:38:57 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Aug 28 04:38:57 2013 -0400

    Merge topic 'export-policy' into next
    
    0ddfd4d Disallow include() of the result of export()


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ddfd4d4eceb25e55153ba9d55820530cc938c3a
commit 0ddfd4d4eceb25e55153ba9d55820530cc938c3a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Jun 18 16:33:33 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Aug 28 10:31:05 2013 +0200

    Disallow include() of the result of export()
    
    Currently, export() is executed at configure-time.
    
    One problem with this is that certain exported properties like
    the link interface may not be complete at the point the export() is
    encountered leading to an incorrect or incomplete exported
    representation. Additionally, the generated IMPORTED_LOCATION
    property may even be incorrect if commands following the export()
    have an effect on it.
    
    Another problem is that it requires the C++ implementation of cmake
    to be capable of computing the exported information at configure time.
    This is a limitation on the cleanup and maintenance of the code. At
    some point in the future, this limitation will be dropped and more
    implementation will be moved from cmTarget to cmGeneratorTarget.

diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index f059ceb..4558fb6 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -170,6 +170,8 @@ bool cmExportCommand
   ebfg.SetCommand(this);
   ebfg.SetExportOld(this->ExportOld.IsEnabled());
 
+  this->Makefile->AddExportedTargetsFile(fname);
+
   // Compute the set of configurations exported.
   std::vector<std::string> configurationTypes;
   this->Makefile->GetConfigurations(configurationTypes);
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index bb891d6..a3d8b83 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -88,6 +88,45 @@ bool cmIncludeCommand
       fname = mfile.c_str();
       }
     }
+
+  std::string fname_abs =
+      cmSystemTools::CollapseFullPath(fname.c_str(),
+                                      this->Makefile->GetStartDirectory());
+
+  if (this->Makefile->IsExportedTargetsFile(fname_abs))
+    {
+    const char *modal = 0;
+    cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+
+    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024))
+      {
+      case cmPolicies::WARN:
+        modal = "should";
+      case cmPolicies::OLD:
+        break;
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::REQUIRED_ALWAYS:
+      case cmPolicies::NEW:
+        modal = "may";
+        messageType = cmake::FATAL_ERROR;
+      }
+    if (modal)
+      {
+      cmOStringStream e;
+      e << (this->Makefile->GetPolicies()
+            ->GetPolicyWarning(cmPolicies::CMP0024)) << "\n";
+      e << "The file\n  " << fname_abs << "\nwas generated by the export() "
+        "command.  It " << modal << " not be used as the argument to the "
+        "include() command.  Use ALIAS targets instead to refer to targets "
+        "by alternative names.\n";
+      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      if (messageType == cmake::FATAL_ERROR)
+        {
+        return false;
+        }
+      }
+    }
+
   std::string fullFilePath;
   bool readit =
     this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 8bce9fd..362b066 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -489,6 +489,18 @@ public:
       return this->cmCurrentListFile.c_str();
     }
 
+  void AddExportedTargetsFile(const std::string &filename)
+  {
+    this->ExportedTargetsFiles.insert(filename);
+  }
+
+  bool IsExportedTargetsFile(const std::string &filename) const
+  {
+    const std::set<std::string>::const_iterator it
+                                  = this->ExportedTargetsFiles.find(filename);
+    return it != this->ExportedTargetsFiles.end();
+  }
+
   //@}
 
   /**
@@ -1041,7 +1053,7 @@ private:
   void EnforceDirectoryLevelRules();
 
   bool GeneratingBuildSystem;
-
+  std::set<std::string> ExportedTargetsFiles;
   /**
    * Old version of GetSourceFileWithOutput(const char*) kept for
    * backward-compatibility. It implements a linear search and support
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index a823f05..3f7eb61 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -601,6 +601,20 @@ cmPolicies::cmPolicies()
     "The NEW behavior for this policy is to not to allow mixing of the "
     "keyword and plain signatures.",
     2,8,12,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0024, "CMP0024",
+    "Disallow include export result.",
+    "CMake 2.8.12 and lower allowed use of the include() command with the "
+    "result of the export() command.  This relies on the assumption that "
+    "the export() command has an immediate effect at configure-time during a "
+    "cmake run.  Certain properties of targets are not fully determined "
+    "until later at generate-time, such as the link language and complete "
+    "list of link libraries.  Future refactoring will change the effect of "
+    "the export() command to be executed at generate-time.  Use ALIAS "
+    "targets instead in cases where the goal is to refer to targets by "
+    "another name",
+    2,8,13,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 5b843a9..bafe5b2 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -74,6 +74,7 @@ public:
     /// target property
     CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
     CMP0023, ///< Disallow mixing keyword and plain tll signatures
+    CMP0024, ///< Disallow including export() result.
 
     /** \brief Always the last entry.
      *
diff --git a/Tests/RunCMake/include/CMP0024-NEW-result.txt b/Tests/RunCMake/include/CMP0024-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include/CMP0024-NEW-stderr.txt b/Tests/RunCMake/include/CMP0024-NEW-stderr.txt
new file mode 100644
index 0000000..182c67a
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-NEW-stderr.txt
@@ -0,0 +1,15 @@
+CMake Error at CMP0024-NEW.cmake:9 \(include\):
+  Policy CMP0024 is not set: Disallow include export result.  Run "cmake
+  --help-policy CMP0024" for policy details.  Use the cmake_policy command to
+  set the policy and suppress this warning.
+
+  The file
+
+    .*/Tests/RunCMake/include/CMP0024-NEW-build/theTargets.cmake
+
+  was generated by the export\(\) command.  It may not be used as the argument
+  to the include\(\) command.  Use ALIAS targets instead to refer to targets by
+  alternative names.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/include/CMP0024-NEW.cmake b/Tests/RunCMake/include/CMP0024-NEW.cmake
new file mode 100644
index 0000000..0685d6c
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-NEW.cmake
@@ -0,0 +1,9 @@
+
+enable_language(CXX)
+
+cmake_policy(SET CMP0024 NEW)
+
+add_library(foo SHARED empty.cpp)
+
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
+include("${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
diff --git a/Tests/RunCMake/include/CMP0024-WARN-result.txt b/Tests/RunCMake/include/CMP0024-WARN-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-WARN-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include/CMP0024-WARN-stderr.txt b/Tests/RunCMake/include/CMP0024-WARN-stderr.txt
new file mode 100644
index 0000000..2b36f17
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-WARN-stderr.txt
@@ -0,0 +1,16 @@
+CMake Warning \(dev\) at CMP0024-WARN.cmake:7 \(include\):
+  Policy CMP0024 is not set: Disallow include export result.  Run "cmake
+  --help-policy CMP0024" for policy details.  Use the cmake_policy command to
+  set the policy and suppress this warning.
+
+  The file
+
+    .*/Tests/RunCMake/include/CMP0024-WARN-build/theTargets.cmake
+
+  was generated by the export\(\) command.  It should not be used as the
+  argument to the include\(\) command.  Use ALIAS targets instead to refer to
+  targets by alternative names.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/include/CMP0024-WARN.cmake b/Tests/RunCMake/include/CMP0024-WARN.cmake
new file mode 100644
index 0000000..583c7d4
--- /dev/null
+++ b/Tests/RunCMake/include/CMP0024-WARN.cmake
@@ -0,0 +1,7 @@
+
+enable_language(CXX)
+
+add_library(foo SHARED empty.cpp)
+
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
+include("${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
diff --git a/Tests/RunCMake/include/RunCMakeTest.cmake b/Tests/RunCMake/include/RunCMakeTest.cmake
index 59b87ca..7fc9a12 100644
--- a/Tests/RunCMake/include/RunCMakeTest.cmake
+++ b/Tests/RunCMake/include/RunCMakeTest.cmake
@@ -2,3 +2,5 @@ include(RunCMake)
 
 run_cmake(EmptyString)
 run_cmake(EmptyStringOptional)
+run_cmake(CMP0024-WARN)
+run_cmake(CMP0024-NEW)
diff --git a/Tests/RunCMake/include/empty.cpp b/Tests/RunCMake/include/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/include/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}

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

Summary of changes:
 Source/cmExportCommand.cxx                         |    2 +
 Source/cmIncludeCommand.cxx                        |   39 ++++++++++++++++++++
 Source/cmMakefile.h                                |   14 +++++++-
 Source/cmPolicies.cxx                              |   14 +++++++
 Source/cmPolicies.h                                |    1 +
 .../CMP0024-NEW-result.txt}                        |    0
 Tests/RunCMake/include/CMP0024-NEW-stderr.txt      |   15 ++++++++
 Tests/RunCMake/include/CMP0024-NEW.cmake           |    9 +++++
 .../CMP0024-WARN-result.txt}                       |    0
 Tests/RunCMake/include/CMP0024-WARN-stderr.txt     |   16 ++++++++
 Tests/RunCMake/include/CMP0024-WARN.cmake          |    7 ++++
 Tests/RunCMake/include/RunCMakeTest.cmake          |    2 +
 Tests/RunCMake/{CMP0022 => include}/empty.cpp      |    0
 13 files changed, 118 insertions(+), 1 deletions(-)
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => include/CMP0024-NEW-result.txt} (100%)
 create mode 100644 Tests/RunCMake/include/CMP0024-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/include/CMP0024-NEW.cmake
 copy Tests/RunCMake/{CMP0022/CMP0022-WARN-static-result.txt => include/CMP0024-WARN-result.txt} (100%)
 create mode 100644 Tests/RunCMake/include/CMP0024-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/include/CMP0024-WARN.cmake
 copy Tests/RunCMake/{CMP0022 => include}/empty.cpp (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list