diff options
author | Morné Chamberlain <thefreeman.za@gmail.com> | 2012-10-17 21:29:53 (GMT) |
---|---|---|
committer | Morné Chamberlain <thefreeman.za@gmail.com> | 2012-10-17 21:29:53 (GMT) |
commit | d022d4ec78bcb0d3be93479b514f5275703d9a30 (patch) | |
tree | c2353ce4b5416bf60321485050dda7e4c56a4ff9 /Source | |
parent | 9cd3e7071f1769eb6bd751a501d36c6130019a1a (diff) | |
parent | 7ded904329635b490467ddf06d87b2620da470aa (diff) | |
download | CMake-d022d4ec78bcb0d3be93479b514f5275703d9a30.zip CMake-d022d4ec78bcb0d3be93479b514f5275703d9a30.tar.gz CMake-d022d4ec78bcb0d3be93479b514f5275703d9a30.tar.bz2 |
Merge branch 'master' into sublime-text-2-generator
Diffstat (limited to 'Source')
25 files changed, 316 insertions, 139 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d38d0f2..6a0145b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 9) -set(CMake_VERSION_TWEAK 20121012) +set(CMake_VERSION_TWEAK 20121017) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDocumentVariables.cxx b/Source/CPack/cmCPackDocumentVariables.cxx index 7fa401c..6a841fa 100644 --- a/Source/CPack/cmCPackDocumentVariables.cxx +++ b/Source/CPack/cmCPackDocumentVariables.cxx @@ -31,15 +31,25 @@ void cmCPackDocumentVariables::DefineVariables(cmake* cm) "Each CPack generator as a built-in default value for this" " variable. E.g. Archive generators (ZIP, TGZ, ...) includes" " the top level whereas RPM or DEB don't. The user may override" - " the default value byt setting this variable.\n" + " the default value by setting this variable.\n" "There is a similar variable " - "CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY" + "CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY " "which may be used to override the behavior for the component" - "packaging case which may have different default value for" - "historical (now backward compatibility) reason.", false, + " packaging case which may have different default value for" + " historical (now backward compatibility) reason.", false, "Variables common to all CPack generators"); cm->DefineProperty + ("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY", cmProperty::VARIABLE, + "Boolean toggle to include/exclude top level directory " + "(component case).", + "Similar usage as CPACK_INCLUDE_TOPLEVEL_DIRECTORY" + " but for the component case. " + "See CPACK_INCLUDE_TOPLEVEL_DIRECTORY documentation for" + " the detail.", false, + "Variables common to all CPack generators"); + + cm->DefineProperty ("CPACK_SET_DESTDIR", cmProperty::VARIABLE, "Boolean toggle to make CPack use DESTDIR mechanism when" " packaging.", "DESTDIR means DESTination DIRectory." diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index f113400..e964696 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -855,7 +855,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION // then forward request to cmake_install.cmake script - if (this->GetOption("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) + if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) { mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); @@ -865,7 +865,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // then ask cmake_install.cmake script to error out // as soon as it occurs (before installing file) if (!SupportsAbsoluteDestination() || - this->GetOption("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) + this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) { mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); @@ -905,7 +905,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( localFileName = cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); localFileName = - localFileName.substr(localFileName.find('/')+1, + localFileName.substr(localFileName.find_first_not_of('/'), std::string::npos); Components[installComponent].Files.push_back(localFileName); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index a2a16d3..80218ad 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -247,7 +247,8 @@ void cmCTestMemCheckHandler::GenerateTestCommand( { std::vector<cmStdString>::size_type pp; std::string memcheckcommand = ""; - memcheckcommand = this->MemoryTester; + memcheckcommand + = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { args.push_back(this->MemoryTesterOptions[pp]); @@ -410,29 +411,46 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "MemoryCheckCommand").c_str()); + = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str(); + + // determine the checker type + if ( this->MemoryTester.find("valgrind") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; + } + else if ( this->MemoryTester.find("purify") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; + } + else if ( this->MemoryTester.find("BC") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; + } + else + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN; + } } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "PurifyCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "PurifyCommand").c_str()); + = this->CTest->GetCTestConfiguration("PurifyCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "ValgrindCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "ValgrindCommand").c_str()); + = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "BoundsCheckerCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "BoundsCheckerCommand").c_str()); + = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; } else { @@ -470,82 +488,81 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; - if ( this->MemoryTester.find("valgrind") != std::string::npos ) + switch ( this->MemoryTesterStyle ) { - this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; - if ( this->MemoryTesterOptions.empty() ) - { - this->MemoryTesterOptions.push_back("-q"); - this->MemoryTesterOptions.push_back("--tool=memcheck"); - this->MemoryTesterOptions.push_back("--leak-check=yes"); - this->MemoryTesterOptions.push_back("--show-reachable=yes"); - this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); - this->MemoryTesterOptions.push_back("--num-callers=50"); - } - if ( this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").size() ) - { - if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) ) + case cmCTestMemCheckHandler::VALGRIND: + if ( this->MemoryTesterOptions.empty() ) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot find memory checker suppression file: " - << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); - return false; - } - std::string suppressions = "--suppressions=" - + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); - this->MemoryTesterOptions.push_back(suppressions); - } - } - else if ( this->MemoryTester.find("purify") != std::string::npos ) - { - this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; - std::string outputFile; -#ifdef _WIN32 - if( this->CTest->GetCTestConfiguration( + this->MemoryTesterOptions.push_back("-q"); + this->MemoryTesterOptions.push_back("--tool=memcheck"); + this->MemoryTesterOptions.push_back("--leak-check=yes"); + this->MemoryTesterOptions.push_back("--show-reachable=yes"); + this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); + this->MemoryTesterOptions.push_back("--num-callers=50"); + } + if ( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) + { + if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); + return false; + } + std::string suppressions = "--suppressions=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(suppressions); + } + break; + case cmCTestMemCheckHandler::PURIFY: { - if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) ) + std::string outputFile; +#ifdef _WIN32 + if( this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").size() ) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot find memory checker suppression file: " - << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); - return false; - } - std::string filterFiles = "/FilterFiles=" - + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); - this->MemoryTesterOptions.push_back(filterFiles); - } - outputFile = "/SAVETEXTDATA="; + if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); + return false; + } + std::string filterFiles = "/FilterFiles=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(filterFiles); + } + outputFile = "/SAVETEXTDATA="; #else - outputFile = "-log-file="; + outputFile = "-log-file="; #endif - outputFile += this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); - } - else if ( this->MemoryTester.find("BC") != std::string::npos ) - { - this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; - std::string dpbdFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.DPbd"; - this->BoundsCheckerDPBDFile = dpbdFile; - this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; - this->MemoryTesterOptions.push_back("/B"); - this->MemoryTesterOptions.push_back(dpbdFile); - this->MemoryTesterOptions.push_back("/X"); - this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); - this->MemoryTesterOptions.push_back("/M"); - } - else - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Do not understand memory checker: " << this->MemoryTester.c_str() - << std::endl); - return false; + outputFile += this->MemoryTesterOutputFile; + this->MemoryTesterOptions.push_back(outputFile); + break; + } + case cmCTestMemCheckHandler::BOUNDS_CHECKER: + { + this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; + std::string dpbdFile = this->CTest->GetBinaryDir() + + "/Testing/Temporary/MemoryChecker.DPbd"; + this->BoundsCheckerDPBDFile = dpbdFile; + this->MemoryTesterOptions.push_back("/B"); + this->MemoryTesterOptions.push_back(dpbdFile); + this->MemoryTesterOptions.push_back("/X"); + this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterOptions.push_back("/M"); + break; + } + default: + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Do not understand memory checker: " << this->MemoryTester.c_str() + << std::endl); + return false; } std::vector<cmStdString>::size_type cc; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index ead449e..b796b83 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1304,9 +1304,10 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it + std::string cmd = cmSystemTools::ConvertToOutputPath(it->c_str()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << cmd << std::endl); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, + if ( !cmSystemTools::RunSingleCommand(cmd.c_str(), 0, &retVal, 0, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0 ) { diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 8b2daba..25b13e5 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -623,7 +623,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::string cdefs = gtgt->GetCompileDefinitions(); - if(cdefs.empty()) + if(!cdefs.empty()) { // Expand the list. std::vector<std::string> defs; @@ -640,8 +640,10 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::set<std::string> uniqIncludeDirs; std::vector<std::string> includes; + const char *config = target->GetMakefile() + ->GetDefinition("CMAKE_BUILD_TYPE"); target->GetMakefile()->GetLocalGenerator()-> - GetIncludeDirectories(includes, gtgt); + GetIncludeDirectories(includes, gtgt, "C", config); for(std::vector<std::string>::const_iterator dirIt=includes.begin(); dirIt != includes.end(); ++dirIt) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index f1d9c31..689f213 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -890,7 +890,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const l != targets.end(); ++l) { std::vector<std::string> includeDirs; - (*it)->GetIncludeDirectories(includeDirs, l->second); + const char *config = mf->GetDefinition("CMAKE_BUILD_TYPE"); + (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); this->AppendIncludeDirectories(fout, includeDirs, emmited); } } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 3f8e962..7d8df37 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -13,6 +13,7 @@ #include "cmMakefile.h" #include "cmTarget.h" +#include "assert.h" #include <cmsys/String.h> @@ -129,3 +130,51 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() delete *it; } } + +std::string cmGeneratorExpression::Preprocess(const std::string &input, + PreprocessContext context) +{ + if (context != StripAllGeneratorExpressions) + { + assert(!"cmGeneratorExpression::Preprocess called with invalid args"); + return std::string(); + } + + std::string result; + std::string::size_type pos = 0; + std::string::size_type lastPos = pos; + while((pos = input.find("$<", lastPos)) != input.npos) + { + result += input.substr(lastPos, pos - lastPos); + pos += 2; + int nestingLevel = 1; + const char *c = input.c_str() + pos; + const char * const cStart = c; + for ( ; *c; ++c) + { + if(c[0] == '$' && c[1] == '<') + { + ++nestingLevel; + ++c; + continue; + } + if(c[0] == '>') + { + --nestingLevel; + if (nestingLevel == 0) + { + break; + } + } + } + const std::string::size_type traversed = (c - cStart) + 1; + if (!*c) + { + result += "$<" + input.substr(pos, traversed); + } + pos += traversed; + lastPos = pos; + } + result += input.substr(lastPos); + return result; +} diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index d37ce97..29d3f44 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -48,6 +48,13 @@ public: const cmCompiledGeneratorExpression& Parse(std::string const& input); const cmCompiledGeneratorExpression& Parse(const char* input); + enum PreprocessContext { + StripAllGeneratorExpressions + }; + + static std::string Preprocess(const std::string &input, + PreprocessContext context); + private: cmGeneratorExpression(const cmGeneratorExpression &); void operator=(const cmGeneratorExpression &); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 92e2052..287066a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -17,7 +17,10 @@ #include "cmGeneratorExpression.h" //---------------------------------------------------------------------------- -static void reportError(cmGeneratorExpressionContext *context, +#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510 +static +#endif +void reportError(cmGeneratorExpressionContext *context, const std::string &expr, const std::string &result) { context->HadError = true; diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index d95e1cc..7a8fc51 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -14,6 +14,8 @@ #include "cmGeneratorExpressionEvaluator.h" +#include "assert.h" + //---------------------------------------------------------------------------- cmGeneratorExpressionParser::cmGeneratorExpressionParser( const std::vector<cmGeneratorExpressionToken> &tokens) @@ -75,6 +77,7 @@ static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result, void cmGeneratorExpressionParser::ParseGeneratorExpression( std::vector<cmGeneratorExpressionEvaluator*> &result) { + assert(this->it != this->Tokens.end()); unsigned int nestedLevel = this->NestingLevel; ++this->NestingLevel; @@ -96,12 +99,14 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( // ERROR } - if (this->it->TokenType == cmGeneratorExpressionToken::EndExpression) + if (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::EndExpression) { GeneratorExpressionContent *content = new GeneratorExpressionContent( startToken->Content, this->it->Content - startToken->Content + this->it->Length); + assert(this->it != this->Tokens.end()); ++this->it; --this->NestingLevel; content->SetIdentifier(identifier); @@ -113,39 +118,58 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator> commaTokens; std::vector<cmGeneratorExpressionToken>::const_iterator colonToken; - if (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) + if (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { colonToken = this->it; parameters.resize(parameters.size() + 1); + assert(this->it != this->Tokens.end()); ++this->it; - while (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) + + while (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) { commaTokens.push_back(this->it); parameters.resize(parameters.size() + 1); + assert(this->it != this->Tokens.end()); + ++this->it; + } + while (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) + { + extendText(*(parameters.end() - 1), this->it); + assert(this->it != this->Tokens.end()); ++this->it; } - while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression) + while (this->it != this->Tokens.end() && + this->it->TokenType != cmGeneratorExpressionToken::EndExpression) { this->ParseContent(*(parameters.end() - 1)); - while (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) + if (this->it == this->Tokens.end()) + { + break; + } + while (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) { commaTokens.push_back(this->it); parameters.resize(parameters.size() + 1); + assert(this->it != this->Tokens.end()); ++this->it; } - if (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) + while (this->it != this->Tokens.end() && + this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { extendText(*(parameters.end() - 1), this->it); + assert(this->it != this->Tokens.end()); ++this->it; } - if (this->it == this->Tokens.end()) - { - break; - } } - if(this->it->TokenType == cmGeneratorExpressionToken::EndExpression) + if(this->it != this->Tokens.end() + && this->it->TokenType == cmGeneratorExpressionToken::EndExpression) { --this->NestingLevel; + assert(this->it != this->Tokens.end()); ++this->it; } } @@ -168,6 +192,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.end(); std::vector<TokenVector::const_iterator>::const_iterator commaIt = commaTokens.begin(); + assert(parameters.size() > commaTokens.size()); for ( ; pit != pend; ++pit, ++commaIt) { extendResult(result, *pit); @@ -175,6 +200,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( { extendText(result, *commaIt); } + else + { + break; + } } } return; @@ -194,6 +223,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( void cmGeneratorExpressionParser::ParseContent( std::vector<cmGeneratorExpressionEvaluator*> &result) { + assert(this->it != this->Tokens.end()); switch(this->it->TokenType) { case cmGeneratorExpressionToken::Text: @@ -210,6 +240,7 @@ void cmGeneratorExpressionParser::ParseContent( TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1)); textContent->Extend(this->it->Length); + assert(this->it != this->Tokens.end()); ++this->it; return; } @@ -217,10 +248,12 @@ void cmGeneratorExpressionParser::ParseContent( cmGeneratorExpressionEvaluator* n = new TextContent(this->it->Content, this->it->Length); result.push_back(n); + assert(this->it != this->Tokens.end()); ++this->it; return ; } case cmGeneratorExpressionToken::BeginExpression: + assert(this->it != this->Tokens.end()); ++this->it; this->ParseGeneratorExpression(result); return; @@ -233,10 +266,11 @@ void cmGeneratorExpressionParser::ParseContent( } else { - // TODO: Unreachable. Assert? + assert(!"Got unexpected syntax token."); } + assert(this->it != this->Tokens.end()); ++this->it; return; } - // Unreachable. Assert? + assert(!"Unhandled token in generator expression."); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d4b57f4..19b55c6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -287,7 +287,8 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() } //---------------------------------------------------------------------------- -std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories() +std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( + const char *config) { std::vector<std::string> includes; const char *prop = this->Target->GetProperty("INCLUDE_DIRECTORIES"); @@ -296,7 +297,6 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories() return includes; } - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8ea17d7..a29a9f9 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -72,7 +72,7 @@ public: const char* GetCreateRuleVariable(); /** Get the include directories for this target. */ - std::vector<std::string> GetIncludeDirectories(); + std::vector<std::string> GetIncludeDirectories(const char *config); std::string GetCompileDefinitions(const char *config = 0); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 09588f9..23ec08a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -25,6 +25,7 @@ #include "cmComputeTargetDepends.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" +#include "cmGeneratorExpression.h" #include <cmsys/Directory.hxx> @@ -1152,13 +1153,13 @@ void cmGlobalGenerator::CheckLocalGenerators() { manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); this->LocalGenerators[i]->ConfigureFinalPass(); - cmGeneratorTargetsType targets = - this->LocalGenerators[i]->GetMakefile()->GetGeneratorTargets(); - for (cmGeneratorTargetsType::iterator l = targets.begin(); + cmTargets &targets = + this->LocalGenerators[i]->GetMakefile()->GetTargets(); + for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { const cmTarget::LinkLibraryVectorType& libs = - l->second->Target->GetOriginalLinkLibraries(); + l->second.GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin(); lib != libs.end(); ++lib) { @@ -1174,14 +1175,23 @@ void cmGlobalGenerator::CheckLocalGenerators() } std::string text = notFoundMap[varName]; text += "\n linked by target \""; - text += l->second->GetName(); + text += l->second.GetName(); text += "\" in directory "; text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory(); notFoundMap[varName] = text; } } std::vector<std::string> incs; - this->LocalGenerators[i]->GetIncludeDirectories(incs, l->second); + const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); + if (!incDirProp) + { + continue; + } + + std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, + cmGeneratorExpression::StripAllGeneratorExpressions); + + cmSystemTools::ExpandListArgument(incDirs.c_str(), incs); for( std::vector<std::string>::const_iterator incDir = incs.begin(); incDir != incs.end(); ++incDir) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 95c6807..30d8f18 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1947,7 +1947,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt); + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, + "C", configName); std::set<cmStdString> emitted; emitted.insert("/System/Library/Frameworks"); for(std::vector<std::string>::iterator i = includes.begin(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c7995a3..4f4f725 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1324,7 +1324,8 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang) + const char* lang, + const char *config) { // Need to decide whether to automatically include the source and // binary directories at the beginning of the include path. @@ -1417,7 +1418,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, // Get the target-specific include directories. std::vector<std::string> includes; - includes = target->GetIncludeDirectories(); + includes = target->GetIncludeDirectories(config); // Support putting all the in-project include directories first if // it is requested by the project. diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 49bce38..bd58218 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -212,7 +212,7 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang = "C"); + const char* lang = "C", const char *config = 0); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 72b56e7..f15322b 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -853,7 +853,8 @@ inline std::string removeQuotes(const std::string& s) std::string -cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target) +cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target, + const char *config) { std::string includeOptions; @@ -868,7 +869,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target) for(int j=0; j < 2; ++j) { std::vector<std::string> includes; - this->GetIncludeDirectories(includes, gt); + this->GetIncludeDirectories(includes, gt, "C", config); std::vector<std::string>::iterator i; for(i = includes.begin(); i != includes.end(); ++i) @@ -1147,7 +1148,15 @@ void cmLocalVisualStudio6Generator #endif // Get include options for this target. - std::string includeOptions = this->GetTargetIncludeOptions(target); + std::string includeOptionsDebug = this->GetTargetIncludeOptions(target, + "DEBUG"); + std::string includeOptionsRelease = this->GetTargetIncludeOptions(target, + "RELEASE"); + std::string includeOptionsRelWithDebInfo = this->GetTargetIncludeOptions( + target, + "RELWITHDEBINFO"); + std::string includeOptionsMinSizeRel = this->GetTargetIncludeOptions(target, + "MINSIZEREL"); // Get extra linker options for this target type. std::string extraLinkOptions; @@ -1560,8 +1569,15 @@ void cmLocalVisualStudio6Generator cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO", optionsRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", - includeOptions.c_str()); + cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_DEBUG", + includeOptionsDebug.c_str()); + cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELEASE", + includeOptionsRelease.c_str()); + cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_MINSIZEREL", + includeOptionsMinSizeRel.c_str()); + cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELWITHDEBINFO", + includeOptionsRelWithDebInfo.c_str()); + cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG", targetVersionFlag.c_str()); cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG", diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 9315d97..f45bc17 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -90,7 +90,7 @@ private: std::string& options); void OutputObjects(cmTarget& target, const char* tool, std::string& options); - std::string GetTargetIncludeOptions(cmTarget &target); + std::string GetTargetIncludeOptions(cmTarget &target, const char *config); std::vector<std::string> Configurations; std::string GetConfigName(std::string const& configuration) const; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 33d6e05..f9a2d32 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -814,7 +814,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); fout << "\t\t\t\tAdditionalIncludeDirectories=\""; std::vector<std::string> includes; - this->GetIncludeDirectories(includes, gt); + this->GetIncludeDirectories(includes, gt, "C", configName); std::vector<std::string>::iterator i = includes.begin(); for(;i != includes.end(); ++i) { diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 75a76a4..2ae35ef 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmMakeDepend.h" #include "cmSystemTools.h" +#include "cmGeneratorExpression.h" #include <cmsys/RegularExpression.hxx> @@ -58,12 +59,22 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) // Now extract any include paths from the targets std::set<std::string> uniqueIncludes; std::vector<std::string> orderedAndUniqueIncludes; - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); - for (cmGeneratorTargetsType::iterator l = targets.begin(); + cmTargets &targets = this->Makefile->GetTargets(); + for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) { - const std::vector<std::string>& includes = - l->second->GetIncludeDirectories(); + const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); + if (!incDirProp) + { + continue; + } + + std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, + cmGeneratorExpression::StripAllGeneratorExpressions); + + std::vector<std::string> includes; + cmSystemTools::ExpandListArgument(incDirs.c_str(), includes); + for(std::vector<std::string>::const_iterator j = includes.begin(); j != includes.end(); ++j) { diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5cc67e2..3d02d6a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1057,8 +1057,11 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n"; std::vector<std::string> includes; + + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget); + this->GeneratorTarget, + "C", config); for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { @@ -1543,8 +1546,11 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags() emitted.insert("/System/Library/Frameworks"); #endif std::vector<std::string> includes; + + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget); + this->GeneratorTarget, + "C", config); std::vector<std::string>::iterator i; // check all include directories for frameworks as this // will already have added a -F for the framework @@ -1849,8 +1855,10 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, std::vector<std::string> includes; + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget, lang); + this->GeneratorTarget, + lang, config); std::string includeFlags = this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); @@ -1953,8 +1961,10 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) { std::vector<std::string> includes; + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget); + this->GeneratorTarget, + "C", config); for(std::vector<std::string>::const_iterator idi = includes.begin(); idi != includes.end(); ++idi) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 39f6aab..0f10152 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -152,8 +152,10 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // Add include directory flags. { std::vector<std::string> includes; - this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, - language.c_str()); + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + this->LocalGenerator->GetIncludeDirectories(includes, + this->GeneratorTarget, + language.c_str(), config); std::string includeFlags = this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), language == "RC" ? true : false); // full include paths for RC diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 68f1046..942c7ab 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -170,7 +170,8 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) ++fileIt) { cmSourceFile* sf = *fileIt; - std::string absFile = sf->GetFullPath(); + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ab57a32..1e37ca5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1586,12 +1586,13 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *> (this->GlobalGenerator)->GetConfigurations(); - std::vector<std::string> includes; - this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget); for(std::vector<std::string>::iterator i = configs->begin(); i != configs->end(); ++i) { + std::vector<std::string> includes; + this->LocalGenerator->GetIncludeDirectories(includes, + this->GeneratorTarget, + "C", i->c_str()); this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> |