diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-11-09 18:52:31 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-11-12 18:41:25 (GMT) |
commit | 81566557d591bf375384ca3e697877ba67c2f77d (patch) | |
tree | 407fdf5c95426653c3e213ea372e3e38f3ccf627 | |
parent | 28bc41ca62b00d5c265c83436f317f970a4b9a93 (diff) | |
download | CMake-81566557d591bf375384ca3e697877ba67c2f77d.zip CMake-81566557d591bf375384ca3e697877ba67c2f77d.tar.gz CMake-81566557d591bf375384ca3e697877ba67c2f77d.tar.bz2 |
ObjC: Initialize ObjC/XX standard properties from C/C++ counterparts
Fixes: #19937
-rw-r--r-- | Source/cmLocalGenerator.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b79eb1d..5f8b920 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -693,6 +693,16 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() configNames.emplace_back(); } + using LanguagePair = std::pair<std::string, std::string>; + std::vector<LanguagePair> pairedLanguages{ { "OBJC", "C" }, + { "OBJCXX", "CXX" } }; + std::set<LanguagePair> objcEnabledLanguages; + for (auto const& lang : pairedLanguages) { + if (this->Makefile->GetState()->GetLanguageEnabled(lang.first)) { + objcEnabledLanguages.insert(lang); + } + } + // Process compile features of all targets. const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); for (cmGeneratorTarget* target : targets) { @@ -701,6 +711,25 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() return false; } } + + // Now that C/C++ _STANDARD values have been computed + // set the values to ObjC/ObjCXX _STANDARD variables + auto copyPropertyToObjLang = [&](LanguagePair const& lang, + const char* property) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + return; + } + if (!target->GetProperty(cmStrCat(lang.first, property))) { + target->Target->SetProperty( + cmStrCat(lang.first, property), + target->GetProperty(cmStrCat(lang.second, property))); + } + }; + for (auto const& lang : objcEnabledLanguages) { + copyPropertyToObjLang(lang, "_STANDARD"); + copyPropertyToObjLang(lang, "_STANDARD_REQUIRED"); + copyPropertyToObjLang(lang, "_EXTENSIONS"); + } } return true; |