diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-10-09 20:11:47 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-10-09 20:11:47 (GMT) |
commit | ebd0c2d3771835a1317c1fd70eafd3ebf2135b01 (patch) | |
tree | 1dc8f5805b5f3f01933bc0035b3b6cad7b04b73a /Source | |
parent | f9687e328f7ea64ea6384aae11af36fdd3a12643 (diff) | |
download | CMake-ebd0c2d3771835a1317c1fd70eafd3ebf2135b01.zip CMake-ebd0c2d3771835a1317c1fd70eafd3ebf2135b01.tar.gz CMake-ebd0c2d3771835a1317c1fd70eafd3ebf2135b01.tar.bz2 |
Merge in changes for RC 3
Diffstat (limited to 'Source')
48 files changed, 457 insertions, 310 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 7c8405e..6224b40 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -390,8 +390,6 @@ int cmCPackGenerator::InstallProjectViaInstallScript( { const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT"); - std::string currentWorkingDirectory = - cmSystemTools::GetCurrentWorkingDirectory(); if ( cmakeScripts && *cmakeScripts ) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, @@ -460,8 +458,6 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); - std::string currentWorkingDirectory = - cmSystemTools::GetCurrentWorkingDirectory(); if ( cmakeProjects && *cmakeProjects ) { if ( !cmakeGenerator ) diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 11058c9..a3b5759 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -149,8 +149,21 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " << dmgCmd.str().c_str() << std::endl); - bool res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, - &retVal, 0, this->GeneratorVerbose, 0); + // since we get random dashboard failures with this one + // try running it more than once + int numTries = 4; + bool res; + while(numTries > 0) + { + res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, + &retVal, 0, + this->GeneratorVerbose, 0); + if(res && retVal) + { + numTries = -1; + } + numTries--; + } if ( !res || retVal ) { cmGeneratedFileStream ofs(tmpFile.c_str()); diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index befbc94..9333131 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -321,8 +321,19 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, << "\" \"" << outFileName << "\""; std::string output; int retVal = 1; - bool res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, - &retVal, 0, this->GeneratorVerbose, 0); + int numTries = 4; + bool res; + while(numTries > 0) + { + res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, + &retVal, 0, this->GeneratorVerbose, + 0); + if(res && retVal) + { + numTries = -1; + } + numTries--; + } if ( !res || retVal ) { cmGeneratedFileStream ofs(tmpFile.c_str()); diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 3ca0e53..1c56d81 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -176,12 +176,12 @@ int cmCPackTGZ_Data_Close(void *client_data) int n; uLong x = mydata->CRC; for (n = 0; n < 4; n++) { - buffer[n] = (int)(x & 0xff); + buffer[n] = static_cast<char>(x & 0xff); x >>= 8; } x = mydata->ZLibStream.total_in; for (n = 0; n < 4; n++) { - buffer[n+4] = (int)(x & 0xff); + buffer[n+4] = static_cast<char>(x & 0xff); x >>= 8; } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index d93da07..0095bbc 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -596,8 +596,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) std::vector<cmCTestBuildErrorWarning>::iterator it; // only report the first 50 warnings and first 50 errors - unsigned short numErrorsAllowed = this->MaxErrors; - unsigned short numWarningsAllowed = this->MaxWarnings; + int numErrorsAllowed = this->MaxErrors; + int numWarningsAllowed = this->MaxWarnings; std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory"); // make sure the source dir is in the correct case on windows // via a call to collapse full path. diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index b6e10bf..c2135aa 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -361,9 +361,6 @@ int cmCTestCoverageHandler::ProcessHandler() cmSystemTools::ConvertToUnixSlashes(sourceDir); cmSystemTools::ConvertToUnixSlashes(binaryDir); - std::string asfGlob = sourceDir + "/*"; - std::string abfGlob = binaryDir + "/*"; - cmCTestLog(this->CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl); cmCTestCoverageHandlerContainer cont; @@ -1590,13 +1587,13 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( std::string shortFileName = this->CTest->GetShortPathToFile(file.c_str()); - float cper = percentBranch + percentFunction; + float cper = static_cast<float>(percentBranch + percentFunction); if(totalBranches > 0) { cper /= 2.0f; } percent_coverage += cper; - float cmet = percentFunction + percentBranch; + float cmet = static_cast<float>(percentFunction + percentBranch); if(totalBranches > 0) { cmet /= 2.0f; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7ab9cac..63dfe7e 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -81,7 +81,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler); testRun->SetIndex(test); testRun->SetTestProperties(this->Properties[test]); - if(testRun->StartTest()) + if(testRun->StartTest(this->Total)) { this->RunningTests.insert(testRun); } @@ -251,7 +251,8 @@ bool cmCTestMultiProcessHandler::CheckOutput() this->TestRunningMap[test] = false; this->RunningTests.erase(p); this->WriteCheckpoint(test); - this->WriteCostData(test, p->GetTestResults().ExecutionTime); + this->WriteCostData(test, static_cast<float>( + p->GetTestResults().ExecutionTime)); this->RunningCount -= GetProcessorsUsed(test); delete p; } @@ -276,7 +277,7 @@ void cmCTestMultiProcessHandler::ReadCostData() cmSystemTools::SplitString(line.c_str(), ' '); int index = atoi(parts[0].c_str()); - float cost = atof(parts[1].c_str()); + float cost = static_cast<float>(atof(parts[1].c_str())); if(this->Properties[index] && this->Properties[index]->Cost == 0) { this->Properties[index]->Cost = cost; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ffc257a..982beb3 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -297,9 +297,11 @@ void cmCTestRunTest::MemCheckPostProcess() //---------------------------------------------------------------------- // Starts the execution of a test. Returns once it has started -bool cmCTestRunTest::StartTest() +bool cmCTestRunTest::StartTest(size_t total) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, " Start " + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2*getNumWidth(total) + 8) + << "Start " + << std::setw(getNumWidth(total)) << this->TestProperties->Index << ": " << this->TestProperties->Name << std::endl); this->ComputeArguments(); diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index aeffbb8..bfeda20 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -46,7 +46,7 @@ public: bool CheckOutput(); //launch the test process, return whether it started correctly - bool StartTest(); + bool StartTest(size_t total); //capture and report the test results bool EndTest(size_t completed, size_t total, bool started); //Called by ctest -N to log the command string diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2ad2e37..3572b11 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -574,16 +574,16 @@ int cmCTestTestHandler::ProcessHandler() } } - float percent = float(passed.size()) * 100.0f / total; + float percent = float(passed.size()) * 100.0f / float(total); if ( failed.size() > 0 && percent > 99) { percent = 99; } - + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << static_cast<int>(percent + .5) << "% tests passed, " - << failed.size() << " tests failed out of " - << total << std::endl); + << failed.size() << " tests failed out of " + << total << std::endl); if(this->CTest->GetLabelSummary()) { this->PrintLabelSummary(); @@ -596,7 +596,7 @@ int cmCTestTestHandler::ProcessHandler() if (failed.size()) { cmGeneratedFileStream ofs; - cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); @@ -1982,7 +1982,7 @@ bool cmCTestTestHandler::SetTestsProperties( } if ( key == "COST" ) { - rtit->Cost = atof(val.c_str()); + rtit->Cost = static_cast<float>(atof(val.c_str())); } if ( key == "RUN_SERIAL" ) { diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 854b919..cd231ad 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -920,7 +920,7 @@ void cmCursesMainForm::HandleInput() { if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) ) { - this->SearchString += key; + this->SearchString += static_cast<char>(key); } } else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC ) diff --git a/Source/QtDialog/CMake.desktop b/Source/QtDialog/CMake.desktop index 9568501..d1d4fb2 100644 --- a/Source/QtDialog/CMake.desktop +++ b/Source/QtDialog/CMake.desktop @@ -1,6 +1,5 @@ [Desktop Entry] Version=1.0 -Encoding=UTF-8 Name=CMake Comment=Cross-platform buildsystem Exec=cmake-gui %f diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index ea65f2d..a3de4db 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -342,7 +342,7 @@ void CMakeSetupDialog::finishConfigure(int err) void CMakeSetupDialog::finishGenerate(int err) { - this->enterState(ReadyGenerate); + this->enterState(ReadyConfigure); if(err != 0) { QMessageBox::critical(this, tr("Error"), diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index d0c28a8..942cb3f 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -149,10 +149,8 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, std::set<cmStdString> dependencies; std::set<cmStdString> scanned; - // Use reserve to allocate enough memory for both strings, + // Use reserve to allocate enough memory for tempPathStr // so that during the loops no memory is allocated or freed - std::string cacheKey; - cacheKey.reserve(4*1024); std::string tempPathStr; tempPathStr.reserve(4*1024); @@ -181,22 +179,8 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, } else { - // With GCC distribution of STL, assigning to a string directly - // throws away the internal buffer of the left-hand-side. We - // want to keep the pre-allocated buffer so we use C-style - // string assignment and then operator+=. We could call - // .clear() instead of assigning to an empty string but the - // method does not exist on some older compilers. - cacheKey = ""; - cacheKey += current.FileName; - - for(std::vector<std::string>::const_iterator i = - this->IncludePath.begin(); i != this->IncludePath.end(); ++i) - { - cacheKey+=*i; - } std::map<cmStdString, cmStdString>::iterator - headerLocationIt=this->HeaderLocationCache.find(cacheKey); + headerLocationIt=this->HeaderLocationCache.find(current.FileName); if (headerLocationIt!=this->HeaderLocationCache.end()) { fullName=headerLocationIt->second; @@ -214,16 +198,16 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, } else { - tempPathStr += *i; - tempPathStr+="/"; - tempPathStr+=current.FileName; + tempPathStr += *i; + tempPathStr+="/"; + tempPathStr+=current.FileName; } // Look for the file in this location. if(cmSystemTools::FileExists(tempPathStr.c_str(), true)) { - fullName = tempPathStr; - HeaderLocationCache[cacheKey]=fullName; + fullName = tempPathStr; + HeaderLocationCache[current.FileName]=fullName; break; } } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index ea07da4..b42f2a9 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -56,7 +56,18 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Full path to the listfile currently being processed.", "As CMake processes the listfiles in your project this " "variable will always be set to the one currently being " - "processed. See also CMAKE_PARENT_LIST_FILE.",false, + "processed. " + "The value has dynamic scope. " + "When CMake starts processing commands in a source file " + "it sets this variable to the location of the file. " + "When CMake finishes processing commands from the file it " + "restores the previous value. " + "Therefore the value of the variable inside a macro or " + "function is the file invoking the bottom-most entry on " + "the call stack, not the file containing the macro or " + "function definition." + "\n" + "See also CMAKE_PARENT_LIST_FILE.",false, "Variables that Provide Information"); cm->DefineProperty diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index c01e220..763fdd8 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -540,7 +540,7 @@ bool cmELFInternalImpl<Types>::LoadDynamicSection() // Allocate the dynamic section entries. ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; - int n = sec.sh_size / sec.sh_entsize; + int n = static_cast<int>(sec.sh_size / sec.sh_entsize); this->DynamicSectionEntries.resize(n); // Read each entry. @@ -592,7 +592,7 @@ unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j) return 0; } ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; - return sec.sh_offset + sec.sh_entsize*j; + return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize*j); } //---------------------------------------------------------------------------- diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index a70ca75..abe6bc9 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -531,6 +531,13 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) return false; } + // At least one compiler (Portland Group Fortran) produces binaries + // with some extra characters in strings. + char extra[256]; // = {}; // some compilers do not like this + memset(extra, 0, sizeof(extra)); + extra[0x0c] = 1; // FF (form feed) + extra[0x14] = 1; // DC4 (device control 4) + // Parse strings out of the file. int output_size = 0; std::vector<std::string> strings; @@ -585,7 +592,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) { // Ignore CR character to make output always have UNIX newlines. } - else if((c >= 0x20 && c < 0x7F) || c == '\t' || c == '\f' || + else if((c >= 0x20 && c < 0x7F) || c == '\t' || extra[c] || (c == '\n' && newline_consume)) { // This is an ASCII character that may be part of a string. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 165dbc2..7dbbf6d 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -736,7 +736,7 @@ bool cmFindPackageCommand::HandlePackageMode() } // Try to load the config file if the directory is known - bool cachedDirectoryOk = false; + bool fileFound = false; if(!cmSystemTools::IsOff(def)) { // Get the directory from the variable value. @@ -754,25 +754,30 @@ bool cmFindPackageCommand::HandlePackageMode() if (this->FindConfigFile(dir, file)) { this->FileFound = file; - cachedDirectoryOk = true; + fileFound = true; } def = this->Makefile->GetDefinition(this->Variable.c_str()); } // Search for the config file if it is not already found. - if(cmSystemTools::IsOff(def) || !cachedDirectoryOk) + if(cmSystemTools::IsOff(def) || !fileFound) { - this->FindConfig(); + fileFound = this->FindConfig(); def = this->Makefile->GetDefinition(this->Variable.c_str()); } + // Sanity check. + if(fileFound && this->FileFound.empty()) + { + this->Makefile->IssueMessage( + cmake::INTERNAL_ERROR, "fileFound is true but FileFound is empty!"); + fileFound = false; + } + // If the directory for the config file was found, try to read the file. bool result = true; bool found = false; - // in the following test FileFound should never be empty if def is valid - // but I don't want to put an assert() in there now, in case this still - // makes it into 2.6.3 - if(!cmSystemTools::IsOff(def) && (!this->FileFound.empty())) + if(fileFound) { // Set the version variables before loading the config file. // It may override them. @@ -886,7 +891,7 @@ bool cmFindPackageCommand::HandlePackageMode() } //---------------------------------------------------------------------------- -void cmFindPackageCommand::FindConfig() +bool cmFindPackageCommand::FindConfig() { // Compute the set of search prefixes. this->ComputePrefixes(); @@ -938,9 +943,11 @@ void cmFindPackageCommand::FindConfig() "The directory containing a CMake configuration file for "; help += this->Name; help += "."; + // We force the value since we do not get here if it was already set. this->Makefile->AddCacheDefinition(this->Variable.c_str(), init.c_str(), help.c_str(), - cmCacheManager::PATH); + cmCacheManager::PATH, true); + return found; } //---------------------------------------------------------------------------- diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 139ca9b..63f4111 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -73,7 +73,7 @@ private: void AddFindDefinition(const char* var, const char* val); void RestoreFindDefinitions(); bool HandlePackageMode(); - void FindConfig(); + bool FindConfig(); bool FindPrefixedConfig(); bool FindFrameworkConfig(); bool FindAppBundleConfig(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 25e7602..4734c50 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1953,6 +1953,11 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, for (cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { cmTarget* target = &l->second; + if(this->IsRootOnlyTarget(target) && + target->GetMakefile() != root->GetMakefile()) + { + continue; + } // put the target in the set of original targets originalTargets.insert(target); // Get the set of targets that depend on target @@ -1962,6 +1967,13 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- +bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) +{ + return (target->GetType() == cmTarget::GLOBAL_TARGET || + strcmp(target->GetName(), this->GetAllTargetName()) == 0); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 5a01bd2..c9d0790 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -265,6 +265,7 @@ protected: virtual void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); + virtual bool IsRootOnlyTarget(cmTarget* target); void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 9a7c744..783db21 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -213,27 +213,10 @@ void cmGlobalVisualStudio6Generator } else { - bool skip = false; - // if it is a global target or the check build system target - // or the all_build target - // then only use the one that is for the root - if(target->GetType() == cmTarget::GLOBAL_TARGET - || !strcmp(target->GetName(), this->GetAllTargetName())) - { - if(target->GetMakefile() != root->GetMakefile()) - { - skip = true; - } - } - // if not skipping the project then write it into the - // solution - if(!skip) - { - std::string dspname = GetVS6TargetName(target->GetName()); - std::string dir = target->GetMakefile()->GetStartOutputDirectory(); - dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); - this->WriteProject(fout, dspname.c_str(), dir.c_str(), *target); - } + std::string dspname = GetVS6TargetName(target->GetName()); + std::string dir = target->GetMakefile()->GetStartOutputDirectory(); + dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); + this->WriteProject(fout, dspname.c_str(), dir.c_str(), *target); } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f2f3e98..dbe9aed 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -289,34 +289,16 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( } else { - bool skip = false; - // if it is a global target or the check build system target - // or the all_build target - // then only use the one that is for the root - if(target->GetType() == cmTarget::GLOBAL_TARGET - || !strcmp(target->GetName(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) - || !strcmp(target->GetName(), this->GetAllTargetName())) + const char *vcprojName = + target->GetProperty("GENERATOR_FILE_NAME"); + if(vcprojName) { - if(target->GetMakefile() != root->GetMakefile()) - { - skip = true; - } - } - // if not skipping the project then write it into the - // solution - if(!skip) - { - const char *vcprojName = - target->GetProperty("GENERATOR_FILE_NAME"); - if(vcprojName) - { - cmMakefile* tmf = target->GetMakefile(); - std::string dir = tmf->GetStartOutputDirectory(); - dir = root->Convert(dir.c_str(), - cmLocalGenerator::START_OUTPUT); - this->WriteProject(fout, vcprojName, dir.c_str(), - *target); - } + cmMakefile* tmf = target->GetMakefile(); + std::string dir = tmf->GetStartOutputDirectory(); + dir = root->Convert(dir.c_str(), + cmLocalGenerator::START_OUTPUT); + this->WriteProject(fout, vcprojName, dir.c_str(), + *target); } } } @@ -633,6 +615,13 @@ cmGlobalVisualStudio7Generator } } +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio7Generator::IsRootOnlyTarget(cmTarget* target) +{ + return (this->cmGlobalVisualStudioGenerator::IsRootOnlyTarget(target) || + strcmp(target->GetName(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) == 0); +} + bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, cmTarget* target) { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 363489e..73302bc 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -133,6 +133,7 @@ protected: std::string ConvertToSolutionPath(const char* path); + virtual bool IsRootOnlyTarget(cmTarget* target); bool IsPartOfDefaultBuild(const char* project, cmTarget* target); std::vector<std::string> Configurations; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f217a35..d2c75b2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2646,18 +2646,18 @@ void cmGlobalXCodeGenerator { osxArch = "$(ARCHS_STANDARD_32_64_BIT)"; } - else if(this->XcodeVersion <= 25) + else if(this->XcodeVersion == 31) + { + osxArch = "$(ARCHS_STANDARD_32_BIT)"; + } + else if(this->XcodeVersion <= 30) { -#ifdef __i386 - osxArch = "i386"; -#endif #ifdef __ppc__ osxArch = "ppc"; #endif - } - else - { - osxArch = "$(ARCHS_STANDARD_32_BIT)"; +#ifdef __i386 + osxArch = "i386"; +#endif } buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index 2970531..2ff7945 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -172,7 +172,10 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType( return Binary; } - fgets(buf, 1024, inFile); + if(!fgets(buf, 1024, inFile)) + { + buf[0] = 0; + } fclose(inFile); FileType type = Binary; unsigned int minLineLength = 0; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 81be212..b51fabb 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -269,10 +269,9 @@ namespace if (cmSystemTools::IsOff(def)) { cmPolicies* policies = makefile->GetPolicies(); - errorString = "You have used a variable or argument named \"" + errorString = "A variable or argument named \"" + newArg - + "\" in a conditional statement. Please be aware of issues " - + "related to policy CMP0012. " + + "\" appears in a conditional statement. " + policies->GetPolicyWarning(cmPolicies::CMP0012); status = cmake::AUTHOR_WARNING; } @@ -285,10 +284,9 @@ namespace if (!cmSystemTools::IsOff(def)) { cmPolicies* policies = makefile->GetPolicies(); - errorString = "You have used a variable or argument named \"" + errorString = "A variable or argument named \"" + newArg - + "\" in a conditional statement. Please be aware of issues " - + "related to policy CMP0012. " + + "\" appears in a conditional statement. " + policies->GetPolicyWarning(cmPolicies::CMP0012); status = cmake::AUTHOR_WARNING; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ee55957..c4ee5c7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1951,15 +1951,6 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, flagsVar += "_FLAGS"; this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); } - - // Add flags specific to shared builds. - if(cmSystemTools::IsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) - { - flagsVar = "CMAKE_SHARED_BUILD_"; - flagsVar += lang; - flagsVar += "_FLAGS"; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); - } } //---------------------------------------------------------------------------- @@ -2083,6 +2074,26 @@ void cmLocalGenerator::AppendDefines(std::string& defines, } //---------------------------------------------------------------------------- +void cmLocalGenerator::AppendFeatureOptions( + std::string& flags, const char* lang, const char* feature) +{ + std::string optVar = "CMAKE_"; + optVar += lang; + optVar += "_COMPILE_OPTIONS_"; + optVar += feature; + if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str())) + { + std::vector<std::string> options; + cmSystemTools::ExpandListArgument(optionList, options); + for(std::vector<std::string>::const_iterator oi = options.begin(); + oi != options.end(); ++oi) + { + this->AppendFlags(flags, this->EscapeForShell(oi->c_str()).c_str()); + } + } +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, const char* default_comment) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 840e5d3..d2082e4 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -149,6 +149,10 @@ public: void AppendDefines(std::string& defines, const char* defines_list, const char* lang); + /** Lookup and append options associated with a particular feature. */ + void AppendFeatureOptions(std::string& flags, const char* lang, + const char* feature); + /** Translate a dependency as given in CMake code to the name to appear in a generated build file. If the given name is that of a CMake target it will be transformed to the real output diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7aa1202..88c8c7b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -810,7 +810,7 @@ void cmMakefile::ConfigureFinalPass() for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); l++) { - l->second.AnalyzeLibDependencies(*this); + l->second.FinishConfigure(); } } @@ -1642,57 +1642,6 @@ void cmMakefile::AddDefinition(const char* name, const char* value) #endif } -//---------------------------------------------------------------------------- -void cmMakefile::UseCacheDefinition(cmCacheManager::CacheIterator const& it) -{ - // Check for a local definition that might hide the cache value. - const char* name = it.GetName(); - const char* def = this->Internal->VarStack.top().Get(name); - if(!def) - { - return; - } - - // If the visible value will change then check policy CMP0015. - const char* cache = it.GetValue(); - if(strcmp(def, cache) != 0) - { - cmOStringStream e; - switch (this->GetPolicyStatus(cmPolicies::CMP0015)) - { - case cmPolicies::WARN: - e << "Local variable \"" << name << "\" is set to\n" - << " " << def << "\n" - << "but the CACHE entry of the same name is set to\n" - << " " << cache << "\n" - << "The local variable is hiding the cache value." - << "\n" - << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0015); - this->IssueMessage(cmake::AUTHOR_WARNING, e.str()); - case cmPolicies::OLD: - // OLD behavior is to leave local definition. - return; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - e << "Local variable \"" << name << "\" is set to\n" - << " " << def << "\n" - << "but the CACHE entry of the same name is set to\n" - << " " << cache << "\n" - << "This command is removing the local variable to expose " - << "the cache value." - << "\n" - << this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0015); - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - case cmPolicies::NEW: - // NEW behavior is to remove local definition (done below). - break; - } - } - - // Remove the local definition to make the cache value visible. - this->RemoveDefinition(name); -} - void cmMakefile::AddCacheDefinition(const char* name, const char* value, const char* doc, @@ -1719,7 +1668,10 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, cmSystemTools::ExpandListArgument(val, files); for ( cc = 0; cc < files.size(); cc ++ ) { - files[cc] = cmSystemTools::CollapseFullPath(files[cc].c_str()); + if(!cmSystemTools::IsOff(files[cc].c_str())) + { + files[cc] = cmSystemTools::CollapseFullPath(files[cc].c_str()); + } if ( cc > 0 ) { nvalue += ";"; @@ -3311,6 +3263,31 @@ bool cmMakefile::GetPropertyAsBool(const char* prop) return cmSystemTools::IsOn(this->GetProperty(prop)); } +//---------------------------------------------------------------------------- +const char* cmMakefile::GetFeature(const char* feature, const char* config) +{ + // TODO: Define accumulation policy for features (prepend, append, replace). + // Currently we always replace. + if(config && *config) + { + std::string featureConfig = feature; + featureConfig += "_"; + featureConfig += cmSystemTools::UpperCase(config); + if(const char* value = this->GetProperty(featureConfig.c_str())) + { + return value; + } + } + if(const char* value = this->GetProperty(feature)) + { + return value; + } + if(cmLocalGenerator* parent = this->LocalGenerator->GetParent()) + { + return parent->GetMakefile()->GetFeature(feature, config); + } + return 0; +} cmTarget* cmMakefile::FindTarget(const char* name) { @@ -3530,6 +3507,19 @@ void cmMakefile::DefineProperties(cmake *cm) "be followed. See the include_regular_expression command.", false); cm->DefineProperty + ("INTERPROCEDURAL_OPTIMIZATION", cmProperty::DIRECTORY, + "Enable interprocedural optimization for targets in a directory.", + "If set to true, enables interprocedural optimizations " + "if they are known to be supported by the compiler."); + + cm->DefineProperty + ("INTERPROCEDURAL_OPTIMIZATION_<CONFIG>", cmProperty::DIRECTORY, + "Per-configuration interprocedural optimization for a directory.", + "This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION. " + "If set, this property overrides the generic property " + "for the named configuration."); + + cm->DefineProperty ("VARIABLES", cmProperty::DIRECTORY, "List of variables defined in the current directory.", "This read-only property specifies the list of CMake variables " diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 485d9e2..63f81b8 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -286,11 +286,6 @@ public: bool force = false); /** - * Update the variable scope to make the cache definition visible. - */ - void UseCacheDefinition(cmCacheManager::CacheIterator const& it); - - /** * Add bool variable definition to the build. */ void AddDefinition(const char* name, bool); @@ -793,6 +788,8 @@ public: const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); + const char* GetFeature(const char* feature, const char* config); + // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index c7213a6..a20c917 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -199,11 +199,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string flags; std::string linkFlags; - // Add flags to deal with shared libraries. Any library being - // linked in might be shared, so always use shared flags for an - // executable. - this->LocalGenerator->AddSharedFlags(linkFlags, linkLanguage, true); - // Add flags to create an executable. this->LocalGenerator-> AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS", @@ -231,9 +226,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) (linkFlags, this->Makefile->GetDefinition(export_flag_var.c_str())); } - // Add language-specific flags. - this->LocalGenerator - ->AddLanguageFlags(flags, linkLanguage, this->ConfigName); + // Add language feature flags. + this->AddFeatureFlags(flags, linkLanguage); // Add target-specific linker flags. this->LocalGenerator->AppendFlags diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 9162b4c..4070a3b 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -113,6 +113,12 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() } linkRuleVar += "_CREATE_STATIC_LIBRARY"; + if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") && + this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str())) + { + linkRuleVar += "_IPO"; + } + std::string extraFlags; this->LocalGenerator->AppendFlags (extraFlags,this->Target->GetProperty("STATIC_LIBRARY_FLAGS")); @@ -671,9 +677,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.TargetInstallNameDir = install_name_dir.c_str(); } } + + // Add language feature flags. std::string langFlags; - this->LocalGenerator - ->AddLanguageFlags(langFlags, linkLanguage, this->ConfigName); + this->AddFeatureFlags(langFlags, linkLanguage); + // remove any language flags that might not work with the // particular os if(forbiddenFlagVar) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index edfae87..c4f1d32 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -291,10 +291,8 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() this->LocalGenerator->AppendDefines (defines, this->Target->GetProperty(defPropName.c_str()), lang); - // Add language-specific flags. - this->LocalGenerator - ->AddLanguageFlags(flags, lang, - this->LocalGenerator->ConfigurationName.c_str()); + // Add language feature flags. + this->AddFeatureFlags(flags, lang); // Fortran-specific flags computed for this target. if(*l == "Fortran") @@ -578,9 +576,6 @@ cmMakefileTargetGenerator sourceFile = this->Convert(sourceFile.c_str(), cmLocalGenerator::NONE, cmLocalGenerator::SHELL); - std::string objectFile = this->Convert(obj.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); // Construct the build message. std::vector<std::string> no_commands; @@ -1762,3 +1757,29 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) this->ModuleDefinitionFile.c_str())); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } + +//---------------------------------------------------------------------------- +const char* cmMakefileTargetGenerator::GetFeature(const char* feature) +{ + return this->Target->GetFeature(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) +{ + return cmSystemTools::IsOn(this->GetFeature(feature)); +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::AddFeatureFlags( + std::string& flags, const char* lang + ) +{ + // Add language-specific flags. + this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName); + + if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) + { + this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); + } +} diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 6878e06..4ee2b39 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -220,6 +220,13 @@ protected: // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(std::string& flags); + // Add language feature flags. + void AddFeatureFlags(std::string& flags, const char* lang); + + // Feature query methods. + const char* GetFeature(const char* feature); + bool GetFeatureAsBool(const char* feature); + //================================================================== // Convenience routines that do nothing more than forward to // implementaitons diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index c3ec266..af9d94b 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -53,7 +53,6 @@ bool cmOptionCommand if ( it.GetType() != cmCacheManager::UNINITIALIZED ) { it.SetProperty("HELPSTRING", args[1].c_str()); - this->Makefile->UseCacheDefinition(it); return true; } if ( it.GetValue() ) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index ffba3cb..0d35b65 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -359,17 +359,19 @@ cmPolicies::cmPolicies() this->DefinePolicy( CMP0012, "CMP0012", "The if() command can recognize named boolean constants.", - "In CMake versions prior to 2.6.5 the only boolean constants were 0 " + "In CMake versions 2.6.4 and lower the only boolean constants were 0 " "and 1. Other boolean constants such as true, false, yes, no, " "on, off, y, n, notfound, ignore (all case insensitive) were recognized " - "in some cases but not all. In later versions of cmake these values are " + "in some cases but not all. " + "For example, the code \"if(TRUE)\" might have evaluated as false. " + "In later versions of cmake these values are " "treated as boolean constants more consistently and should not be used " "as variable names. " "The OLD behavior for this policy is to allow variables to have names " "such as true and to dereference them. " "The NEW behavior for this policy is to treat strings like true as a " "boolean constant.", - 2,6,5, cmPolicies::WARN); + 2,8,0, cmPolicies::WARN); this->DefinePolicy( CMP0013, "CMP0013", @@ -380,13 +382,13 @@ cmPolicies::cmPolicies() "overwritten in the build tree and could lead to strange behavior. " "CMake 2.6.4 and above explicitly detect duplicate binary directories. " "CMake 2.6.4 always considers this case an error. " - "In CMake 2.6.5 and above this policy determines whether or not " + "In CMake 2.8.0 and above this policy determines whether or not " "the case is an error. " "The OLD behavior for this policy is to allow duplicate binary " "directories. " "The NEW behavior for this policy is to disallow duplicate binary " "directories with an error.", - 2,6,5, cmPolicies::WARN); + 2,8,0, cmPolicies::WARN); this->DefinePolicy( CMP0014, "CMP0014", @@ -399,37 +401,6 @@ cmPolicies::cmPolicies() "The OLD behavior for this policy is to silently ignore the problem. " "The NEW behavior for this policy is to report an error.", 2,8,0, cmPolicies::WARN); - - this->DefinePolicy( - CMP0015, "CMP0015", - "The set() CACHE mode and option() command make the cache value visible.", - "In CMake 2.6 and below the CACHE mode of the set() command and the " - "option() command did not expose the value from the named cache entry " - "if it was already set both in the cache and as a local variable. " - "This led to subtle differences between first and later configurations " - "because a conflicting local variable would be overridden only when the " - "cache value was first created. " - "For example, the code\n" - " set(x 1)\n" - " set(before ${x})\n" - " set(x 2 CACHE STRING \"X\")\n" - " set(after ${x})\n" - " message(STATUS \"${before},${after}\")\n" - "would print \"1,2\" on the first run and \"1,1\" on future runs." - "\n" - "CMake 2.8.0 and above prefer to expose the cache value in all cases by " - "removing the local variable definition, but this changes behavior in " - "subtle cases when the local variable has a different value than that " - "exposed from the cache. " - "The example above will always print \"1,2\"." - "\n" - "This policy determines whether the commands should always expose the " - "cache value. " - "The OLD behavior for this policy is to leave conflicting local " - "variable values untouched and hide the true cache value. " - "The NEW behavior for this policy is to always expose the cache value.", - 2,8,0, cmPolicies::WARN); - } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index be3b44a..cf808bd 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -50,7 +50,6 @@ public: CMP0012, // Strong handling of boolean constants CMP0013, // Duplicate binary directories not allowed CMP0014, // Input directories must have CMakeLists.txt - CMP0015, // set(CACHE) and option() make CACHE value visible // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 20246d7..86ecebe 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -53,7 +53,7 @@ static void cmScriptGeneratorEncodeConfig(const char* config, if(*c >= 'a' && *c <= 'z') { result += "["; - result += *c + ('A' - 'a'); + result += static_cast<char>(*c + 'A' - 'a'); result += *c; result += "]"; } @@ -61,7 +61,7 @@ static void cmScriptGeneratorEncodeConfig(const char* config, { result += "["; result += *c; - result += *c + ('a' - 'A'); + result += static_cast<char>(*c + 'a' - 'A'); result += "]"; } else diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 7ff6869..5fcbdba 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -155,7 +155,6 @@ bool cmSetCommand // or the makefile if(cache && type != cmCacheManager::INTERNAL && !force) { - this->Makefile->UseCacheDefinition(it); return true; } } diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 609106c..2990d24 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -64,10 +64,8 @@ public: " set(<variable> <value>\n" " [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])\n" "Within CMake sets <variable> to the value <value>. <value> is expanded" - " before <variable> is set to it. If CACHE is present and <variable> " - "is not yet in the cache, then <variable> is put in the cache. If it is " - "already in the cache, <variable> is assigned the value stored in the " - "cache. If CACHE is present, also <type> and <docstring> are " + " before <variable> is set to it. If CACHE is present, then the " + "<variable> is put in the cache. <type> and <docstring> are then " "required. <type> is used by the CMake GUI to choose a widget with " "which the user sets a value. The value for <type> may be one of\n" " FILEPATH = File chooser dialog.\n" diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 134f9ea..2313853 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -381,7 +381,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) { std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \""; e += replace.substr(r, 2); - e += "\"in replace-expression."; + e += "\" in replace-expression."; this->SetError(e.c_str()); return false; } @@ -559,7 +559,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const& { if(args.size() < 5) { - this->SetError("sub-command REPLACE requires four arguments."); + this->SetError("sub-command REPLACE requires at least four arguments."); return false; } @@ -586,7 +586,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const& { if(args.size() != 5) { - this->SetError("sub-command REPLACE requires four arguments."); + this->SetError("sub-command SUBSTRING requires four arguments."); return false; } @@ -647,7 +647,7 @@ bool cmStringCommand::HandleStripCommand( { if(args.size() != 3) { - this->SetError("sub-command LENGTH requires two arguments."); + this->SetError("sub-command STRIP requires two arguments."); return false; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bf82981..219c1ef 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -338,7 +338,7 @@ bool cmSystemTools::IsOn(const char* val) for(std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) { - *c = toupper(*c); + *c = static_cast<char>(toupper(*c)); } return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y"); } @@ -371,7 +371,7 @@ bool cmSystemTools::IsOff(const char* val) for(std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) { - *c = toupper(*c); + *c = static_cast<char>(toupper(*c)); } return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE"); @@ -915,7 +915,10 @@ bool RunCommandViaPopen(const char* command, #endif return false; } - fgets(buffer, BUFFER_SIZE, cpipe); + if (!fgets(buffer, BUFFER_SIZE, cpipe)) + { + buffer[0] = 0; + } while(!feof(cpipe)) { if(verbose) @@ -923,8 +926,10 @@ bool RunCommandViaPopen(const char* command, cmSystemTools::Stdout(buffer); } output += buffer; - buffer[0] = 0; - fgets(buffer, BUFFER_SIZE, cpipe); + if(!fgets(buffer, BUFFER_SIZE, cpipe)) + { + buffer[0] = 0; + } } retVal = pclose(cpipe); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8510b59..ccac68a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,6 +55,13 @@ public: { this->SourceFileFlagsConstructed = false; } + cmTargetInternals(cmTargetInternals const& r) + { + this->SourceFileFlagsConstructed = false; + // Only some of these entries are part of the object state. + // Others not copied here are result caches. + this->SourceEntries = r.SourceEntries; + } typedef cmTarget::SourceFileFlags SourceFileFlags; std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; bool SourceFileFlagsConstructed; @@ -421,6 +428,19 @@ void cmTarget::DefineProperties(cmake *cm) "created."); cm->DefineProperty + ("INTERPROCEDURAL_OPTIMIZATION", cmProperty::TARGET, + "Enable interprocedural optimization for a target.", + "If set to true, enables interprocedural optimizations " + "if they are known to be supported by the compiler."); + + cm->DefineProperty + ("INTERPROCEDURAL_OPTIMIZATION_<CONFIG>", cmProperty::TARGET, + "Per-configuration interprocedural optimization for a target.", + "This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION. " + "If set, this property overrides the generic property " + "for the named configuration."); + + cm->DefineProperty ("LABELS", cmProperty::TARGET, "Specify a list of text labels associated with a target.", "Target label semantics are currently unspecified."); @@ -1015,6 +1035,27 @@ void cmTarget::SetMakefile(cmMakefile* mf) } //---------------------------------------------------------------------------- +void cmTarget::FinishConfigure() +{ + // Erase any cached link information that might have been comptued + // on-demand during the configuration. This ensures that build + // system generation uses up-to-date information even if other cache + // invalidation code in this source file is buggy. + this->ClearLinkMaps(); + + // Do old-style link dependency analysis. + this->AnalyzeLibDependencies(*this->Makefile); +} + +//---------------------------------------------------------------------------- +void cmTarget::ClearLinkMaps() +{ + this->Internal->LinkImplMap.clear(); + this->Internal->LinkInterfaceMap.clear(); + this->Internal->LinkClosureMap.clear(); +} + +//---------------------------------------------------------------------------- cmListFileBacktrace const& cmTarget::GetBacktrace() const { return this->Internal->Backtrace; @@ -1593,18 +1634,6 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -void cmTarget::AddLinkLibrary(const std::string& lib, - LinkLibraryType llt) -{ - this->AddFramework(lib.c_str(), llt); - cmTarget::LibraryID tmp; - tmp.first = lib; - tmp.second = llt; - this->LinkLibraries.push_back(tmp); - this->OriginalLinkLibraries.push_back(tmp); -} - -//---------------------------------------------------------------------------- bool cmTarget::NameResolvesToFramework(const std::string& libname) { return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()-> @@ -1648,6 +1677,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, tmp.second = llt; this->LinkLibraries.push_back( tmp ); this->OriginalLinkLibraries.push_back(tmp); + this->ClearLinkMaps(); // Add the explicit dependency information for this target. This is // simply a set of libraries separated by ";". There should always @@ -1993,13 +2023,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) } this->Properties.SetProperty(prop, value, cmProperty::TARGET); - - // If imported information is being set, wipe out cached - // information. - if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0) - { - this->Internal->ImportInfoMap.clear(); - } + this->MaybeInvalidatePropertyCache(prop); } //---------------------------------------------------------------------------- @@ -2010,13 +2034,21 @@ void cmTarget::AppendProperty(const char* prop, const char* value) return; } this->Properties.AppendProperty(prop, value, cmProperty::TARGET); + this->MaybeInvalidatePropertyCache(prop); +} - // If imported information is being set, wipe out cached - // information. +//---------------------------------------------------------------------------- +void cmTarget::MaybeInvalidatePropertyCache(const char* prop) +{ + // Wipe wipe out maps caching information affected by this property. if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0) { this->Internal->ImportInfoMap.clear(); } + if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0) + { + this->ClearLinkMaps(); + } } //---------------------------------------------------------------------------- @@ -2245,6 +2277,26 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- +const char* cmTarget::GetFeature(const char* feature, const char* config) +{ + if(config && *config) + { + std::string featureConfig = feature; + featureConfig += "_"; + featureConfig += cmSystemTools::UpperCase(config); + if(const char* value = this->GetProperty(featureConfig.c_str())) + { + return value; + } + } + if(const char* value = this->GetProperty(feature)) + { + return value; + } + return this->Makefile->GetFeature(feature, config); +} + +//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const char* prop) { return this->GetProperty(prop, cmProperty::TARGET); @@ -4309,12 +4361,12 @@ cmTargetInternalPointer::cmTargetInternalPointer() //---------------------------------------------------------------------------- cmTargetInternalPointer -::cmTargetInternalPointer(cmTargetInternalPointer const&) +::cmTargetInternalPointer(cmTargetInternalPointer const& r) { // Ideally cmTarget instances should never be copied. However until // we can make a sweep to remove that, this copy constructor avoids // allowing the resources (Internals) to be copied. - this->Pointer = new cmTargetInternals; + this->Pointer = new cmTargetInternals(*r.Pointer); } //---------------------------------------------------------------------------- @@ -4332,7 +4384,7 @@ cmTargetInternalPointer::operator=(cmTargetInternalPointer const& r) // we can make a sweep to remove that, this copy constructor avoids // allowing the resources (Internals) to be copied. cmTargetInternals* oldPointer = this->Pointer; - this->Pointer = new cmTargetInternals; + this->Pointer = new cmTargetInternals(*r.Pointer); delete oldPointer; return *this; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e0e258d..66e3f3df 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -183,9 +183,6 @@ public: const char *target, const char* lib, LinkLibraryType llt); - void AddLinkLibrary(const std::string& lib, - LinkLibraryType llt); - void MergeLinkLibraries( cmMakefile& mf, const char* selfname, const LinkLibraryVectorType& libs ); @@ -222,7 +219,8 @@ public: ///! Get the utilities used by this target std::set<cmStdString>const& GetUtilities() const { return this->Utilities; } - void AnalyzeLibDependencies( const cmMakefile& mf ); + /** Finalize the target at the end of the Configure step. */ + void FinishConfigure(); ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); @@ -232,6 +230,8 @@ public: bool GetPropertyAsBool(const char *prop); void CheckProperty(const char* prop, cmMakefile* context); + const char* GetFeature(const char* feature, const char* config); + bool IsImported() const {return this->IsImportedTarget;} /** The link interface specifies transitive library dependencies and @@ -490,6 +490,8 @@ private: const LibraryID& lib, DependencyMap& dep_map); + void AnalyzeLibDependencies( const cmMakefile& mf ); + const char* GetSuffixVariableInternal(bool implib); const char* GetPrefixVariableInternal(bool implib); std::string GetFullNameInternal(const char* config, bool implib); @@ -565,6 +567,10 @@ private: LinkImplementation& impl); void ComputeLinkClosure(const char* config, LinkClosure& lc); + void ClearLinkMaps(); + + void MaybeInvalidatePropertyCache(const char* prop); + // The cmMakefile instance that owns this target. This should // always be set. cmMakefile* Makefile; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index cdee8d2..48a0e83 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1276,7 +1276,10 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) int count; if (countFile) { - fscanf(countFile,"%i",&count); + if (1!=fscanf(countFile,"%i",&count)) + { + cmSystemTools::Message("Could not read from count file."); + } fclose(countFile); } else @@ -1318,7 +1321,10 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) } else { - fscanf(progFile,"%i",&count); + if (1!=fscanf(progFile,"%i",&count)) + { + cmSystemTools::Message("Could not read from progress file."); + } fclose(progFile); } unsigned int i; @@ -1469,7 +1475,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) std::string homeOutDir; std::string startOutDir; std::string depInfo; - bool color = true; + bool color = false; if(args.size() >= 8) { // Full signature: @@ -1487,11 +1493,12 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) startOutDir = args[6]; depInfo = args[7]; if(args.size() >= 9 && - args[8].length() > 8 && + args[8].length() >= 8 && args[8].substr(0, 8) == "--color=") { // Enable or disable color based on the switch value. - color = cmSystemTools::IsOn(args[8].substr(8).c_str()); + color = (args[8].size() == 8 || + cmSystemTools::IsOn(args[8].substr(8).c_str())); } } else diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 4173413..cd427cb 100644 --- a/Source/cmakewizard.cxx +++ b/Source/cmakewizard.cxx @@ -28,8 +28,10 @@ void cmakewizard::AskUser(const char* key, printf("Current Value: %s\n", iter.GetValue()); printf("New Value (Enter to keep current value): "); char buffer[4096]; - buffer[0] = 0; - fgets(buffer, sizeof(buffer)-1, stdin); + if(!fgets(buffer, sizeof(buffer)-1, stdin)) + { + buffer[0] = 0; + } if(strlen(buffer) > 0) { @@ -65,8 +67,10 @@ bool cmakewizard::AskAdvanced() { printf("Would you like to see advanced options? [No]:"); char buffer[4096]; - buffer[0] = 0; - fgets(buffer, sizeof(buffer)-1, stdin); + if(!fgets(buffer, sizeof(buffer)-1, stdin)) + { + buffer[0] = 0; + } if(buffer[0]) { if(buffer[0] == 'y' || buffer[0] == 'Y') diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 391a2c5..23d396f 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -242,6 +242,8 @@ protected: // For Mac bool ParseSysCtl(); + void CallSwVers(); + void TrimNewline(kwsys_stl::string&); kwsys_stl::string ExtractValueFromSysCtl(const char* word); kwsys_stl::string SysCtlBuffer; @@ -3006,13 +3008,13 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha if(buffer[i] == ' ' || buffer[i] == '\t') { break; - } + } if(buffer[i] != '\n' && buffer[i] != '\r') { kwsys_stl::string val = value; value = buffer[i]; value += val; - } + } } return value; } @@ -3356,6 +3358,12 @@ bool SystemInformationImplementation::QueryOSInformation() WSACleanup( ); } this->Hostname = name; + + const char* arch = getenv("PROCESSOR_ARCHITECTURE"); + if(arch) + { + this->OSPlatform = arch; + } #else @@ -3369,12 +3377,64 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSVersion = unameInfo.version; this->OSPlatform = unameInfo.machine; } +#ifdef __APPLE__ + this->CallSwVers(); +#endif #endif return true; } +void SystemInformationImplementation::CallSwVers() +{ +#ifdef __APPLE__ + kwsys_stl::string output; + kwsys_stl::vector<const char*> args; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-productName"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSName = output; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-productVersion"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSRelease = output; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-buildVersion"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSVersion = output; +#endif +} + +void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output) +{ + // remove \r + kwsys_stl::string::size_type pos=0; + while((pos = output.find("\r", pos)) != kwsys_stl::string::npos) + { + output.erase(pos); + } + + // remove \n + pos = 0; + while((pos = output.find("\n", pos)) != kwsys_stl::string::npos) + { + output.erase(pos); + } +} + /** Return true if the machine is 64 bits */ bool SystemInformationImplementation::Is64Bits() { |