summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-10-13 00:00:24 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-07 14:48:44 (GMT)
commit913394af249d6b1892a6e609d2abfed001fa1dc4 (patch)
tree484096975102a7da96f95e184d48aff7f6393492 /Source
parent8238a6cd5d2867e709e87a752e0a24c7c2bf28f0 (diff)
downloadCMake-913394af249d6b1892a6e609d2abfed001fa1dc4.zip
CMake-913394af249d6b1892a6e609d2abfed001fa1dc4.tar.gz
CMake-913394af249d6b1892a6e609d2abfed001fa1dc4.tar.bz2
cmTarget: Add CXX_STANDARD and CXX_EXTENSION target properties.
These are used to determine whether to add -std=c++11, -std=gnu++11 etc flags on the compile line.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx29
-rw-r--r--Source/cmLocalGenerator.h2
-rw-r--r--Source/cmTarget.cxx2
3 files changed, 33 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1e65a02..779a2b8 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1459,6 +1459,7 @@ void cmLocalGenerator::AddCompileOptions(
this->AppendFlagEscape(flags, *i);
}
}
+ this->AddCompilerRequirementFlag(flags, target, lang);
}
//----------------------------------------------------------------------------
@@ -2128,6 +2129,34 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
}
}
+//----------------------------------------------------------------------------
+void cmLocalGenerator::
+AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+ const std::string& lang)
+{
+ if (lang.empty())
+ {
+ return;
+ }
+ std::string stdProp = lang + "_STANDARD";
+ const char *standard = target->GetProperty(stdProp);
+ if (!standard)
+ {
+ return;
+ }
+ std::string extProp = lang + "_EXTENSIONS";
+ bool ext = target->GetPropertyAsBool(extProp);
+ std::string type = ext ? "EXTENSION" : "STANDARD";
+
+ std::string compile_option =
+ "CMAKE_" + lang + std::string(standard)
+ + "_" + type + "_COMPILE_OPTION";
+ if (const char *opt = target->GetMakefile()->GetDefinition(compile_option))
+ {
+ this->AppendFlags(flags, opt);
+ }
+}
+
static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
cmLocalGenerator *lg,
const std::string& lang)
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 8f30149..12a94e4 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -149,6 +149,8 @@ public:
const std::string& lang);
void AddConfigVariableFlags(std::string& flags, const std::string& var,
const std::string& config);
+ void AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+ const std::string& lang);
///! Append flags to a string.
virtual void AppendFlags(std::string& flags, const char* newFlags);
virtual void AppendFlagEscape(std::string& flags,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index d28ac3f..53c0205 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -307,6 +307,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("MACOSX_BUNDLE", 0);
this->SetPropertyDefault("MACOSX_RPATH", 0);
this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+ this->SetPropertyDefault("CXX_STANDARD", 0);
+ this->SetPropertyDefault("CXX_EXTENSIONS", 0);
}
// Collect the set of configuration types.