From 81566557d591bf375384ca3e697877ba67c2f77d Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Sat, 9 Nov 2019 19:52:31 +0100 Subject: ObjC: Initialize ObjC/XX standard properties from C/C++ counterparts Fixes: #19937 --- Source/cmLocalGenerator.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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::vector pairedLanguages{ { "OBJC", "C" }, + { "OBJCXX", "CXX" } }; + std::set 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& 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; -- cgit v0.12