Bladeren bron

cmLocalGenerator: Remove AddCompileDefinitions method

This method offers the same definitions as `GetTargetDefines` except
that it excludes the "export" macro on shared libraries.  Update call
sites to use `GetTargetDefines` instead.  Some of them were incorrectly
excluding the export macro.
Brad King 7 jaren geleden
bovenliggende
commit
8f076acdb0

+ 1 - 6
Source/cmExtraSublimeTextGenerator.cxx

@@ -384,13 +384,8 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
   cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
                                                     language);
 
-  // Add the export symbol definition for shared library objects.
-  if (const char* exportMacro = target->GetExportMacro()) {
-    lg->AppendDefines(defines, exportMacro);
-  }
-
   // Add preprocessor definitions for this target and configuration.
-  lg->AddCompileDefinitions(defines, target, config, language);
+  lg->GetTargetDefines(target, config, language, defines);
   const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
   if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
     lg->AppendDefines(

+ 2 - 7
Source/cmGhsMultiTargetGenerator.cxx

@@ -267,14 +267,9 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
   if (i == this->DefinesByLanguage.end()) {
     std::set<std::string> defines;
     const char* lang = language.c_str();
-    // Add the export symbol definition for shared library objects.
-    if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
-      this->LocalGenerator->AppendDefines(defines, exportMacro);
-    }
-
     // Add preprocessor definitions for this target and configuration.
-    this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
-                                                config, language);
+    this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, config,
+                                           language, defines);
 
     std::string definesString;
     this->LocalGenerator->JoinDefines(defines, definesString, lang);

+ 3 - 11
Source/cmLocalGenerator.cxx

@@ -773,16 +773,6 @@ std::string cmLocalGenerator::GetIncludeFlags(
   return flags;
 }
 
-void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
-                                             cmGeneratorTarget const* target,
-                                             const std::string& config,
-                                             const std::string& lang) const
-{
-  std::vector<std::string> targetDefines;
-  target->GetCompileDefinitions(targetDefines, config, lang);
-  this->AppendDefines(defines, targetDefines);
-}
-
 void cmLocalGenerator::AddCompileOptions(std::string& flags,
                                          cmGeneratorTarget* target,
                                          const std::string& lang,
@@ -1237,7 +1227,9 @@ void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target,
   }
 
   // Add preprocessor definitions for this target and configuration.
-  this->AddCompileDefinitions(defines, target, config, lang);
+  std::vector<std::string> targetDefines;
+  target->GetCompileDefinitions(targetDefines, config, lang);
+  this->AppendDefines(defines, targetDefines);
 }
 
 std::string cmLocalGenerator::GetTargetFortranFlags(

+ 0 - 4
Source/cmLocalGenerator.h

@@ -251,10 +251,6 @@ public:
                              bool appendAllImplicitDirs = false) const;
   void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
                          const std::string& lang, const std::string& config);
-  void AddCompileDefinitions(std::set<std::string>& defines,
-                             cmGeneratorTarget const* target,
-                             const std::string& config,
-                             const std::string& lang) const;
 
   std::string GetProjectName() const;
 

+ 2 - 2
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1819,8 +1819,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
 
     // Build a list of preprocessor definitions for the target.
     std::set<std::string> defines;
-    this->AddCompileDefinitions(defines, target, this->ConfigName,
-                                implicitLang.first);
+    this->GetTargetDefines(target, this->ConfigName, implicitLang.first,
+                           defines);
     if (!defines.empty()) {
       /* clang-format off */
       cmakefileStream

+ 1 - 1
Source/cmQtAutoGenInitializer.cxx

@@ -416,7 +416,7 @@ bool cmQtAutoGenInitializer::InitMoc()
     auto GetCompileDefinitions =
       [this, localGen](std::string const& cfg) -> std::string {
       std::set<std::string> defines;
-      localGen->AddCompileDefinitions(defines, this->Target, cfg, "CXX");
+      localGen->GetTargetDefines(this->Target, cfg, "CXX", defines);
       return cmJoin(defines, ";");
     };