diff options
Diffstat (limited to 'Source')
44 files changed, 432 insertions, 405 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 59ccf51..8ea5ce5 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 0) -set(CMake_VERSION_PATCH 20140606) +set(CMake_VERSION_PATCH 20140610) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 0113698..a5eee6b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -588,8 +588,8 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, return; } - cmsys::RegularExpression urlRegex; - urlRegex.compile("^(mailto:|(ftps?|https?|news)://).*$"); + static cmsys::RegularExpression + urlRegex("^(mailto:|(ftps?|https?|news)://).*$"); std::vector<std::string>::iterator it; for ( it = cpackMenuLinksVector.begin(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 1d1dde4..f21d166 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -509,7 +509,7 @@ int cmCTestTestHandler::ProcessHandler() if ( val ) { this->UseExcludeLabelRegExpFlag = true; - this->ExcludeLabelRegularExpression = val; + this->ExcludeLabelRegExp = val; } val = this->GetOption("IncludeRegularExpression"); if ( val ) @@ -1558,7 +1558,7 @@ void cmCTestTestHandler::GetListOfTests() this->IncludeLabelRegularExpression. compile(this->IncludeLabelRegExp.c_str()); } - if ( !this->IncludeLabelRegExp.empty() ) + if ( !this->ExcludeLabelRegExp.empty() ) { this->ExcludeLabelRegularExpression. compile(this->ExcludeLabelRegExp.c_str()); diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index a7f6b49..64b67c9 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -137,7 +137,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) this->Makefile->GetHomeOutputDirectory())) { cmOStringStream msg; - cmListFileBacktrace bt; + cmListFileBacktrace bt(this->Makefile->GetLocalGenerator()); cmListFileContext lfc; lfc.FilePath = this->FileName; lfc.Line = this->FileLine; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ea8536f..0ce04a5 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1811,7 +1811,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) } } - is_shared_library = this->ExtractSharedLibraryName.find(file.c_str()); + is_shared_library = this->ExtractSharedLibraryName.find(file); if(!is_shared_library) { @@ -1831,8 +1831,8 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) { if(fullPath.find(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(fullPath) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index eb62455..f28217f 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -386,15 +386,17 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, e << "The dependency target \"" << dependee_name << "\" of target \"" << depender->GetName() << "\" does not exist."; - cmListFileBacktrace nullBacktrace; cmListFileBacktrace const* backtrace = depender->GetUtilityBacktrace(dependee_name); - if(!backtrace) + if(backtrace) { - backtrace = &nullBacktrace; + cm->IssueMessage(messageType, e.str(), *backtrace); + } + else + { + cm->IssueMessage(messageType, e.str()); } - cm->IssueMessage(messageType, e.str(), *backtrace); } } diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index ac2eef8..c161eb6 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -17,6 +17,7 @@ //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand() + : Backtrace(NULL) { this->HaveComment = false; this->EscapeOldStyle = true; @@ -33,7 +34,7 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): WorkingDirectory(r.WorkingDirectory), EscapeAllowMakeVars(r.EscapeAllowMakeVars), EscapeOldStyle(r.EscapeOldStyle), - Backtrace(new cmListFileBacktrace(*r.Backtrace)) + Backtrace(r.Backtrace) { } @@ -54,11 +55,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) this->EscapeAllowMakeVars = r.EscapeAllowMakeVars; this->EscapeOldStyle = r.EscapeOldStyle; this->ImplicitDepends = r.ImplicitDepends; - - cmsys::auto_ptr<cmListFileBacktrace> - newBacktrace(new cmListFileBacktrace(*r.Backtrace)); - delete this->Backtrace; - this->Backtrace = newBacktrace.release(); + this->Backtrace = r.Backtrace; return *this; } @@ -78,20 +75,19 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf, WorkingDirectory(workingDirectory?workingDirectory:""), EscapeAllowMakeVars(false), EscapeOldStyle(true), - Backtrace(new cmListFileBacktrace) + Backtrace(NULL) { this->EscapeOldStyle = true; this->EscapeAllowMakeVars = false; if(mf) { - mf->GetBacktrace(*this->Backtrace); + this->Backtrace = mf->GetBacktrace(); } } //---------------------------------------------------------------------------- cmCustomCommand::~cmCustomCommand() { - delete this->Backtrace; } //---------------------------------------------------------------------------- @@ -166,7 +162,7 @@ void cmCustomCommand::SetEscapeAllowMakeVars(bool b) //---------------------------------------------------------------------------- cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const { - return *this->Backtrace; + return this->Backtrace; } //---------------------------------------------------------------------------- diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index b5d7e62..21dbefb 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -13,8 +13,8 @@ #define cmCustomCommand_h #include "cmStandardIncludes.h" +#include "cmListFileCache.h" class cmMakefile; -class cmListFileBacktrace; /** \class cmCustomCommand * \brief A class to encapsulate a custom command @@ -88,7 +88,7 @@ private: std::string WorkingDirectory; bool EscapeAllowMakeVars; bool EscapeOldStyle; - cmListFileBacktrace* Backtrace; + cmListFileBacktrace Backtrace; ImplicitDependsList ImplicitDepends; }; diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index ebfbf7c..1bca6e6 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -21,7 +21,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator( cmCustomCommand const& cc, const std::string& config, cmMakefile* mf): CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), - GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false) + GE(new cmGeneratorExpression(&cc.GetBacktrace())), DependsDone(false) { } diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6c8ebb6..30a52d4 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -18,6 +18,7 @@ //---------------------------------------------------------------------------- cmExportBuildFileGenerator::cmExportBuildFileGenerator() + : Backtrace(NULL) { this->Makefile = 0; this->ExportSet = 0; diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index c1bdb5b..8b5694c 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -45,7 +45,7 @@ public: void SetMakefile(cmMakefile *mf) { this->Makefile = mf; - this->Makefile->GetBacktrace(this->Backtrace); + this->Backtrace = this->Makefile->GetBacktrace(); } protected: diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 2db4086..9f5eee5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -377,8 +377,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; const char *input = target->GetProperty(propName); - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; std::string dirs = cmGeneratorExpression::Preprocess( tei->InterfaceIncludeDirectories, diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 3350d7c..eb8d193 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -57,10 +57,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets( return std::string(); } - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( tgt->GetName(), propName, 0, 0); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4ee34df..655f3ba 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3270,14 +3270,13 @@ void cmFileCommand::AddEvaluationFile(const std::string &inputName, bool inputIsContent ) { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression outputGe(lfbt); + cmGeneratorExpression outputGe(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge = outputGe.Parse(outputExpr); - cmGeneratorExpression conditionGe(lfbt); + cmGeneratorExpression conditionGe(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge = conditionGe.Parse(condition); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index d53bdd7..2b4d955 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -24,7 +24,7 @@ //---------------------------------------------------------------------------- cmGeneratorExpression::cmGeneratorExpression( - cmListFileBacktrace const& backtrace): + cmListFileBacktrace const* backtrace): Backtrace(backtrace) { } @@ -33,10 +33,18 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(std::string const& input) { +#if !defined(__BORLANDC__) return cmsys::auto_ptr<cmCompiledGeneratorExpression>( - new cmCompiledGeneratorExpression( - this->Backtrace, - input)); + new cmCompiledGeneratorExpression( + this->Backtrace ? *this->Backtrace : cmListFileBacktrace(NULL), + input)); +#else + cmListFileBacktrace emptyBacktrace(NULL); + return cmsys::auto_ptr<cmCompiledGeneratorExpression>( + new cmCompiledGeneratorExpression( + this->Backtrace ? *this->Backtrace : emptyBacktrace, + input)); +#endif } //---------------------------------------------------------------------------- @@ -461,12 +469,11 @@ std::string::size_type cmGeneratorExpression::Find(const std::string &input) //---------------------------------------------------------------------------- bool cmGeneratorExpression::IsValidTargetName(const std::string &input) { - cmsys::RegularExpression targetNameValidator; // The ':' is supported to allow use with IMPORTED targets. At least // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter. - targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$"); + static cmsys::RegularExpression targetNameValidator("^[A-Za-z0-9_.:+-]+$"); - return targetNameValidator.find(input.c_str()); + return targetNameValidator.find(input); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index ef5360e..324d23c 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -41,7 +41,7 @@ class cmGeneratorExpression { public: /** Construct. */ - cmGeneratorExpression(cmListFileBacktrace const& backtrace); + cmGeneratorExpression(cmListFileBacktrace const* backtrace = NULL); ~cmGeneratorExpression(); cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse( @@ -70,7 +70,7 @@ private: cmGeneratorExpression(const cmGeneratorExpression &); void operator=(const cmGeneratorExpression &); - cmListFileBacktrace const& Backtrace; + cmListFileBacktrace const* Backtrace; }; class cmCompiledGeneratorExpression diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 7f8e694..75a84cb 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -24,6 +24,25 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( : Parent(parent), Target(target), Property(property), Content(content), Backtrace(backtrace), TransitivePropertiesOnly(false) { + Initialize(); +} + +//---------------------------------------------------------------------------- +cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( + const std::string &target, + const std::string &property, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *parent) + : Parent(parent), Target(target), Property(property), + Content(content), Backtrace(NULL), TransitivePropertiesOnly(false) +{ + Initialize(); +} + +//---------------------------------------------------------------------------- +void +cmGeneratorExpressionDAGChecker::Initialize() +{ const cmGeneratorExpressionDAGChecker *top = this; const cmGeneratorExpressionDAGChecker *p = this->Parent; while (p) @@ -43,11 +62,12 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( #undef TEST_TRANSITIVE_PROPERTY_METHOD { std::map<std::string, std::set<std::string> >::const_iterator it - = top->Seen.find(target); + = top->Seen.find(this->Target); if (it != top->Seen.end()) { const std::set<std::string> &propSet = it->second; - const std::set<std::string>::const_iterator i = propSet.find(property); + const std::set<std::string>::const_iterator i + = propSet.find(this->Property); if (i != propSet.end()) { this->CheckResult = ALREADY_SEEN; @@ -55,7 +75,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( } } const_cast<cmGeneratorExpressionDAGChecker *>(top) - ->Seen[target].insert(property); + ->Seen[this->Target].insert(this->Property); } } diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 7217a56..10f9fa7 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -46,6 +46,10 @@ struct cmGeneratorExpressionDAGChecker const std::string &property, const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *parent); + cmGeneratorExpressionDAGChecker(const std::string &target, + const std::string &property, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *parent); enum Result { DAG, @@ -76,6 +80,7 @@ struct cmGeneratorExpressionDAGChecker private: Result CheckGraph() const; + void Initialize(); private: const cmGeneratorExpressionDAGChecker * const Parent; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 01d31d3..f9067cf 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -115,7 +115,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() } cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace(); - cmGeneratorExpression contentGE(lfbt); + cmGeneratorExpression contentGE(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression = contentGE.Parse(inputContent); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index a15e3ff..7dcb335 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -401,9 +401,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode { return compilerId ? compilerId : ""; } - cmsys::RegularExpression compilerIdValidator; - compilerIdValidator.compile("^[A-Za-z0-9_]*$"); - if (!compilerIdValidator.find(parameters.begin()->c_str())) + static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$"); + if (!compilerIdValidator.find(*parameters.begin())) { reportError(context, content->GetOriginalExpression(), "Expression syntax not recognized."); @@ -509,9 +508,8 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode return compilerVersion ? compilerVersion : ""; } - cmsys::RegularExpression compilerIdValidator; - compilerIdValidator.compile("^[0-9\\.]*$"); - if (!compilerIdValidator.find(parameters.begin()->c_str())) + static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$"); + if (!compilerIdValidator.find(*parameters.begin())) { reportError(context, content->GetOriginalExpression(), "Expression syntax not recognized."); @@ -711,9 +709,8 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode { return configurationNode.Evaluate(parameters, context, content, 0); } - cmsys::RegularExpression configValidator; - configValidator.compile("^[A-Za-z0-9_]*$"); - if (!configValidator.find(parameters.begin()->c_str())) + static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$"); + if (!configValidator.find(*parameters.begin())) { reportError(context, content->GetOriginalExpression(), "Expression syntax not recognized."); @@ -809,7 +806,7 @@ std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets, cmGeneratorExpressionDAGChecker *dagChecker, const std::string &interfacePropertyName) { - cmGeneratorExpression ge(context->Backtrace); + cmGeneratorExpression ge(&context->Backtrace); std::string sep; std::string depString; @@ -884,8 +881,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "$<TARGET_PROPERTY:...> expression requires one or two parameters"); return std::string(); } - cmsys::RegularExpression propertyNameValidator; - propertyNameValidator.compile("^[A-Za-z0-9_]+$"); + static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$"); cmTarget const* target = context->HeadTarget; std::string propertyName = *parameters.begin(); @@ -973,7 +969,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode return std::string(); } - if (!propertyNameValidator.find(propertyName.c_str())) + if (!propertyNameValidator.find(propertyName)) { ::reportError(context, content->GetOriginalExpression(), "Property name not supported."); @@ -1196,7 +1192,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName) { - cmGeneratorExpression ge(context->Backtrace); + cmGeneratorExpression ge(&context->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); std::string result = cge->Evaluate(context->Makefile, context->Config, diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index eb76d7f..0ffb860 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -22,6 +22,11 @@ class cmTarget; //---------------------------------------------------------------------------- struct cmGeneratorExpressionContext { + cmGeneratorExpressionContext() + : Backtrace(NULL) + { + } + cmListFileBacktrace Backtrace; std::set<cmTarget*> DependTargets; std::set<cmTarget const*> AllTargets; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 153c611..a7576ed 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -259,12 +259,10 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, std::vector<std::string>& result, bool excludeImported) { - cmListFileBacktrace lfbt; - if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(dirs) ->Evaluate(mf, config, false, headTarget, @@ -278,7 +276,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, if (const char* dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(dirs) ->Evaluate(mf, config, false, headTarget, @@ -457,8 +455,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, return false; } - cmListFileBacktrace lfbt; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", 0, 0); @@ -470,7 +467,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, it = this->Target->GetSystemIncludeDirectories().begin(); it != this->Target->GetSystemIncludeDirectories().end(); ++it) { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(*it) ->Evaluate(this->Makefile, config, false, this->Target, @@ -808,7 +805,7 @@ cmTargetTraceDependencies { // Transform command names that reference targets built in this // project to corresponding target-level dependencies. - cmGeneratorExpression ge(cc.GetBacktrace()); + cmGeneratorExpression ge(&cc.GetBacktrace()); // Add target-level dependencies referenced by generator expressions. std::set<cmTarget*> targets; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index bb818eb..6c8be72 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1282,8 +1282,7 @@ void cmGlobalGenerator::Generate() if(!this->GenerateCPackPropertiesFile()) { this->GetCMakeInstance()->IssueMessage( - cmake::FATAL_ERROR, "Could not write CPack properties file.", - cmListFileBacktrace()); + cmake::FATAL_ERROR, "Could not write CPack properties file."); } for (std::map<std::string, cmExportBuildFileGenerator*>::iterator @@ -1294,8 +1293,7 @@ void cmGlobalGenerator::Generate() && !cmSystemTools::GetErrorOccuredFlag()) { this->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.", - cmListFileBacktrace()); + ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file."); return; } } @@ -1324,8 +1322,7 @@ void cmGlobalGenerator::Generate() { w << " " << *iter << "\n"; } - this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - cmListFileBacktrace()); + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); } this->CMakeInstance->UpdateProgress("Generating done", -1); @@ -1525,8 +1522,7 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const if(ti == this->GeneratorTargets.end()) { this->CMakeInstance->IssueMessage( - cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!", - cmListFileBacktrace()); + cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!"); return 0; } return ti->second; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 86d0de3..a6d1c31 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -48,17 +48,19 @@ public: const char* p = cmVS10GenName(name, genName); if(!p) { return 0; } - if(strcmp(p, "") == 0) + if(!*p) { return new cmGlobalVisualStudio10Generator( genName, "", ""); } - if(strcmp(p, " Win64") == 0) + if(*p++ != ' ') + { return 0; } + if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio10Generator( genName, "x64", "CMAKE_FORCE_WIN64"); } - if(strcmp(p, " IA64") == 0) + if(strcmp(p, "IA64") == 0) { return new cmGlobalVisualStudio10Generator( genName, "Itanium", "CMAKE_FORCE_IA64"); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 7033f2a..fa134fc 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -43,27 +43,24 @@ public: const char* p = cmVS11GenName(name, genName); if(!p) { return 0; } - if(strcmp(p, "") == 0) + if(!*p) { return new cmGlobalVisualStudio11Generator( genName, "", ""); } - if(strcmp(p, " Win64") == 0) + if(*p++ != ' ') + { return 0; } + if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio11Generator( genName, "x64", "CMAKE_FORCE_WIN64"); } - if(strcmp(p, " ARM") == 0) + if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio11Generator( genName, "ARM", ""); } - if(*p++ != ' ') - { - return 0; - } - std::set<std::string> installedSDKs = cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 40f8b05..698624d 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -43,17 +43,19 @@ public: const char* p = cmVS12GenName(name, genName); if(!p) { return 0; } - if(strcmp(p, "") == 0) + if(!*p) { return new cmGlobalVisualStudio12Generator( genName, "", ""); } - if(strcmp(p, " Win64") == 0) + if(*p++ != ' ') + { return 0; } + if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio12Generator( genName, "x64", "CMAKE_FORCE_WIN64"); } - if(strcmp(p, " ARM") == 0) + if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio12Generator( genName, "ARM", ""); diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 6594218..b2be82e 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -12,6 +12,7 @@ #include "cmInstallFilesGenerator.h" #include "cmGeneratorExpression.h" +#include "cmMakefile.h" #include "cmSystemTools.h" //---------------------------------------------------------------------------- @@ -84,8 +85,7 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os, Indent const& indent) { std::vector<std::string> files; - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; for(std::vector<std::string>::const_iterator i = this->Files.begin(); i != this->Files.end(); ++i) { diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 7e78ec0..7813fcc 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -32,9 +32,8 @@ cmInstalledFile::~cmInstalledFile() //---------------------------------------------------------------------------- void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name) { - cmListFileBacktrace backtrace; - mf->GetBacktrace(backtrace); - cmGeneratorExpression ge(backtrace); + cmListFileBacktrace backtrace = mf->GetBacktrace(); + cmGeneratorExpression ge(&backtrace); this->Name = name; this->NameExpression = ge.Parse(name).release(); @@ -70,9 +69,8 @@ void cmInstalledFile::SetProperty(cmMakefile const* mf, void cmInstalledFile::AppendProperty(cmMakefile const* mf, const std::string& prop, const char* value, bool /*asString*/) { - cmListFileBacktrace backtrace; - mf->GetBacktrace(backtrace); - cmGeneratorExpression ge(backtrace); + cmListFileBacktrace backtrace = mf->GetBacktrace(); + cmGeneratorExpression ge(&backtrace); Property& property = this->Properties[prop]; property.ValueExpressions.push_back(ge.Parse(value).release()); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 34781d3..705666d 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -12,6 +12,7 @@ #include "cmListFileCache.h" #include "cmListFileLexer.h" +#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmVersion.h" @@ -408,6 +409,23 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, } //---------------------------------------------------------------------------- +void cmListFileBacktrace::MakeRelative() +{ + if (this->Relative) + { + return; + } + for (cmListFileBacktrace::iterator i = this->begin(); + i != this->end(); ++i) + { + i->FilePath = this->LocalGenerator->Convert(i->FilePath, + cmLocalGenerator::HOME); + } + this->Relative = true; +} + + +//---------------------------------------------------------------------------- std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc) { os << lfc.FilePath; diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index bede25e..2ca9b8e 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -14,6 +14,8 @@ #include "cmStandardIncludes.h" +class cmLocalGenerator; + /** \class cmListFileCache * \brief A class to cache list file contents. * @@ -66,7 +68,20 @@ struct cmListFileFunction: public cmListFileContext std::vector<cmListFileArgument> Arguments; }; -class cmListFileBacktrace: public std::vector<cmListFileContext> {}; +class cmListFileBacktrace: public std::vector<cmListFileContext> +{ + public: + cmListFileBacktrace(cmLocalGenerator* localGen) + : LocalGenerator(localGen) + , Relative(localGen ? false : true) + { + } + + void MakeRelative(); + private: + cmLocalGenerator* LocalGenerator; + bool Relative; +}; struct cmListFile { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2620471..630957f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -310,14 +310,19 @@ void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const { // Collect context information. - cmListFileBacktrace backtrace; + cmLocalGenerator* localGen = this->GetLocalGenerator(); + if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile()) + { + localGen = 0; + } + cmListFileBacktrace backtrace(localGen); if(!this->CallStack.empty()) { if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) { this->CallStack.back().Status->SetNestedError(true); } - this->GetBacktrace(backtrace); + backtrace = this->GetBacktrace(); } else { @@ -335,11 +340,6 @@ void cmMakefile::IssueMessage(cmake::MessageType t, lfc.FilePath = this->ListFileStack.back(); } lfc.Line = 0; - if(!this->GetCMakeInstance()->GetIsInTryCompile()) - { - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, - cmLocalGenerator::HOME); - } backtrace.push_back(lfc); } @@ -348,21 +348,15 @@ void cmMakefile::IssueMessage(cmake::MessageType t, } //---------------------------------------------------------------------------- -bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const +cmListFileBacktrace cmMakefile::GetBacktrace() const { - if(this->CallStack.empty()) - { - return false; - } + cmListFileBacktrace backtrace(this->GetLocalGenerator()); for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin(); i != this->CallStack.rend(); ++i) { - cmListFileContext lfc = *(*i).Context; - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, - cmLocalGenerator::HOME); - backtrace.push_back(lfc); + backtrace.push_back(*i->Context); } - return true; + return backtrace; } //---------------------------------------------------------------------------- @@ -1745,8 +1739,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, before ? this->IncludeDirectoriesEntries.begin() : this->IncludeDirectoriesEntries.end(); - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); cmValueWithOrigin entry(incString, lfbt); this->IncludeDirectoriesEntries.insert(position, entry); @@ -1923,7 +1916,7 @@ void cmMakefile::CheckForUnused(const char* reason, if (this->WarnUnused && !this->VariableUsed(name)) { std::string path; - cmListFileBacktrace bt; + cmListFileBacktrace bt(this->GetLocalGenerator()); if (this->CallStack.size()) { const cmListFileContext* file = this->CallStack.back().Context; @@ -2874,7 +2867,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( this->GetHomeOutputDirectory())) { cmOStringStream msg; - cmListFileBacktrace bt; + cmListFileBacktrace bt(this->GetLocalGenerator()); cmListFileContext lfc; lfc.FilePath = filename; lfc.Line = line; @@ -4013,8 +4006,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) { return; } - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); this->IncludeDirectoriesEntries.push_back( cmValueWithOrigin(value, lfbt)); return; @@ -4026,8 +4018,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) { return; } - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); return; } @@ -4038,8 +4029,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) { return; } - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); cmValueWithOrigin entry(value, lfbt); this->CompileDefinitionsEntries.push_back(entry); return; @@ -4070,24 +4060,21 @@ void cmMakefile::AppendProperty(const std::string& prop, { if (prop == "INCLUDE_DIRECTORIES") { - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); this->IncludeDirectoriesEntries.push_back( cmValueWithOrigin(value, lfbt)); return; } if (prop == "COMPILE_OPTIONS") { - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); this->CompileOptionsEntries.push_back( cmValueWithOrigin(value, lfbt)); return; } if (prop == "COMPILE_DEFINITIONS") { - cmListFileBacktrace lfbt; - this->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->GetBacktrace(); this->CompileDefinitionsEntries.push_back( cmValueWithOrigin(value, lfbt)); return; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e3b83af..d5ffd98 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -655,7 +655,7 @@ public: /** * Get the current context backtrace. */ - bool GetBacktrace(cmListFileBacktrace& backtrace) const; + cmListFileBacktrace GetBacktrace() const; /** * Get the vector of files created by this makefile diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 85017ad..403f6e6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -137,8 +137,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->Makefile->GetProperty ("ADDITIONAL_MAKE_CLEAN_FILES")) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(additional_clean_files); diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index ec671fc..71a3497 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -39,8 +39,8 @@ public: if(file.rfind(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(file) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) @@ -326,8 +326,8 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath, if(fullPath.rfind(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(fullPath) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8143556..01edde9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -87,10 +87,12 @@ class cmTargetInternals { public: cmTargetInternals() + : Backtrace(NULL) { this->PolicyWarnedCMP0022 = false; } cmTargetInternals(cmTargetInternals const&) + : Backtrace(NULL) { this->PolicyWarnedCMP0022 = false; } @@ -366,7 +368,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } // Save the backtrace of target construction. - this->Makefile->GetBacktrace(this->Internal->Backtrace); + this->Internal->Backtrace = this->Makefile->GetBacktrace(); if (!this->IsImported()) { @@ -443,7 +445,7 @@ void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { if(this->Utilities.insert(u).second && makefile) { - makefile->GetBacktrace(UtilityBacktraces[u]); + UtilityBacktraces.insert(std::make_pair(u, makefile->GetBacktrace())); } } @@ -710,11 +712,8 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files, this->DebugSourcesDone = true; } - cmListFileBacktrace lfbt; - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "SOURCES", 0, 0); + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "SOURCES", 0, 0); std::set<std::string> uniqueSrcs; bool contextDependentDirectSources = processSources(this, @@ -739,7 +738,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files, continue; } { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, @@ -758,7 +757,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files, // TARGET_PROPERTY expression. sourceGenex = "$<$<BOOL:" + it->Value + ">:" + sourceGenex + ">"; } - cmGeneratorExpression ge(it->Backtrace); + cmGeneratorExpression ge(&it->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( sourceGenex); @@ -910,9 +909,8 @@ void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) { this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); cge->SetEvaluateForBuildsystem(true); this->Internal->SourceEntries.push_back( @@ -948,9 +946,8 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs) { this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); cge->SetEvaluateForBuildsystem(true); this->Internal->SourceEntries.push_back( @@ -1084,9 +1081,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) { this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); this->Internal->SourceEntries.push_back( @@ -1206,11 +1202,10 @@ void cmTarget::GetDirectLinkLibraries(const std::string& config, const char *prop = this->GetProperty("LINK_LIBRARIES"); if (prop) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "LINK_LIBRARIES", 0, 0); cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, @@ -1241,11 +1236,10 @@ void cmTarget::GetInterfaceLinkLibraries(const std::string& config, const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "INTERFACE_LINK_LIBRARIES", 0, 0); cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, @@ -1306,8 +1300,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature) ret = false; } } - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->TLLCommands.push_back(std::make_pair(signature, lfbt)); return ret; } @@ -1333,9 +1326,10 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; std::set<std::string> emitted; - for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin(); + for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin(); it != sigs.end(); ++it) { + it->MakeRelative(); cmListFileBacktrace::const_iterator i = it->begin(); if(i != it->end()) { @@ -1796,9 +1790,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } if(prop == "INCLUDE_DIRECTORIES") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); deleteAndClear(this->Internal->IncludeDirectoriesEntries); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->IncludeDirectoriesEntries.push_back( @@ -1807,9 +1800,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } if(prop == "COMPILE_OPTIONS") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); deleteAndClear(this->Internal->CompileOptionsEntries); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileOptionsEntries.push_back( @@ -1818,9 +1810,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } if(prop == "COMPILE_FEATURES") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); deleteAndClear(this->Internal->CompileFeaturesEntries); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileFeaturesEntries.push_back( @@ -1829,9 +1820,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } if(prop == "COMPILE_DEFINITIONS") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); deleteAndClear(this->Internal->CompileDefinitionsEntries); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileDefinitionsEntries.push_back( @@ -1849,8 +1839,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(value, lfbt); this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; @@ -1866,9 +1855,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) return; } this->Internal->SourceFilesMap.clear(); - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); this->Internal->SourceEntries.clear(); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->SourceEntries.push_back( @@ -1901,36 +1889,32 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } if(prop == "INCLUDE_DIRECTORIES") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); this->Internal->IncludeDirectoriesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } if(prop == "COMPILE_OPTIONS") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); this->Internal->CompileOptionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } if(prop == "COMPILE_FEATURES") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); this->Internal->CompileFeaturesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } if(prop == "COMPILE_DEFINITIONS") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); this->Internal->CompileDefinitionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; @@ -1945,8 +1929,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } if (prop == "LINK_LIBRARIES") { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(value, lfbt); this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; @@ -1962,9 +1945,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, return; } this->Internal->SourceFilesMap.clear(); - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmGeneratorExpression ge(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(&lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->SourceEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); @@ -2030,7 +2012,7 @@ void cmTarget::AppendBuildInterfaceIncludes() void cmTarget::InsertInclude(const cmValueWithOrigin &entry, bool before) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(&entry.Backtrace); std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position = before ? this->Internal->IncludeDirectoriesEntries.begin() @@ -2044,7 +2026,7 @@ void cmTarget::InsertInclude(const cmValueWithOrigin &entry, void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, bool before) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(&entry.Backtrace); std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position = before ? this->Internal->CompileOptionsEntries.begin() @@ -2057,7 +2039,7 @@ void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, //---------------------------------------------------------------------------- void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(&entry.Backtrace); this->Internal->CompileDefinitionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); @@ -2098,14 +2080,13 @@ static void processIncludeDirectories(cmTarget const* tgt, } } std::string usedIncludes; - cmListFileBacktrace lfbt; for(std::vector<std::string>::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { std::string targetName = (*it)->TargetName; std::string evaluatedTargetName; { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(targetName); evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); @@ -2238,10 +2219,8 @@ cmTarget::GetIncludeDirectories(const std::string& config) const { std::vector<std::string> includes; std::set<std::string> uniqueIncludes; - cmListFileBacktrace lfbt; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "INCLUDE_DIRECTORIES", 0, 0); std::vector<std::string> debugProperties; @@ -2284,7 +2263,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const continue; } { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(it->Value); std::string result = cge->Evaluate(this->Makefile, config, @@ -2303,7 +2282,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const // TARGET_PROPERTY expression. includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">"; } - cmGeneratorExpression ge(it->Backtrace); + cmGeneratorExpression ge(&it->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( includeGenex); @@ -2332,7 +2311,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const libDir = frameworkCheck.match(1); - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(libDir.c_str()); this->Internal @@ -2446,10 +2425,9 @@ void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, { return; } - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "AUTOUIC_OPTIONS", 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(prop) @@ -2466,11 +2444,9 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, const std::string& config) const { std::set<std::string> uniqueOptions; - cmListFileBacktrace lfbt; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "COMPILE_OPTIONS", 0, 0); + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); std::vector<std::string> debugProperties; const char *debugProp = @@ -2512,7 +2488,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, continue; } { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, @@ -2531,7 +2507,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, // TARGET_PROPERTY expression. optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">"; } - cmGeneratorExpression ge(it->Backtrace); + cmGeneratorExpression ge(&it->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( optionGenex); @@ -2578,11 +2554,9 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, const std::string& config) const { std::set<std::string> uniqueOptions; - cmListFileBacktrace lfbt; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); std::vector<std::string> debugProperties; const char *debugProp = @@ -2624,7 +2598,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, continue; } { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, @@ -2643,7 +2617,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, // TARGET_PROPERTY expression. defsGenex = "$<$<BOOL:" + it->Value + ">:" + defsGenex + ">"; } - cmGeneratorExpression ge(it->Backtrace); + cmGeneratorExpression ge(&it->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( defsGenex); @@ -2671,7 +2645,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, } case cmPolicies::OLD: { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(configProp); this->Internal @@ -2726,10 +2700,8 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result, const std::string& config) const { std::set<std::string> uniqueFeatures; - cmListFileBacktrace lfbt; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "COMPILE_FEATURES", 0, 0); @@ -2773,7 +2745,7 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result, continue; } { - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, @@ -2792,7 +2764,7 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result, // TARGET_PROPERTY expression. featureGenex = "$<$<BOOL:" + it->Value + ">:" + featureGenex + ">"; } - cmGeneratorExpression ge(it->Backtrace); + cmGeneratorExpression ge(&it->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( featureGenex); @@ -5184,8 +5156,7 @@ cmTarget::ReportPropertyOrigin(const std::string &p, areport += result; areport += "\"):\n" + report; - cmListFileBacktrace lfbt; - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport, lfbt); + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } //---------------------------------------------------------------------------- @@ -5922,10 +5893,9 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } if(propertyLibs) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(lfbt, + cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), linkProp, 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) @@ -6176,7 +6146,6 @@ void processILibs(const std::string& config, if (emitted.insert(tgt).second) { tgts.push_back(tgt); - std::vector<std::string> ilibs; cmTarget::LinkInterface const* iface = tgt->GetLinkInterfaceLibraries(config, headTarget); if (iface) @@ -6245,10 +6214,9 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, } // The interface libraries have been explicitly set. - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), - linkIfaceProp, 0, 0); + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + linkIfaceProp, 0, 0); dagChecker.SetTransitivePropertiesOnly(); std::vector<std::string> libs; cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate( @@ -6357,9 +6325,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, if(explicitLibraries) { // The interface libraries have been explicitly set. - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), linkIfaceProp, 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(explicitLibraries)->Evaluate( this->Makefile, @@ -6384,9 +6351,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "INTERFACE_LINK_LIBRARIES", 0, 0); std::vector<std::string> ifaceLibs; const char* newExplicitLibraries = diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index 18499fd..3fb76a6 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -55,8 +55,7 @@ bool cmTargetCompileOptionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, bool, bool) { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertCompileOption(entry); return true; diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index caec7eb..e9f0e04 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -70,8 +70,7 @@ bool cmTargetIncludeDirectoriesCommand ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, bool prepend, bool system) { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(entry, prepend); if (system) diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 28a7bb1..ff5d411 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -17,24 +17,22 @@ //---------------------------------------------------------------------------- cmTest::cmTest(cmMakefile* mf) + : Backtrace(mf->GetBacktrace()) { this->Makefile = mf; this->OldStyle = true; this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); - this->Backtrace = new cmListFileBacktrace; - this->Makefile->GetBacktrace(*this->Backtrace); } //---------------------------------------------------------------------------- cmTest::~cmTest() { - delete this->Backtrace; } //---------------------------------------------------------------------------- cmListFileBacktrace const& cmTest::GetBacktrace() const { - return *this->Backtrace; + return this->Backtrace; } //---------------------------------------------------------------------------- diff --git a/Source/cmTest.h b/Source/cmTest.h index a93eff5..c6e7e42 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -14,8 +14,8 @@ #include "cmCustomCommand.h" #include "cmPropertyMap.h" +#include "cmListFileCache.h" class cmMakefile; -class cmListFileBacktrace; /** \class cmTest * \brief Represent a test @@ -71,7 +71,7 @@ private: bool OldStyle; cmMakefile* Makefile; - cmListFileBacktrace* Backtrace; + cmListFileBacktrace Backtrace; }; #endif diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index c1b1f8b..f87a535 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -70,7 +70,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, this->TestGenerated = true; // Set up generator expression evaluation context. - cmGeneratorExpression ge(this->Test->GetBacktrace()); + cmGeneratorExpression ge(&this->Test->GetBacktrace()); // Start the test command. os << indent << "add_test(" << this->Test->GetName() << " "; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 72bb020..acf3930 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -32,34 +32,37 @@ #include <cmsys/auto_ptr.hxx> -static cmVS7FlagTable const* -cmVSGetCLFlagTable(cmLocalVisualStudioGenerator* lg) +cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const { - if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12) + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS12) { return cmVS12CLFlagTable; } - else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11) + else if(v == cmLocalVisualStudioGenerator::VS11) { return cmVS11CLFlagTable; } else { return cmVS10CLFlagTable; } } -static cmVS7FlagTable const* -cmVSGetLibFlagTable(cmLocalVisualStudioGenerator* lg) +cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const { - if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12) + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS12) { return cmVS12LibFlagTable; } - else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11) + else if(v == cmLocalVisualStudioGenerator::VS11) { return cmVS11LibFlagTable; } else { return cmVS10LibFlagTable; } } -static cmVS7FlagTable const* -cmVSGetLinkFlagTable(cmLocalVisualStudioGenerator* lg) +cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const { - if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12) + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS12) { return cmVS12LinkFlagTable; } - else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11) + else if(v == cmLocalVisualStudioGenerator::VS11) { return cmVS11LinkFlagTable; } else { return cmVS10LinkFlagTable; } @@ -464,8 +467,6 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() { - cmGlobalVisualStudio10Generator* gg = - static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *> (this->GlobalGenerator)->GetConfigurations(); @@ -500,52 +501,61 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); - const char* mfcFlag = - this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG"); - std::string mfcFlagValue = mfcFlag ? mfcFlag : "0"; + this->WriteMSToolConfigurationValues(*i); - std::string useOfMfcValue = "false"; - if(mfcFlagValue == "1") - { - useOfMfcValue = "Static"; - } - else if(mfcFlagValue == "2") - { - useOfMfcValue = "Dynamic"; - } - std::string mfcLine = "<UseOfMfc>"; - mfcLine += useOfMfcValue + "</UseOfMfc>\n"; - this->WriteString(mfcLine.c_str(), 2); + this->WriteString("</PropertyGroup>\n", 1); + } +} - if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && - this->ClOptions[*i]->UsingUnicode()) || - this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) - { - this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); - } - else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY && - this->ClOptions[*i]->UsingSBCS()) - { - this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2); - } - else - { - this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2); - } - if(const char* toolset = gg->GetPlatformToolset()) - { - std::string pts = "<PlatformToolset>"; - pts += toolset; - pts += "</PlatformToolset>\n"; - this->WriteString(pts.c_str(), 2); - } - if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) - { - this->WriteString("<WindowsAppContainer>true" - "</WindowsAppContainer>\n", 2); - } +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator +::WriteMSToolConfigurationValues(std::string const& config) +{ + cmGlobalVisualStudio10Generator* gg = + static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); + const char* mfcFlag = + this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG"); + std::string mfcFlagValue = mfcFlag ? mfcFlag : "0"; - this->WriteString("</PropertyGroup>\n", 1); + std::string useOfMfcValue = "false"; + if(mfcFlagValue == "1") + { + useOfMfcValue = "Static"; + } + else if(mfcFlagValue == "2") + { + useOfMfcValue = "Dynamic"; + } + std::string mfcLine = "<UseOfMfc>"; + mfcLine += useOfMfcValue + "</UseOfMfc>\n"; + this->WriteString(mfcLine.c_str(), 2); + + if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && + this->ClOptions[config]->UsingUnicode()) || + this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + { + this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); + } + else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY && + this->ClOptions[config]->UsingSBCS()) + { + this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2); + } + else + { + this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2); + } + if(const char* toolset = gg->GetPlatformToolset()) + { + std::string pts = "<PlatformToolset>"; + pts += toolset; + pts += "</PlatformToolset>\n"; + this->WriteString(pts.c_str(), 2); + } + if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + { + this->WriteString("<WindowsAppContainer>true" + "</WindowsAppContainer>\n", 2); } } @@ -1144,17 +1154,18 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } // if the source file does not match the linker language // then force c or c++ + const char* compileAs = 0; if(needForceLang || (linkLanguage != lang)) { if(lang == "CXX") { // force a C++ file type - flags += " /TP "; + compileAs = "CompileAsCpp"; } else if(lang == "C") { // force to c - flags += " /TC "; + compileAs = "CompileAsC"; } } bool hasFlags = false; @@ -1190,7 +1201,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } // if we have flags or defines for this config then // use them - if(flags.size() || configDefines.size()) + if(!flags.empty() || !configDefines.empty() || compileAs) { (*this->BuildFileStream ) << firstString; firstString = ""; // only do firstString once @@ -1198,7 +1209,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmVisualStudioGeneratorOptions clOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler, - cmVSGetCLFlagTable(this->LocalGenerator), 0, this); + this->GetClFlagTable(), 0, this); + if(compileAs) + { + clOptions.AddFlag("CompileAs", compileAs); + } clOptions.Parse(flags.c_str()); clOptions.AddDefines(configDefines.c_str()); clOptions.SetConfiguration((*config).c_str()); @@ -1260,23 +1275,28 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() this->ConvertToWindowsSlash(outDir); this->WritePlatformConfigTag("OutDir", config->c_str(), 3); - *this->BuildFileStream << outDir + *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n"; this->WritePlatformConfigTag("IntDir", config->c_str(), 3); - *this->BuildFileStream << intermediateDir + *this->BuildFileStream << cmVS10EscapeXML(intermediateDir) << "</IntDir>\n"; + std::string name = + cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); this->WritePlatformConfigTag("TargetName", config->c_str(), 3); - *this->BuildFileStream - << cmSystemTools::GetFilenameWithoutLastExtension( - targetNameFull.c_str()) - << "</TargetName>\n"; + *this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n"; + std::string ext = + cmSystemTools::GetFilenameLastExtension(targetNameFull); + if(ext.empty()) + { + // An empty TargetExt causes a default extension to be used. + // A single "." appears to be treated as an empty extension. + ext = "."; + } this->WritePlatformConfigTag("TargetExt", config->c_str(), 3); - *this->BuildFileStream - << cmSystemTools::GetFilenameLastExtension(targetNameFull.c_str()) - << "</TargetExt>\n"; + *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n"; this->OutputLinkIncremental(*config); } @@ -1355,48 +1375,44 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( cmsys::auto_ptr<Options> pOptions( new Options(this->LocalGenerator, Options::Compiler, - cmVSGetCLFlagTable(this->LocalGenerator))); + this->GetClFlagTable())); Options& clOptions = *pOptions; std::string flags; - // collect up flags for - if(this->Target->GetType() < cmTarget::UTILITY) + const std::string& linkLanguage = + this->Target->GetLinkerLanguage(configName.c_str()); + if(linkLanguage.empty()) { - const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - this->Name.c_str()); - return false; - } - if(linkLanguage == "C" || linkLanguage == "CXX" - || linkLanguage == "Fortran") - { - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += linkLanguage; - baseFlagVar += "_FLAGS"; - flags = this-> - Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); - std::string flagVar = baseFlagVar + std::string("_") + - cmSystemTools::UpperCase(configName); - flags += " "; - flags += this-> - Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); - } - // set the correct language - if(linkLanguage == "C") - { - flags += " /TC "; - } - if(linkLanguage == "CXX") - { - flags += " /TP "; - } - this->LocalGenerator->AddCompileOptions(flags, this->Target, - linkLanguage, configName.c_str()); + cmSystemTools::Error + ("CMake can not determine linker language for target: ", + this->Name.c_str()); + return false; + } + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") + { + std::string baseFlagVar = "CMAKE_"; + baseFlagVar += linkLanguage; + baseFlagVar += "_FLAGS"; + flags = this-> + Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); + std::string flagVar = baseFlagVar + std::string("_") + + cmSystemTools::UpperCase(configName); + flags += " "; + flags += this-> + Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); + } + // set the correct language + if(linkLanguage == "C") + { + clOptions.AddFlag("CompileAs", "CompileAsC"); } + if(linkLanguage == "CXX") + { + clOptions.AddFlag("CompileAs", "CompileAsCpp"); + } + this->LocalGenerator->AddCompileOptions(flags, this->Target, + linkLanguage, configName.c_str()); // Get preprocessor definitions for this directory. std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags(); @@ -1436,6 +1452,10 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->OutputIncludes(includes); clOptions.OutputFlagMap(*this->BuildFileStream, " "); + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + "\n", "CXX"); + + this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); // If not in debug mode, write the DebugInformationFormat field // without value so PDBs don't get generated uselessly. @@ -1445,10 +1465,6 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( "</DebugInformationFormat>\n", 3); } - clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - "\n", "CXX"); - this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); - // Specify the compiler program database file if configured. std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) @@ -1508,7 +1524,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) cmVisualStudioGeneratorOptions libOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, - cmVSGetLibFlagTable(this->LocalGenerator), 0, this); + this->GetLibFlagTable(), 0, this); libOptions.Parse(libflags.c_str()); libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); libOptions.OutputFlagMap(*this->BuildFileStream, " "); @@ -1543,7 +1559,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { cmsys::auto_ptr<Options> pOptions( new Options(this->LocalGenerator, Options::Linker, - cmVSGetLinkFlagTable(this->LocalGenerator), 0, this)); + this->GetLinkFlagTable(), 0, this)); Options& linkOptions = *pOptions; const std::string& linkLanguage = @@ -1567,16 +1583,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { linkType = "EXE"; } - std::string stackVar = "CMAKE_"; - stackVar += linkLanguage; - stackVar += "_STACK_SIZE"; - const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str()); std::string flags; - if(stackVal) - { - flags += " /STACK:"; - flags += stackVal; - } std::string linkFlagVarBase = "CMAKE_"; linkFlagVarBase += linkType; linkFlagVarBase += "_LINKER_FLAGS"; @@ -1600,14 +1607,6 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) flags += " "; flags += flagsConfig; } - if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) - { - linkOptions.AddFlag("SubSystem", "Windows"); - } - else - { - linkOptions.AddFlag("SubSystem", "Console"); - } std::string standardLibsVar = "CMAKE_"; standardLibsVar += linkLanguage; standardLibsVar += "_STANDARD_LIBRARIES"; @@ -1661,15 +1660,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkDirs += "%(AdditionalLibraryDirectories)"; linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str()); linkOptions.AddFlag("AdditionalDependencies", libs.c_str()); - linkOptions.AddFlag("Version", ""); - if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) - { - linkOptions.AddFlag("GenerateDebugInformation", "true"); - } - else - { - linkOptions.AddFlag("GenerateDebugInformation", "false"); - } + std::string targetName; std::string targetNameSO; std::string targetNameFull; @@ -1688,6 +1679,31 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) config.c_str()); } + linkOptions.AddFlag("Version", ""); + + if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) + { + linkOptions.AddFlag("SubSystem", "Windows"); + } + else + { + linkOptions.AddFlag("SubSystem", "Console"); + } + + if(const char* stackVal = + this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE")) + { + linkOptions.AddFlag("StackReserveSize", stackVal); + } + + if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) + { + linkOptions.AddFlag("GenerateDebugInformation", "true"); + } + else + { + linkOptions.AddFlag("GenerateDebugInformation", "false"); + } std::string pdb = this->Target->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d72c6fd..8f2faca 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -23,6 +23,7 @@ class cmCustomCommand; class cmLocalVisualStudio7Generator; class cmComputeLinkInformation; class cmVisualStudioGeneratorOptions; +struct cmIDEFlagTable; #include "cmSourceGroup.h" class cmVisualStudio10TargetGenerator @@ -55,6 +56,7 @@ private: void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); + void WriteMSToolConfigurationValues(std::string const& config); void WriteSource(const char* tool, cmSourceFile const* sf, const char* end = 0); void WriteSources(const char* tool, @@ -98,6 +100,10 @@ private: const std::vector<cmSourceGroup>& allGroups); bool IsResxHeader(const std::string& headerFile); + cmIDEFlagTable const* GetClFlagTable() const; + cmIDEFlagTable const* GetLibFlagTable() const; + cmIDEFlagTable const* GetLinkFlagTable() const; + private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map<std::string, Options*> OptionsMap; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 16dc724..e3bebbd 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2562,8 +2562,11 @@ static bool cmakeCheckStampList(const char* stampList) //---------------------------------------------------------------------------- void cmake::IssueMessage(cmake::MessageType t, std::string const& text, - cmListFileBacktrace const& backtrace) + cmListFileBacktrace const& bt) { + cmListFileBacktrace backtrace = bt; + backtrace.MakeRelative(); + cmOStringStream msg; bool isError = false; // Construct the message header. @@ -2786,7 +2789,7 @@ void cmake::RunCheckForUnusedVariables() } if(haveUnused) { - this->IssueMessage(cmake::WARNING, msg.str(), cmListFileBacktrace()); + this->IssueMessage(cmake::WARNING, msg.str()); } #endif } diff --git a/Source/cmake.h b/Source/cmake.h index 329b439..2d04902 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -13,6 +13,7 @@ #ifndef cmake_h #define cmake_h +#include "cmListFileCache.h" #include "cmSystemTools.h" #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" @@ -29,7 +30,6 @@ class cmFileTimeComparison; class cmExternalMakefileProjectGenerator; class cmDocumentationSection; class cmPolicies; -class cmListFileBacktrace; class cmTarget; class cmGeneratedFileStream; @@ -360,7 +360,7 @@ class cmake /** Display a message to the user. */ void IssueMessage(cmake::MessageType t, std::string const& text, - cmListFileBacktrace const& backtrace); + cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL)); ///! run the --build option int Build(const std::string& dir, const std::string& target, |