summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx281
1 files changed, 201 insertions, 80 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e684689..ab7de57 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -35,9 +35,10 @@
#include "cmake.h"
#include <stdlib.h> // required for atoi
+#include <cm_auto_ptr.hxx>
#include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx>
-#include <cmsys/auto_ptr.hxx>
+#include <cmsys/SystemTools.hxx>
#include <assert.h>
#include <ctype.h> // for isspace
@@ -105,8 +106,8 @@ cmMakefile::~cmMakefile()
cmDeleteAll(this->EvaluationFiles);
}
-void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text,
- bool force) const
+void cmMakefile::IssueMessage(cmake::MessageType t,
+ std::string const& text) const
{
// Collect context information.
if (!this->ExecutionStatusStack.empty()) {
@@ -114,7 +115,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text,
this->ExecutionStatusStack.back()->SetNestedError(true);
}
}
- this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(), force);
+ this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
}
cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
@@ -175,8 +176,29 @@ cmListFileContext cmMakefile::GetExecutionContext() const
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
+ // Check if current file in the list of requested to trace...
+ std::vector<std::string> const& trace_only_this_files =
+ this->GetCMakeInstance()->GetTraceSources();
+ std::string const& full_path = this->GetExecutionFilePath();
+ std::string const& only_filename = cmSystemTools::GetFilenameName(full_path);
+ bool trace = trace_only_this_files.empty();
+ if (!trace) {
+ for (std::vector<std::string>::const_iterator i =
+ trace_only_this_files.begin();
+ !trace && i != trace_only_this_files.end(); ++i) {
+ std::string::size_type const pos = full_path.rfind(*i);
+ trace = (pos != std::string::npos) &&
+ ((pos + i->size()) == full_path.size()) &&
+ (only_filename == cmSystemTools::GetFilenameName(*i));
+ }
+ // Do nothing if current file wasn't requested for trace...
+ if (!trace) {
+ return;
+ }
+ }
+
std::ostringstream msg;
- msg << this->GetExecutionFilePath() << "(" << lff.Line << "): ";
+ msg << full_path << "(" << lff.Line << "): ";
msg << lff.Name << "(";
bool expand = this->GetCMakeInstance()->GetTraceExpand();
std::string temp;
@@ -240,7 +262,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
// Lookup the command prototype.
if (cmCommand* proto = this->GetState()->GetCommand(name)) {
// Clone the prototype.
- cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
+ CM_AUTO_PTR<cmCommand> pcmd(proto->Clone());
pcmd->SetMakefile(this);
// Decide whether to invoke the command.
@@ -254,9 +276,10 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
this->PrintCommandTrace(lff);
}
// Try invoking the command.
- if (!pcmd->InvokeInitialPass(lff.Arguments, status) ||
- status.GetNestedError()) {
- if (!status.GetNestedError()) {
+ bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status);
+ bool hadNestedError = status.GetNestedError();
+ if (!invokeSucceeded || hadNestedError) {
+ if (!hadNestedError) {
// The command invocation requested that we report an error.
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
}
@@ -426,7 +449,7 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
IncludeScope incScope(this, filenametoread, noPolicyScope);
cmListFile listFile;
- if (!listFile.ParseFile(filenametoread.c_str(), false, this)) {
+ if (!listFile.ParseFile(filenametoread.c_str(), this)) {
return false;
}
@@ -475,7 +498,7 @@ bool cmMakefile::ReadListFile(const char* filename)
ListFileScope scope(this, filenametoread);
cmListFile listFile;
- if (!listFile.ParseFile(filenametoread.c_str(), false, this)) {
+ if (!listFile.ParseFile(filenametoread.c_str(), this)) {
return false;
}
@@ -546,7 +569,8 @@ void cmMakefile::EnforceDirectoryLevelRules() const
case cmPolicies::WARN:
// Warn because the user did not provide a mimimum required
// version.
- this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
+ this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
+ msg.str(), this->Backtrace);
case cmPolicies::OLD:
// OLD behavior is to use policy version 2.4 set in
// cmListFileCache.
@@ -555,7 +579,8 @@ void cmMakefile::EnforceDirectoryLevelRules() const
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
// NEW behavior is to issue an error.
- this->IssueMessage(cmake::FATAL_ERROR, msg.str());
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str(),
+ this->Backtrace);
cmSystemTools::SetFatalErrorOccured();
return;
}
@@ -564,9 +589,8 @@ void cmMakefile::EnforceDirectoryLevelRules() const
void cmMakefile::AddEvaluationFile(
const std::string& inputFile,
- cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
- cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
- bool inputIsContent)
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent)
{
this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
inputFile, outputName, condition, inputIsContent));
@@ -651,12 +675,13 @@ void cmMakefile::ConfigureFinalPass()
const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
if (oldValue &&
cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) {
- this->IssueMessage(
+ this->GetCMakeInstance()->IssueMessage(
cmake::FATAL_ERROR,
"You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less "
"than 2.4. This version of CMake only supports backwards compatibility "
"with CMake 2.4 or later. For compatibility with older versions please "
- "use any CMake 2.8.x release or lower.");
+ "use any CMake 2.8.x release or lower.",
+ this->Backtrace);
}
}
@@ -761,7 +786,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
// Make sure there is at least one output.
if (outputs.empty()) {
cmSystemTools::Error("Attempt to add a custom rule with no output!");
- return 0;
+ return CM_NULLPTR;
}
// Validate custom commands. TODO: More strict?
@@ -772,12 +797,12 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
std::ostringstream e;
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
- return 0;
+ return CM_NULLPTR;
}
}
// Choose a source file on which to store the custom command.
- cmSourceFile* file = 0;
+ cmSourceFile* file = CM_NULLPTR;
if (!commandLines.empty() && !main_dependency.empty()) {
// The main dependency was specified. Use it unless a different
// custom command already used it.
@@ -791,7 +816,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
} else {
// The existing custom command is different. We need to
// generate a rule file for this new command.
- file = 0;
+ file = CM_NULLPTR;
}
} else if (!file) {
file = this->CreateSource(main_dependency);
@@ -912,7 +937,7 @@ void cmMakefile::AddCustomCommandOldStyle(
std::vector<std::string> no_byproducts;
this->AddCustomCommandToTarget(target, no_byproducts, depends,
commandLines, cmTarget::POST_BUILD, comment,
- 0);
+ CM_NULLPTR);
return;
}
@@ -930,14 +955,14 @@ void cmMakefile::AddCustomCommandOldStyle(
if (sourceFiles.find(source)) {
// The source looks like a real file. Use it as the main dependency.
sf = this->AddCustomCommandToOutput(output, depends, source,
- commandLines, comment, 0);
+ commandLines, comment, CM_NULLPTR);
} else {
// The source may not be a real file. Do not use a main dependency.
std::string no_main_dependency = "";
std::vector<std::string> depends2 = depends;
depends2.push_back(source);
sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
- commandLines, comment, 0);
+ commandLines, comment, CM_NULLPTR);
}
// If the rule was added to the source (and not a .rule file),
@@ -1420,10 +1445,81 @@ void cmMakefile::Configure()
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
cmListFile listFile;
- if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(),
- this)) {
+ if (!listFile.ParseFile(currentStart.c_str(), this)) {
return;
}
+ if (this->IsRootMakefile()) {
+ bool hasVersion = false;
+ // search for the right policy command
+ for (std::vector<cmListFileFunction>::iterator i =
+ listFile.Functions.begin();
+ i != listFile.Functions.end(); ++i) {
+ if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") {
+ hasVersion = true;
+ break;
+ }
+ }
+ // if no policy command is found this is an error if they use any
+ // non advanced functions or a lot of functions
+ if (!hasVersion) {
+ bool isProblem = true;
+ if (listFile.Functions.size() < 30) {
+ // the list of simple commands DO NOT ADD TO THIS LIST!!!!!
+ // these commands must have backwards compatibility forever and
+ // and that is a lot longer than your tiny mind can comprehend mortal
+ std::set<std::string> allowedCommands;
+ allowedCommands.insert("project");
+ allowedCommands.insert("set");
+ allowedCommands.insert("if");
+ allowedCommands.insert("endif");
+ allowedCommands.insert("else");
+ allowedCommands.insert("elseif");
+ allowedCommands.insert("add_executable");
+ allowedCommands.insert("add_library");
+ allowedCommands.insert("target_link_libraries");
+ allowedCommands.insert("option");
+ allowedCommands.insert("message");
+ isProblem = false;
+ for (std::vector<cmListFileFunction>::iterator i =
+ listFile.Functions.begin();
+ i != listFile.Functions.end(); ++i) {
+ std::string name = cmSystemTools::LowerCase(i->Name);
+ if (allowedCommands.find(name) == allowedCommands.end()) {
+ isProblem = true;
+ break;
+ }
+ }
+ }
+
+ if (isProblem) {
+ // Tell the top level cmMakefile to diagnose
+ // this violation of CMP0000.
+ this->SetCheckCMP0000(true);
+
+ // Implicitly set the version for the user.
+ this->SetPolicyVersion("2.4");
+ }
+ }
+ bool hasProject = false;
+ // search for a project command
+ for (std::vector<cmListFileFunction>::iterator i =
+ listFile.Functions.begin();
+ i != listFile.Functions.end(); ++i) {
+ if (cmSystemTools::LowerCase(i->Name) == "project") {
+ hasProject = true;
+ break;
+ }
+ }
+ // if no project command is found, add one
+ if (!hasProject) {
+ cmListFileFunction project;
+ project.Name = "PROJECT";
+ cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0);
+ project.Arguments.push_back(prj);
+ listFile.Functions.insert(listFile.Functions.begin(), project);
+ }
+ }
+
this->ReadListFile(listFile, currentStart);
if (cmSystemTools::GetFatalErrorOccured()) {
scope.Quiet();
@@ -1720,8 +1816,8 @@ void cmMakefile::RemoveDefinition(const std::string& name)
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
- vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS, 0,
- this);
+ vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS,
+ CM_NULLPTR, this);
}
#endif
}
@@ -1854,7 +1950,7 @@ cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
}
// otherwise return NULL
- return 0;
+ return CM_NULLPTR;
}
cmSourceFile* cmMakefile::GetSourceFileWithOutput(
@@ -1870,14 +1966,14 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput(
if (o != this->OutputToSource.end()) {
return (*o).second;
}
- return 0;
+ return CM_NULLPTR;
}
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmSourceGroup* cmMakefile::GetSourceGroup(
const std::vector<std::string>& name) const
{
- cmSourceGroup* sg = 0;
+ cmSourceGroup* sg = CM_NULLPTR;
// first look for source group starting with the same as the one we want
for (std::vector<cmSourceGroup>::const_iterator sgIt =
@@ -1890,11 +1986,11 @@ cmSourceGroup* cmMakefile::GetSourceGroup(
}
}
- if (sg != 0) {
+ if (sg != CM_NULLPTR) {
// iterate through its children to find match source group
for (unsigned int i = 1; i < name.size(); ++i) {
sg = sg->LookupChild(name[i].c_str());
- if (sg == 0) {
+ if (sg == CM_NULLPTR) {
break;
}
}
@@ -1912,14 +2008,14 @@ void cmMakefile::AddSourceGroup(const std::string& name, const char* regex)
void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
const char* regex)
{
- cmSourceGroup* sg = 0;
+ cmSourceGroup* sg = CM_NULLPTR;
std::vector<std::string> currentName;
int i = 0;
const int lastElement = static_cast<int>(name.size() - 1);
for (i = lastElement; i >= 0; --i) {
currentName.assign(name.begin(), name.begin() + i + 1);
sg = this->GetSourceGroup(currentName);
- if (sg != 0) {
+ if (sg != CM_NULLPTR) {
break;
}
}
@@ -1946,7 +2042,8 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
}
// build the whole source group path
for (++i; i <= lastElement; ++i) {
- sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
+ sg->AddChild(
+ cmSourceGroup(name[i].c_str(), CM_NULLPTR, sg->GetFullName()));
sg = sg->LookupChild(name[i].c_str());
}
@@ -2048,7 +2145,8 @@ void cmMakefile::ExpandVariablesCMP0019()
<< "The following variable evaluations were encountered:\n"
<< w.str();
/* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(),
+ this->Backtrace);
}
}
@@ -2076,6 +2174,14 @@ bool cmMakefile::IsSet(const std::string& name) const
return true;
}
+bool cmMakefile::PlatformIs32Bit() const
+{
+ if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
+ return atoi(sizeof_dptr) == 4;
+ }
+ return false;
+}
+
bool cmMakefile::PlatformIs64Bit() const
{
if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
@@ -2124,20 +2230,11 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const
// If we are doing an in-source build, then the test will always fail
if (cmSystemTools::SameFile(this->GetHomeDirectory(),
this->GetHomeOutputDirectory())) {
- if (this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD")) {
- return false;
- }
- return true;
+ return !this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD");
}
- // Check if this is a subdirectory of the source tree but not a
- // subdirectory of the build tree
- if (cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) &&
- !cmSystemTools::IsSubDirectory(fileName,
- this->GetHomeOutputDirectory())) {
- return false;
- }
- return true;
+ return !cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) ||
+ cmSystemTools::IsSubDirectory(fileName, this->GetHomeOutputDirectory());
}
const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
@@ -2166,7 +2263,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
}
}
#endif
- return def ? true : false;
+ return def != CM_NULLPTR;
}
const char* cmMakefile::GetDefinition(const std::string& name) const
@@ -2473,8 +2570,9 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
openstack.pop_back();
result.append(last, in - last);
std::string const& lookup = result.substr(var.loc);
- const char* value = NULL;
+ const char* value = CM_NULLPTR;
std::string varresult;
+ std::string svalue;
static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
switch (var.domain) {
case NORMAL:
@@ -2487,7 +2585,9 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
}
break;
case ENVIRONMENT:
- value = cmSystemTools::GetEnv(lookup.c_str());
+ if (cmSystemTools::GetEnv(lookup, svalue)) {
+ value = svalue.c_str();
+ }
break;
case CACHE:
value = state->GetCacheEntryValue(lookup);
@@ -2526,7 +2626,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (!atOnly) {
t_lookup lookup;
const char* next = in + 1;
- const char* start = NULL;
+ const char* start = CM_NULLPTR;
char nextc = *next;
if (nextc == '{') {
// Looking for a variable.
@@ -2792,7 +2892,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
FunctionBlockersType::size_type barrier =
this->FunctionBlockerBarriers.back();
while (this->FunctionBlockers.size() > barrier) {
- cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
+ CM_AUTO_PTR<cmFunctionBlocker> fb(this->FunctionBlockers.back());
this->FunctionBlockers.pop_back();
if (reportError) {
// Report the context in which the unclosed block was opened.
@@ -2929,7 +3029,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
this->FunctionBlockers.push_back(fb);
}
-cmsys::auto_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
+CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
cmFunctionBlocker* fb, const cmListFileFunction& lff)
{
// Find the function blocker stack barrier for the current scope.
@@ -2962,11 +3062,11 @@ cmsys::auto_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
}
cmFunctionBlocker* b = *pos;
this->FunctionBlockers.erase(pos);
- return cmsys::auto_ptr<cmFunctionBlocker>(b);
+ return CM_AUTO_PTR<cmFunctionBlocker>(b);
}
}
- return cmsys::auto_ptr<cmFunctionBlocker>();
+ return CM_AUTO_PTR<cmFunctionBlocker>();
}
const char* cmMakefile::GetHomeDirectory() const
@@ -3010,7 +3110,7 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
return sf;
}
}
- return 0;
+ return CM_NULLPTR;
}
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
@@ -3180,7 +3280,7 @@ cmVariableWatch* cmMakefile::GetVariableWatch() const
this->GetCMakeInstance()->GetVariableWatch()) {
return this->GetCMakeInstance()->GetVariableWatch();
}
- return 0;
+ return CM_NULLPTR;
}
#endif
@@ -3341,8 +3441,8 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output,
}
// Perform variable replacements.
- this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, 0, -1,
- true, true);
+ this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, CM_NULLPTR,
+ -1, true, true);
}
int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
@@ -3384,7 +3484,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
}
} else {
std::string newLineCharacters;
- std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc;
+ std::ios::openmode omode = std::ios::out | std::ios::trunc;
if (newLine.IsValid()) {
newLineCharacters = newLine.GetCharacters();
omode |= std::ios::binary;
@@ -3425,7 +3525,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
while (cmSystemTools::GetLineFromStream(fin, inLine)) {
outLine = "";
this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
- fout << outLine.c_str() << newLineCharacters;
+ fout << outLine << newLineCharacters;
}
// close the files before attempting to copy
fin.close();
@@ -3481,7 +3581,7 @@ cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
if (i != this->Targets.end()) {
return &i->second;
}
- return 0;
+ return CM_NULLPTR;
}
cmTest* cmMakefile::CreateTest(const std::string& testName)
@@ -3503,7 +3603,7 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const
if (mi != this->Tests.end()) {
return mi->second;
}
- return 0;
+ return CM_NULLPTR;
}
void cmMakefile::AddCMakeDependFilesFromUser()
@@ -3594,7 +3694,7 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
cmState::TargetType type, bool global)
{
// Create the target.
- cmsys::auto_ptr<cmTarget> target(new cmTarget);
+ CM_AUTO_PTR<cmTarget> target(new cmTarget);
target->SetType(type, name);
target->MarkAsImported(global);
target->SetMakefile(this);
@@ -3629,8 +3729,9 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
bool cmMakefile::IsAlias(const std::string& name) const
{
- if (this->AliasTargets.find(name) != this->AliasTargets.end())
+ if (this->AliasTargets.find(name) != this->AliasTargets.end()) {
return true;
+ }
return this->GetGlobalGenerator()->IsAlias(name);
}
@@ -3963,10 +4064,10 @@ bool cmMakefile::IgnoreErrorsCMP0061() const
}
#define FEATURE_STRING(F) , #F
-static const char* const C_FEATURES[] = { 0 FOR_EACH_C_FEATURE(
+static const char* const C_FEATURES[] = { CM_NULLPTR FOR_EACH_C_FEATURE(
FEATURE_STRING) };
-static const char* const CXX_FEATURES[] = { 0 FOR_EACH_CXX_FEATURE(
+static const char* const CXX_FEATURES[] = { CM_NULLPTR FOR_EACH_CXX_FEATURE(
FEATURE_STRING) };
#undef FEATURE_STRING
@@ -4002,14 +4103,20 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
<< "\"\nversion "
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (error) {
+ *error = e.str();
+ } else {
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->Backtrace);
+ }
return false;
}
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
- return lang == "C" ? this->AddRequiredTargetCFeature(target, feature)
- : this->AddRequiredTargetCxxFeature(target, feature);
+ return lang == "C"
+ ? this->AddRequiredTargetCFeature(target, feature, error)
+ : this->AddRequiredTargetCxxFeature(target, feature, error);
}
bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
@@ -4045,7 +4152,8 @@ bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
if (error) {
*error = e.str();
} else {
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->Backtrace);
}
return false;
}
@@ -4070,9 +4178,10 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang,
if (error) {
*error = e.str();
} else {
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->Backtrace);
}
- return 0;
+ return CM_NULLPTR;
}
return featuresKnown;
}
@@ -4257,7 +4366,8 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature,
}
bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
- const std::string& feature) const
+ const std::string& feature,
+ std::string* error) const
{
bool needCxx98 = false;
bool needCxx11 = false;
@@ -4273,7 +4383,12 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
std::ostringstream e;
e << "The CXX_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCxxStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (error) {
+ *error = e.str();
+ } else {
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->Backtrace);
+ }
return false;
}
}
@@ -4338,7 +4453,8 @@ void cmMakefile::CheckNeededCLanguage(const std::string& feature,
}
bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
- const std::string& feature) const
+ const std::string& feature,
+ std::string* error) const
{
bool needC90 = false;
bool needC99 = false;
@@ -4353,7 +4469,12 @@ bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
std::ostringstream e;
e << "The C_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (error) {
+ *error = e.str();
+ } else {
+ this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->Backtrace);
+ }
return false;
}
}