summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx151
1 files changed, 93 insertions, 58 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 6ec40fb..f6219ab 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -41,53 +41,6 @@
#include <ctype.h> // for isspace
#include <assert.h>
-#define FOR_EACH_CXX_FEATURE(F) \
- F(cxx_alias_templates) \
- F(cxx_alignas) \
- F(cxx_alignof) \
- F(cxx_attributes) \
- F(cxx_auto_type) \
- F(cxx_constexpr) \
- F(cxx_decltype) \
- F(cxx_decltype_incomplete_return_types) \
- F(cxx_default_function_template_args) \
- F(cxx_defaulted_functions) \
- F(cxx_defaulted_move_initializers) \
- F(cxx_delegating_constructors) \
- F(cxx_deleted_functions) \
- F(cxx_enum_forward_declarations) \
- F(cxx_explicit_conversions) \
- F(cxx_extended_friend_declarations) \
- F(cxx_extern_templates) \
- F(cxx_final) \
- F(cxx_func_identifier) \
- F(cxx_generalized_initializers) \
- F(cxx_inheriting_constructors) \
- F(cxx_inline_namespaces) \
- F(cxx_lambdas) \
- F(cxx_local_type_template_args) \
- F(cxx_long_long_type) \
- F(cxx_noexcept) \
- F(cxx_nonstatic_member_init) \
- F(cxx_nullptr) \
- F(cxx_override) \
- F(cxx_range_for) \
- F(cxx_raw_string_literals) \
- F(cxx_reference_qualified_functions) \
- F(cxx_right_angle_brackets) \
- F(cxx_rvalue_references) \
- F(cxx_sizeof_member) \
- F(cxx_static_assert) \
- F(cxx_strong_enums) \
- F(cxx_thread_local) \
- F(cxx_trailing_return_types) \
- F(cxx_unicode_literals) \
- F(cxx_uniform_initialization) \
- F(cxx_unrestricted_unions) \
- F(cxx_user_literals) \
- F(cxx_variadic_macros) \
- F(cxx_variadic_templates)
-
class cmMakefile::Internals
{
public:
@@ -148,6 +101,8 @@ cmMakefile::cmMakefile(): Internal(new Internals)
this->Initialize();
this->PreOrder = false;
this->GeneratingBuildSystem = false;
+
+ this->NumLastMatches = 0;
}
cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
@@ -196,6 +151,8 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
this->CheckSystemVars = mf.CheckSystemVars;
this->ListFileStack = mf.ListFileStack;
this->OutputToSource = mf.OutputToSource;
+
+ this->NumLastMatches = mf.NumLastMatches;
}
//----------------------------------------------------------------------------
@@ -2498,12 +2455,6 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
{
this->Internal->VarUsageStack.top().insert(name);
}
- if (name == "CMAKE_CXX_KNOWN_FEATURES")
- {
-#define STRING_LIST_ELEMENT(F) ";" #F
- return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
-#undef STRING_LIST_ELEMENT
- }
const char* def = this->Internal->VarStack.top().Get(name);
if(!def)
{
@@ -3911,8 +3862,7 @@ cmTarget* cmMakefile::FindTarget(const std::string& name,
{
if (!excludeAliases)
{
- std::map<std::string, cmTarget*>::const_iterator i
- = this->AliasTargets.find(name);
+ TargetMap::const_iterator i = this->AliasTargets.find(name);
if (i != this->AliasTargets.end())
{
return i->second;
@@ -4134,7 +4084,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
- std::map<std::string, cmTarget*>::const_iterator
+ TargetMap::const_iterator
imported = this->ImportedTargets.find(name);
if(imported != this->ImportedTargets.end())
{
@@ -4328,6 +4278,51 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
return this->QtUiFilesWithOptions;
}
+static std::string matchVariables[] = {
+ "CMAKE_MATCH_0",
+ "CMAKE_MATCH_1",
+ "CMAKE_MATCH_2",
+ "CMAKE_MATCH_3",
+ "CMAKE_MATCH_4",
+ "CMAKE_MATCH_5",
+ "CMAKE_MATCH_6",
+ "CMAKE_MATCH_7",
+ "CMAKE_MATCH_8",
+ "CMAKE_MATCH_9"
+};
+
+//----------------------------------------------------------------------------
+void cmMakefile::ClearMatches()
+{
+ for (unsigned int i=0; i<this->NumLastMatches; i++)
+ {
+ std::string const& var = matchVariables[i];
+ std::string const& s = this->GetSafeDefinition(var);
+ if(!s.empty())
+ {
+ this->AddDefinition(var, "");
+ this->MarkVariableAsUsed(var);
+ }
+ }
+ this->NumLastMatches = 0;
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
+{
+ for (unsigned int i=0; i<10; i++)
+ {
+ std::string const& m = re.match(i);
+ if(!m.empty())
+ {
+ std::string const& var = matchVariables[i];
+ this->AddDefinition(var, m.c_str());
+ this->MarkVariableAsUsed(var);
+ this->NumLastMatches = i + 1;
+ }
+ }
+}
+
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
@@ -4604,8 +4599,28 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
if (!featuresKnown || !*featuresKnown)
{
- // We know of no features for the compiler at all.
- return true;
+ cmOStringStream e;
+ if (error)
+ {
+ e << "no";
+ }
+ else
+ {
+ e << "No";
+ }
+ e << " known features for compiler\n\""
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
+ << "\"\nversion "
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
+ if (error)
+ {
+ *error = e.str();
+ }
+ else
+ {
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+ return false;
}
std::vector<std::string> availableFeatures;
@@ -4626,8 +4641,16 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+ bool needCxx98 = false;
bool needCxx11 = false;
+ if (const char *propCxx98 =
+ this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES"))
+ {
+ std::vector<std::string> props;
+ cmSystemTools::ExpandListArgument(propCxx98, props);
+ needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
+ }
if (const char *propCxx11 =
this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES"))
{
@@ -4655,6 +4678,7 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
cmStrCmp(existingCxxStandard))
: cmArrayEnd(CXX_STANDARDS);
+ bool setCxx98 = needCxx98 && !existingCxxStandard;
bool setCxx11 = needCxx11 && !existingCxxStandard;
if (needCxx11 && existingCxxStandard && existingCxxIt <
@@ -4664,10 +4688,21 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
{
setCxx11 = true;
}
+ else if(needCxx98 && existingCxxStandard && existingCxxIt <
+ std::find_if(cmArrayBegin(CXX_STANDARDS),
+ cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp("98")))
+ {
+ setCxx98 = true;
+ }
if (setCxx11)
{
target->SetProperty("CXX_STANDARD", "11");
}
+ else if (setCxx98)
+ {
+ target->SetProperty("CXX_STANDARD", "98");
+ }
return true;
}