summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2019-11-14 12:35:37 +0100
committerBrad King <brad.king@kitware.com>2019-11-14 11:05:56 -0500
commit6a818b693192e96f57c866caf2541669342a700b (patch)
treefe0ee94a36a3e52739d33378506cdba53a8491ba
parent842605341a6d1c3ca4fe4650f0f1572631cfc6a5 (diff)
downloadcmake-6a818b693192e96f57c866caf2541669342a700b.tar.gz
ObjC: Proper initialization of ObjC/XX standard properties
Fix logic added by commit 81566557d5 (ObjC: Initialize ObjC/XX standard properties from C/C++ counterparts, 2019-11-09) to account for cases when the CXX standard is not explicitly set. Also, do not copy the `*_STANDARD_REQUIRED` and `*_EXTENSIONS` properties unless we copied the `*_STANDARD` property.
-rw-r--r--Source/cmLocalGenerator.cxx43
1 files changed, 29 insertions, 14 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 5f8b92089a..923d2a5df3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -714,21 +714,36 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
// 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)));
+ if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ auto copyStandardToObjLang = [&](LanguagePair const& lang) -> bool {
+ if (!target->GetProperty(cmStrCat(lang.first, "_STANDARD"))) {
+ auto* standard =
+ target->GetProperty(cmStrCat(lang.second, "_STANDARD"));
+ if (!standard) {
+ standard = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang.second, "_STANDARD_DEFAULT"));
+ }
+ target->Target->SetProperty(cmStrCat(lang.first, "_STANDARD"),
+ standard);
+ return true;
+ }
+ return false;
+ };
+ auto copyPropertyToObjLang = [&](LanguagePair const& lang,
+ const char* property) {
+ if (!target->GetProperty(cmStrCat(lang.first, property)) &&
+ target->GetProperty(cmStrCat(lang.second, property))) {
+ target->Target->SetProperty(
+ cmStrCat(lang.first, property),
+ target->GetProperty(cmStrCat(lang.second, property)));
+ }
+ };
+ for (auto const& lang : objcEnabledLanguages) {
+ if (copyStandardToObjLang(lang)) {
+ copyPropertyToObjLang(lang, "_STANDARD_REQUIRED");
+ copyPropertyToObjLang(lang, "_EXTENSIONS");
+ }
}
- };
- for (auto const& lang : objcEnabledLanguages) {
- copyPropertyToObjLang(lang, "_STANDARD");
- copyPropertyToObjLang(lang, "_STANDARD_REQUIRED");
- copyPropertyToObjLang(lang, "_EXTENSIONS");
}
}