浏览代码

CMP0024: Store the fact of included export in global generator.

Storing it in the makefile means that the policy does not trigger
when include and export are in differing directories.
Stephen Kelly 12 年之前
父节点
当前提交
af1f698757

+ 3 - 1
Source/cmExportCommand.cxx

@@ -172,7 +172,9 @@ bool cmExportCommand
   ebfg.SetCommand(this);
   ebfg.SetCommand(this);
   ebfg.SetExportOld(this->ExportOld.IsEnabled());
   ebfg.SetExportOld(this->ExportOld.IsEnabled());
 
 
-  this->Makefile->AddExportedTargetsFile(fname);
+  cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
+                                        ->GetGlobalGenerator();
+  gg->AddExportedTargetsFile(fname);
 
 
   // Compute the set of configurations exported.
   // Compute the set of configurations exported.
   std::vector<std::string> configurationTypes;
   std::vector<std::string> configurationTypes;

+ 13 - 0
Source/cmGlobalGenerator.h

@@ -293,6 +293,18 @@ public:
 
 
   void ProcessEvaluationFiles();
   void ProcessEvaluationFiles();
 
 
+  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();
+  }
+
 protected:
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
   // for a project collect all its targets by following depend
@@ -372,6 +384,7 @@ private:
   std::map<cmStdString, cmStdString> ExtensionToLanguage;
   std::map<cmStdString, cmStdString> ExtensionToLanguage;
   std::map<cmStdString, int> LanguageToLinkerPreference;
   std::map<cmStdString, int> LanguageToLinkerPreference;
   std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags;
   std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags;
+  std::set<std::string> ExportedTargetsFiles;
 
 
   // Record hashes for rules and outputs.
   // Record hashes for rules and outputs.
   struct RuleHash { char Data[32]; };
   struct RuleHash { char Data[32]; };

+ 3 - 1
Source/cmIncludeCommand.cxx

@@ -93,7 +93,9 @@ bool cmIncludeCommand
       cmSystemTools::CollapseFullPath(fname.c_str(),
       cmSystemTools::CollapseFullPath(fname.c_str(),
                                       this->Makefile->GetStartDirectory());
                                       this->Makefile->GetStartDirectory());
 
 
-  if (this->Makefile->IsExportedTargetsFile(fname_abs))
+  cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
+                                        ->GetGlobalGenerator();
+  if (gg->IsExportedTargetsFile(fname_abs))
     {
     {
     const char *modal = 0;
     const char *modal = 0;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;

+ 0 - 13
Source/cmMakefile.h

@@ -489,18 +489,6 @@ public:
       return this->cmCurrentListFile.c_str();
       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();
-  }
-
   //@}
   //@}
 
 
   /**
   /**
@@ -1053,7 +1041,6 @@ private:
   void EnforceDirectoryLevelRules();
   void EnforceDirectoryLevelRules();
 
 
   bool GeneratingBuildSystem;
   bool GeneratingBuildSystem;
-  std::set<std::string> ExportedTargetsFiles;
   /**
   /**
    * Old version of GetSourceFileWithOutput(const char*) kept for
    * Old version of GetSourceFileWithOutput(const char*) kept for
    * backward-compatibility. It implements a linear search and support
    * backward-compatibility. It implements a linear search and support

+ 2 - 5
Tests/RunCMake/include/CMP0024-NEW-stderr.txt

@@ -1,15 +1,12 @@
-CMake Error at CMP0024-NEW.cmake:9 \(include\):
+CMake Error at subdir2/CMakeLists.txt:2 \(include\):
   Policy CMP0024 is not set: Disallow include export result.  Run "cmake
   Policy CMP0024 is not set: Disallow include export result.  Run "cmake
   --help-policy CMP0024" for policy details.  Use the cmake_policy command to
   --help-policy CMP0024" for policy details.  Use the cmake_policy command to
   set the policy and suppress this warning.
   set the policy and suppress this warning.
 
 
   The file
   The file
 
 
-    .*/Tests/RunCMake/include/CMP0024-NEW-build/theTargets.cmake
+    .*/Tests/RunCMake/include/CMP0024-NEW-build/subdir1/theTargets.cmake
 
 
   was generated by the export\(\) command.  It may not be used as the argument
   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
   to the include\(\) command.  Use ALIAS targets instead to refer to targets by
   alternative names.
   alternative names.
-
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

+ 2 - 2
Tests/RunCMake/include/CMP0024-NEW.cmake

@@ -5,5 +5,5 @@ cmake_policy(SET CMP0024 NEW)
 
 
 add_library(foo SHARED empty.cpp)
 add_library(foo SHARED empty.cpp)
 
 
-export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
-include("${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
+add_subdirectory(subdir1)
+add_subdirectory(subdir2)

+ 2 - 4
Tests/RunCMake/include/CMP0024-WARN-stderr.txt

@@ -1,16 +1,14 @@
-CMake Warning \(dev\) at CMP0024-WARN.cmake:7 \(include\):
+CMake Warning \(dev\) at subdir2/CMakeLists.txt:2 \(include\):
   Policy CMP0024 is not set: Disallow include export result.  Run "cmake
   Policy CMP0024 is not set: Disallow include export result.  Run "cmake
   --help-policy CMP0024" for policy details.  Use the cmake_policy command to
   --help-policy CMP0024" for policy details.  Use the cmake_policy command to
   set the policy and suppress this warning.
   set the policy and suppress this warning.
 
 
   The file
   The file
 
 
-    .*/Tests/RunCMake/include/CMP0024-WARN-build/theTargets.cmake
+    .*/Tests/RunCMake/include/CMP0024-WARN-build/subdir1/theTargets.cmake
 
 
   was generated by the export\(\) command.  It should not be used as the
   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
   argument to the include\(\) command.  Use ALIAS targets instead to refer to
   targets by alternative names.
   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.
 This warning is for project developers.  Use -Wno-dev to suppress it.

+ 2 - 2
Tests/RunCMake/include/CMP0024-WARN.cmake

@@ -3,5 +3,5 @@ enable_language(CXX)
 
 
 add_library(foo SHARED empty.cpp)
 add_library(foo SHARED empty.cpp)
 
 
-export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
-include("${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")
+add_subdirectory(subdir1)
+add_subdirectory(subdir2)

+ 2 - 0
Tests/RunCMake/include/subdir1/CMakeLists.txt

@@ -0,0 +1,2 @@
+
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/theTargets.cmake")

+ 2 - 0
Tests/RunCMake/include/subdir2/CMakeLists.txt

@@ -0,0 +1,2 @@
+
+include("${CMAKE_CURRENT_BINARY_DIR}/../subdir1/theTargets.cmake")