diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-03-04 20:46:42 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-03-09 19:49:16 (GMT) |
commit | 0b945ea9a6a38d1b3ee27cc32afb4268bd571600 (patch) | |
tree | 79411aba297b00a76587c9bd855e3a9e5afa3e10 /Source | |
parent | 5c559f11137dcb14113a3c5df99ff896c65c7596 (diff) | |
download | CMake-0b945ea9a6a38d1b3ee27cc32afb4268bd571600.zip CMake-0b945ea9a6a38d1b3ee27cc32afb4268bd571600.tar.gz CMake-0b945ea9a6a38d1b3ee27cc32afb4268bd571600.tar.bz2 |
Genex: Allow COMPILE_LANGUAGE when processing compile definitions.
Issue an error if this is encountered by an IDE generator.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExtraCodeBlocksGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 15 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 32 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 10 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 14 | ||||
-rw-r--r-- | Source/cmTarget.h | 3 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 3 |
15 files changed, 58 insertions, 42 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 69857ef..614e7d9 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -599,7 +599,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector<std::string> cdefs; - target->GetCompileDefinitions(cdefs, buildType); + target->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector<std::string>::const_iterator di = cdefs.begin(); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 5fff0fb..25f9005 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -436,7 +436,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, } // Add preprocessor definitions for this target and configuration. - lg->AddCompileDefinitions(defines, target, config); + lg->AddCompileDefinitions(defines, target, config, language); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 6a9f251..3ec8595 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -817,7 +817,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content, - cmGeneratorExpressionDAGChecker *) const + cmGeneratorExpressionDAGChecker *dagChecker) const { if(context->Language.empty()) { @@ -849,12 +849,21 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode "generators."); return std::string(); } + else if (genName.find("Xcode") != std::string::npos) + { + if (dagChecker && dagChecker->EvaluatingCompileDefinitions()) + { + reportError(context, content->GetOriginalExpression(), + "$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS " + "with the Xcode generator."); + return std::string(); + } + } else { if(genName.find("Makefiles") == std::string::npos && genName.find("Ninja") == std::string::npos && - genName.find("Watcom WMake") == std::string::npos && - genName.find("Xcode") == std::string::npos) + genName.find("Watcom WMake") == std::string::npos) { reportError(context, content->GetOriginalExpression(), "$<COMPILE_LANGUAGE:...> not supported for this generator."); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e89161d..bd8a1f5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1803,7 +1803,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector<std::string> targetDefines; - target.GetCompileDefinitions(targetDefines, configName); + target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index be82085..735dfa9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1428,11 +1428,11 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, cmTarget const* target, - const std::string& config) + const std::string& config, + const std::string& lang) { std::vector<std::string> targetDefines; - target->GetCompileDefinitions(targetDefines, - config); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3a9d5be..f1f0da1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -239,7 +239,8 @@ public: const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set<std::string>& defines, cmTarget const* target, - const std::string& config); + const std::string& config, + const std::string& lang); /** Compute the language used to compile the given source file. */ std::string GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 432cb3a..9ecb029 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2094,26 +2094,26 @@ void cmLocalUnixMakefileGenerator3 << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid << "\")\n"; } - } - // Build a list of preprocessor definitions for the target. - std::set<std::string> defines; - this->AddCompileDefinitions(defines, &target, - this->ConfigurationName); - if(!defines.empty()) - { - cmakefileStream - << "\n" - << "# Preprocessor definitions for this target.\n" - << "set(CMAKE_TARGET_DEFINITIONS\n"; - for(std::set<std::string>::const_iterator di = defines.begin(); - di != defines.end(); ++di) + // Build a list of preprocessor definitions for the target. + std::set<std::string> defines; + this->AddCompileDefinitions(defines, &target, + this->ConfigurationName, l->first); + if(!defines.empty()) { cmakefileStream - << " " << this->EscapeForCMake(*di) << "\n"; + << "\n" + << "# Preprocessor definitions for this target.\n" + << "set(CMAKE_TARGET_DEFINITIONS_" << l->first << "\n"; + for(std::set<std::string>::const_iterator di = defines.begin(); + di != defines.end(); ++di) + { + cmakefileStream + << " " << this->EscapeForCMake(*di) << "\n"; + } + cmakefileStream + << " )\n"; } - cmakefileStream - << " )\n"; } // Store include transform rule properties. Write the directory diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0848b03..2b999eb 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1778,15 +1778,15 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AddCompileDefinitions(definesSet, &target, ""); + this->AddCompileDefinitions(definesSet, &target, "", linkLanguage); this->AddCompileDefinitions(debugDefinesSet, &target, - "DEBUG"); + "DEBUG", linkLanguage); this->AddCompileDefinitions(releaseDefinesSet, &target, - "RELEASE"); + "RELEASE", linkLanguage); this->AddCompileDefinitions(minsizeDefinesSet, &target, - "MINSIZEREL"); + "MINSIZEREL", linkLanguage); this->AddCompileDefinitions(debugrelDefinesSet, &target, - "RELWITHDEBINFO"); + "RELWITHDEBINFO", linkLanguage); std::string defines = " "; std::string debugDefines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ed560aa..f53f825 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -775,7 +775,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); std::vector<std::string> targetDefines; - target.GetCompileDefinitions(targetDefines, configName); + target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 20207f5..57c49f1 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -329,7 +329,7 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - this->LocalGenerator->ConfigurationName); + this->LocalGenerator->ConfigurationName, l); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cfd8937..92fccd3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -231,7 +231,7 @@ ComputeDefines(cmSourceFile const* source, const std::string& language) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - this->GetConfigName()); + this->GetConfigName(), language); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index e18e757..844d708 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -507,7 +507,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget const* target, incs = cmJoin(includeDirs, ";"); std::set<std::string> defines; - localGen->AddCompileDefinitions(defines, target, config); + localGen->AddCompileDefinitions(defines, target, config, "CXX"); defs += cmJoin(defines, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c54d694..87dcc99 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2336,16 +2336,18 @@ static void processCompileDefinitions(cmTarget const* tgt, std::vector<std::string> &options, UNORDERED_SET<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) + const std::string& config, bool debugOptions, + std::string const& language) { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, - "definitions", std::string()); + "definitions", language); } //---------------------------------------------------------------------------- void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, - const std::string& config) const + const std::string& config, + const std::string& language) const { UNORDERED_SET<std::string> uniqueOptions; @@ -2377,7 +2379,8 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, uniqueOptions, &dagChecker, config, - debugDefines); + debugDefines, + language); std::vector<cmTargetInternals::TargetPropertyEntry*> linkInterfaceCompileDefinitionsEntries; @@ -2424,7 +2427,8 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, uniqueOptions, &dagChecker, config, - debugDefines); + debugDefines, + language); deleteAndClear(linkInterfaceCompileDefinitionsEntries); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 56db22e..0356c1e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -496,7 +496,8 @@ public: const char* GetExportMacro() const; void GetCompileDefinitions(std::vector<std::string> &result, - const std::string& config) const; + const std::string& config, + const std::string& language) const; // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 04d1487..19444ed 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1876,7 +1876,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector<std::string> targetDefines; - this->Target->GetCompileDefinitions(targetDefines, configName.c_str()); + this->Target->GetCompileDefinitions(targetDefines, + configName.c_str(), "CXX"); clOptions.AddDefines(targetDefines); if(this->MSTools) { |