diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-10-28 16:17:18 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-10-28 16:17:18 (GMT) |
commit | b4ae8bad4b8e7810a44e2f77363de3009260a473 (patch) | |
tree | 7dd8a97d409c6339948ac4b3e0eda77cd9b7384e /Source | |
parent | ebd0c2d3771835a1317c1fd70eafd3ebf2135b01 (diff) | |
download | CMake-b4ae8bad4b8e7810a44e2f77363de3009260a473.zip CMake-b4ae8bad4b8e7810a44e2f77363de3009260a473.tar.gz CMake-b4ae8bad4b8e7810a44e2f77363de3009260a473.tar.bz2 |
RC 4 merge
Diffstat (limited to 'Source')
39 files changed, 1014 insertions, 557 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d188b11..9099691 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -303,6 +303,8 @@ IF (WIN32) cmLocalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.cxx + cmGlobalVisualStudio10Win64Generator.h + cmGlobalVisualStudio10Win64Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmGlobalWatcomWMakeGenerator.cxx diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 1c56d81..391093a 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -23,7 +23,6 @@ #include <cmsys/SystemTools.hxx> #include <cm_zlib.h> #include <libtar/libtar.h> -#include <memory> // auto_ptr #include <fcntl.h> #include <errno.h> @@ -219,9 +218,8 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, &mydata }; - // Ok, this libtar is not const safe. for now use auto_ptr hack + // Ok, this libtar is not const safe. Make a non-const copy of outFileName char* realName = new char[ strlen(outFileName) + 1 ]; - std::auto_ptr<char> realNamePtr(realName); strcpy(realName, outFileName); int flags = O_WRONLY | O_CREAT; int options = 0; @@ -239,6 +237,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): " << strerror(errno) << std::endl); + delete [] realName; return 0; } @@ -257,6 +256,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, << pathname << "\"): " << strerror(errno) << std::endl); tar_close(t); + delete [] realName; return 0; } } @@ -265,6 +265,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_append_eof(): " << strerror(errno) << std::endl); tar_close(t); + delete [] realName; return 0; } @@ -272,8 +273,10 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_close(): " << strerror(errno) << std::endl); + delete [] realName; return 0; } + delete [] realName; return 1; } diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx index 7c33d70..00bb6fa 100644 --- a/Source/CTest/cmCTestBatchTestHandler.cxx +++ b/Source/CTest/cmCTestBatchTestHandler.cxx @@ -25,7 +25,7 @@ cmCTestBatchTestHandler::~cmCTestBatchTestHandler() void cmCTestBatchTestHandler::RunTests() { this->WriteBatchScript(); - //this->SubmitBatchScript(); + this->SubmitBatchScript(); } //--------------------------------------------------------- @@ -128,16 +128,16 @@ void cmCTestBatchTestHandler::SubmitBatchScript() args.push_back(this->Script); args.push_back("-o"); args.push_back(this->CTest->GetBinaryDir() - + "/Testing/CTestBatchOutput.txt"); + + "/Testing/CTestBatch.txt"); sbatch.SetCommand("sbatch"); sbatch.SetCommandArguments(args); - if(sbatch.StartProcess()) + /*if(sbatch.StartProcess()) { //success condition } else { //fail condition - } + }*/ } diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 46d9f26..8a2d65a 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -251,7 +251,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) tarIt != this->BuildTargets.end(); ++ tarIt ) { double remainingTime = 0; - if (this->Timeout) + if (this->Timeout > 0) { remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; if (remainingTime <= 0) @@ -376,7 +376,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // how much time is remaining double remainingTime = 0; - if (this->Timeout) + if (this->Timeout > 0) { remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; if (remainingTime <= 0) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index c2135aa..1076886 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -677,6 +677,24 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) #endif //---------------------------------------------------------------------- +bool IsFileInDir(const std::string &infile, const std::string &indir) +{ + std::string file = cmSystemTools::CollapseFullPath(infile.c_str()); + std::string dir = cmSystemTools::CollapseFullPath(indir.c_str()); + + if ( + file.size() > dir.size() && + (fnc(file.substr(0, dir.size())) == fnc(dir)) && + file[dir.size()] == '/' + ) + { + return true; + } + + return false; +} + +//---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) { @@ -735,16 +753,27 @@ int cmCTestCoverageHandler::HandleGCovCoverage( " Processing coverage (each . represents one file):" << std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); int file_count = 0; + // make sure output from gcov is in English! cmSystemTools::PutEnv("LC_ALL=POSIX"); + + // files is a list of *.da and *.gcda files with coverage data in them. + // These are binary files that you give as input to gcov so that it will + // give us text output we can analyze to summarize coverage. + // for ( it = files.begin(); it != files.end(); ++ it ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); + + // Call gcov to get coverage data for this *.gcda file: + // std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir + "\" \"" + *it + "\""; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); + std::string output = ""; std::string errors = ""; int retVal = 0; @@ -777,149 +806,151 @@ int cmCTestCoverageHandler::HandleGCovCoverage( << output << std::endl << "--------------------------------------------------------------" << std::endl); + std::vector<cmStdString> lines; std::vector<cmStdString>::iterator line; - - // Globals for storing current source file and current gcov file; cmSystemTools::Split(output.c_str(), lines); + for ( line = lines.begin(); line != lines.end(); ++line) { std::string sourceFile; std::string gcovFile; + cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]" << std::endl); + if ( line->size() == 0 ) { // Ignore empty line; probably style 2 } else if ( st1re1.find(line->c_str()) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 1 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 1; } + if ( gcovStyle != 1 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e1" + << std::endl); + cont->Error ++; + break; + } actualSourceFile = ""; sourceFile = st1re1.match(2); } else if ( st1re2.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 1 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 1; } + if ( gcovStyle != 1 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e2" + << std::endl); + cont->Error ++; + break; + } gcovFile = st1re2.match(1); } else if ( st2re1.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e3" + << std::endl); + cont->Error ++; + break; + } actualSourceFile = ""; sourceFile = st2re1.match(1); } else if ( st2re2.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e4" + << std::endl); + cont->Error ++; + break; + } } else if ( st2re3.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e5" + << std::endl); + cont->Error ++; + break; + } gcovFile = st2re3.match(2); } else if ( st2re4.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e6" + << std::endl); + cont->Error ++; + break; + } cmCTestLog(this->CTest, WARNING, "Warning: " << st2re4.match(1) << " had unexpected EOF" << std::endl); } else if ( st2re5.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e7" + << std::endl); + cont->Error ++; + break; + } cmCTestLog(this->CTest, WARNING, "Warning: Cannot open file: " << st2re5.match(1) << std::endl); } else if ( st2re6.find(line->c_str() ) ) { - if ( gcovStyle != 0 ) + if ( gcovStyle == 0 ) { - if ( gcovStyle != 2 ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" - << std::endl); - cont->Error ++; - break; - } gcovStyle = 2; } + if ( gcovStyle != 2 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e8" + << std::endl); + cont->Error ++; + break; + } cmCTestLog(this->CTest, WARNING, "Warning: File: " << st2re6.match(1) << " is newer than " << st2re6.match(2) << std::endl); @@ -927,16 +958,24 @@ int cmCTestCoverageHandler::HandleGCovCoverage( else { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Unknown line: [" << line->c_str() << "]" << std::endl); + "Unknown gcov output line: [" << line->c_str() << "]" << std::endl); cont->Error ++; //abort(); } - if ( !gcovFile.empty() && actualSourceFile.size() ) + + + // If the last line of gcov output gave us a valid value for gcovFile, + // and we have an actualSourceFile, then insert a (or add to existing) + // SingleFileCoverageVector for actualSourceFile: + // + if ( !gcovFile.empty() && !actualSourceFile.empty() ) { - cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec - = &cont->TotalCoverage[actualSourceFile]; - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in file: " + cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec + = cont->TotalCoverage[actualSourceFile]; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in gcovFile: " << gcovFile << std::endl); + std::ifstream ifile(gcovFile.c_str()); if ( ! ifile ) { @@ -969,41 +1008,45 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // line std::string prefix = nl.substr(0, 12); int cov = atoi(prefix.c_str()); + // Read the line number starting at the 10th character of the gcov // output line std::string lineNumber = nl.substr(10, 5); + int lineIdx = atoi(lineNumber.c_str())-1; if ( lineIdx >= 0 ) { - while ( vec->size() <= - static_cast<size_t>(lineIdx) ) + while ( vec.size() <= static_cast<size_t>(lineIdx) ) { - vec->push_back(-1); + vec.push_back(-1); } + // Initially all entries are -1 (not used). If we get coverage // information, increment it to 0 first. - if ( (*vec)[lineIdx] < 0 ) + if ( vec[lineIdx] < 0 ) { if ( cov > 0 || prefix.find("#") != prefix.npos ) { - (*vec)[lineIdx] = 0; + vec[lineIdx] = 0; } } - (*vec)[lineIdx] += cov; + + vec[lineIdx] += cov; } } } + actualSourceFile = ""; } + + if ( !sourceFile.empty() && actualSourceFile.empty() ) { gcovFile = ""; - // Is it in the source dir? - if ( sourceFile.size() > cont->SourceDir.size() && - (fnc(sourceFile.substr(0, cont->SourceDir.size())) == - fnc(cont->SourceDir)) && - sourceFile[cont->SourceDir.size()] == '/' ) + // Is it in the source dir or the binary dir? + // + if ( IsFileInDir(sourceFile, cont->SourceDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " << sourceFile.c_str() << std::endl); @@ -1012,12 +1055,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } - - // Binary dir? - if ( sourceFile.size() > cont->BinaryDir.size() && - (fnc(sourceFile.substr(0, cont->BinaryDir.size())) == - fnc(cont->BinaryDir)) && - sourceFile[cont->BinaryDir.size()] == '/' ) + else if ( IsFileInDir(sourceFile, cont->BinaryDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " << sourceFile.c_str() << std::endl); @@ -1029,7 +1067,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( actualSourceFile.empty() ) { - if ( missingFiles.find(actualSourceFile) == missingFiles.end() ) + if ( missingFiles.find(sourceFile) == missingFiles.end() ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" << std::endl); @@ -1048,12 +1086,15 @@ int cmCTestCoverageHandler::HandleGCovCoverage( << sourceFile.c_str() << " in source dir: " << cont->SourceDir.c_str() << " or binary dir: " << cont->BinaryDir.c_str() << std::endl; - missingFiles.insert(actualSourceFile); + + missingFiles.insert(sourceFile); } } } } - file_count ++; + + file_count++; + if ( file_count % 50 == 0 ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count @@ -1061,6 +1102,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); } } + cmSystemTools::ChangeDirectory(currentDirectory.c_str()); return file_count; } diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 63dfe7e..024599c 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -81,6 +81,10 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler); testRun->SetIndex(test); testRun->SetTestProperties(this->Properties[test]); + + std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(this->Properties[test]->Directory.c_str()); + if(testRun->StartTest(this->Total)) { this->RunningTests.insert(testRun); @@ -92,6 +96,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) testRun->EndTest(this->Completed, this->Total, false); this->Failed->push_back(this->Properties[test]->Name); } + cmSystemTools::ChangeDirectory(current_dir.c_str()); } //--------------------------------------------------------- @@ -339,6 +344,9 @@ void cmCTestMultiProcessHandler::PrintTestList() { count++; cmCTestTestHandler::cmCTestTestProperties& p = *it->second; + //push working dir + std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(p.Directory.c_str()); cmCTestRunTest testRun(this->TestHandler); testRun.SetIndex(p.Index); @@ -360,6 +368,8 @@ void cmCTestMultiProcessHandler::PrintTestList() << indexStr.str().c_str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl); + //pop working dir + cmSystemTools::ChangeDirectory(current_dir.c_str()); } cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: " << this->Total << std::endl); diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 982beb3..3e4757b 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -301,7 +301,7 @@ bool cmCTestRunTest::StartTest(size_t total) { cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2*getNumWidth(total) + 8) << "Start " - << std::setw(getNumWidth(total)) + << std::setw(getNumWidth(this->TestHandler->GetMaxIndex())) << this->TestProperties->Index << ": " << this->TestProperties->Name << std::endl); this->ComputeArguments(); @@ -419,11 +419,11 @@ bool cmCTestRunTest::CreateProcess(double testTimeOut, // determine how much time we have double timeout = this->CTest->GetRemainingTimeAllowed() - 120; - if (this->CTest->GetTimeOut() && this->CTest->GetTimeOut() < timeout) + if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout) { timeout = this->CTest->GetTimeOut(); } - if (testTimeOut + if (testTimeOut > 0 && testTimeOut < this->CTest->GetRemainingTimeAllowed()) { timeout = testTimeOut; diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 7bc6f72..f19a36d 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -16,11 +16,6 @@ #include <QTranslator> #include <QLocale> #include "QMacInstallDialog.h" - -#ifdef Q_OS_WIN -#include "windows.h" // for SetErrorMode -#endif - #include "CMakeSetupDialog.h" #include "cmDocumentation.h" #include "cmake.h" @@ -103,10 +98,6 @@ int main(int argc, char** argv) } QApplication app(argc, argv); -#ifdef Q_OS_WIN - // QApplication changes error mode, let's put it back - SetErrorMode(0); -#endif // clean out standard Qt paths for plugins, which we don't use anyway // when creating Mac bundles, it potentially causes problems diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 3bd64f0..dc31fad 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -20,6 +20,10 @@ #include "cmSystemTools.h" #include "cmExternalMakefileProjectGenerator.h" +#ifdef Q_OS_WIN +#include "qt_windows.h" // For SetErrorMode +#endif + QCMake::QCMake(QObject* p) : QObject(p) { @@ -148,6 +152,10 @@ void QCMake::setGenerator(const QString& gen) void QCMake::configure() { +#ifdef Q_OS_WIN + UINT lastErrorMode = SetErrorMode(0); +#endif + this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toAscii().data()); this->CMakeInstance->SetStartDirectory(this->SourceDirectory.toAscii().data()); this->CMakeInstance->SetHomeOutputDirectory(this->BinaryDirectory.toAscii().data()); @@ -162,14 +170,27 @@ void QCMake::configure() int err = this->CMakeInstance->Configure(); +#ifdef Q_OS_WIN + SetErrorMode(lastErrorMode); +#endif + emit this->propertiesChanged(this->properties()); emit this->configureDone(err); } void QCMake::generate() { +#ifdef Q_OS_WIN + UINT lastErrorMode = SetErrorMode(0); +#endif + cmSystemTools::ResetErrorOccuredFlag(); int err = this->CMakeInstance->Generate(); + +#ifdef Q_OS_WIN + SetErrorMode(lastErrorMode); +#endif + emit this->generateDone(err); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index fa6333f..6d21ab5 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -564,6 +564,7 @@ bool cmCTest::UpdateCTestConfiguration() << fileName.c_str() << "\n"); // parse the dart test file std::ifstream fin(fileName.c_str()); + if(!fin) { return false; @@ -1081,11 +1082,11 @@ int cmCTest::RunTest(std::vector<const char*> argv, // determine how much time we have double timeout = this->GetRemainingTimeAllowed() - 120; - if (this->TimeOut && this->TimeOut < timeout) + if (this->TimeOut > 0 && this->TimeOut < timeout) { timeout = this->TimeOut; } - if (testTimeOut + if (testTimeOut > 0 && testTimeOut < this->GetRemainingTimeAllowed()) { timeout = testTimeOut; @@ -1117,7 +1118,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, // make sure we pass the timeout in for any build and test // invocations. Since --build-generator is required this is a // good place to check for it, and to add the arguments in - if (strcmp(argv[i],"--build-generator") == 0 && timeout) + if (strcmp(argv[i],"--build-generator") == 0 && timeout > 0) { args.push_back("--test-timeout"); cmOStringStream msg; @@ -1265,6 +1266,11 @@ void cmCTest::StartXML(std::ostream& ostr, bool append) << this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest-" << cmVersion::GetCMakeVersion() << "\"\n" << (append? "\tAppend=\"true\"\n":"") + << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler") + << "\"\n" +#ifdef _COMPILER_VERSION + << "\tCompilerVersion=\"_COMPILER_VERSION\"\n" +#endif << "\tOSName=\"" << info.GetOSName() << "\"\n" << "\tHostname=\"" << info.GetHostname() << "\"\n" << "\tOSRelease=\"" << info.GetOSRelease() << "\"\n" @@ -2363,7 +2369,7 @@ void cmCTest::EmptyCTestConfiguration() void cmCTest::SetCTestConfiguration(const char *name, const char* value) { cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:" - << name << ":" << value << "\n"); + << name << ":" << (value ? value : "(null)") << "\n"); if ( !name ) { diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index ace67ec..234c37e 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -65,7 +65,11 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, if ( !key ) { return this->ExpandVariable(var); - } + } + if(!var) + { + return this->EmptyVariable; + } if ( strcmp(key, "ENV") == 0 ) { char *ptr = getenv(var); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 4746f06..dab0c0d 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -317,7 +317,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if ((res==0) && (copyFile.size())) { - if(!cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), + if(this->OutputFile.empty() || + !cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyFile.c_str())) { cmOStringStream emsg; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index f272262..4bedea3 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -194,7 +194,7 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders, { virtualFolders += "CMake Files\\" + prefix + path + "\\;"; for (std::vector<Tree>::const_iterator it = folders.begin(); - it != folders.end(); + it != folders.end(); ++it) { it->BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\"); @@ -263,37 +263,45 @@ void cmExtraCodeBlocksGenerator it != this->GlobalGenerator->GetProjectMap().end(); ++it) { - // Convert - std::vector<std::string> listFiles = - it->second[0]->GetMakefile()->GetListFiles(); + // Collect all files + std::vector<std::string> listFiles; + for (std::vector<cmLocalGenerator *>::const_iterator + jt = it->second.begin(); + jt != it->second.end(); + ++jt) + { + const std::vector<std::string> & files = + (*jt)->GetMakefile()->GetListFiles(); + listFiles.insert(listFiles.end(), files.begin(), files.end()); + } - for (std::vector<std::string>::const_iterator jt = listFiles.begin(); - jt != listFiles.end(); - ++jt) - { - const std::string &relative = - cmSystemTools::RelativePath( + // Convert + for (std::vector<std::string>::const_iterator jt = listFiles.begin(); + jt != listFiles.end(); + ++jt) + { + const std::string &relative = cmSystemTools::RelativePath( it->second[0]->GetMakefile()->GetHomeDirectory(), jt->c_str()); - std::vector<std::string> splitted; - cmSystemTools::SplitPath(relative.c_str(), splitted, false); - // Split filename from path - std::string fileName = *(splitted.end()-1); - splitted.erase(splitted.end() - 1, splitted.end()); - - // We don't want paths with ".." in them - // reasons are that we don't want files outside the project - // TODO: the path should be normalized first though - // We don't want paths with CMakeFiles in them - // or do we? - // In speedcrunch those where purely internal - if (splitted.size() >= 1 - && relative.find("..") == std::string::npos - && relative.find("CMakeFiles") == std::string::npos) - { - tree.InsertPath(splitted, 1, fileName); - } - } + std::vector<std::string> splitted; + cmSystemTools::SplitPath(relative.c_str(), splitted, false); + // Split filename from path + std::string fileName = *(splitted.end()-1); + splitted.erase(splitted.end() - 1, splitted.end()); + + // We don't want paths with ".." in them + // reasons are that we don't want files outside the project + // TODO: the path should be normalized first though + // We don't want paths with CMakeFiles in them + // or do we? + // In speedcrunch those where purely internal + if (splitted.size() >= 1 + && relative.find("..") == std::string::npos + && relative.find("CMakeFiles") == std::string::npos) + { + tree.InsertPath(splitted, 1, fileName); + } + } } // Now build a virtual tree string @@ -329,68 +337,73 @@ void cmExtraCodeBlocksGenerator for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ti++) { - switch(ti->second.GetType()) + switch(ti->second.GetType()) { - case cmTarget::GLOBAL_TARGET: + case cmTarget::GLOBAL_TARGET: + { + bool insertTarget = false; + // Only add the global targets from CMAKE_BINARY_DIR, + // not from the subdirs + if (strcmp(makefile->GetStartOutputDirectory(), + makefile->GetHomeOutputDirectory())==0) { - bool insertTarget = false; - // Only add the global targets from CMAKE_BINARY_DIR, - // not from the subdirs - if (strcmp(makefile->GetStartOutputDirectory(), - makefile->GetHomeOutputDirectory())==0) + insertTarget = true; + // only add the "edit_cache" target if it's not ccmake, because + // this will not work within the IDE + if (ti->first == "edit_cache") { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") + const char* editCommand = makefile->GetDefinition + ("CMAKE_EDIT_COMMAND"); + if (editCommand == 0) { - if (strstr(makefile->GetRequiredDefinition - ("CMAKE_EDIT_COMMAND"), "ccmake")!=NULL) - { - insertTarget = false; - } + insertTarget = false; + } + else if (strstr(editCommand, "ccmake")!=NULL) + { + insertTarget = false; } } - if (insertTarget) - { - this->AppendTarget(fout, ti->first.c_str(), 0, + } + if (insertTarget) + { + this->AppendTarget(fout, ti->first.c_str(), 0, make.c_str(), makefile, compiler.c_str()); - } } - break; - case cmTarget::UTILITY: - // Add all utility targets, except the Nightly/Continuous/ - // Experimental-"sub"targets as e.g. NightlyStart - if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) + } + break; + case cmTarget::UTILITY: + // Add all utility targets, except the Nightly/Continuous/ + // Experimental-"sub"targets as e.g. NightlyStart + if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) || ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous")) || ((ti->first.find("Experimental")==0) && (ti->first!="Experimental"))) - { - break; - } - - this->AppendTarget(fout, ti->first.c_str(), 0, - make.c_str(), makefile, compiler.c_str()); - break; - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: { - this->AppendTarget(fout, ti->first.c_str(), &ti->second, - make.c_str(), makefile, compiler.c_str()); - std::string fastTarget = ti->first; - fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget.c_str(), &ti->second, - make.c_str(), makefile, compiler.c_str()); - } - break; - // ignore these: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: - default: break; + } + + this->AppendTarget(fout, ti->first.c_str(), 0, + make.c_str(), makefile, compiler.c_str()); + break; + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + this->AppendTarget(fout, ti->first.c_str(), &ti->second, + make.c_str(), makefile, compiler.c_str()); + std::string fastTarget = ti->first; + fastTarget += "/fast"; + this->AppendTarget(fout, fastTarget.c_str(), &ti->second, + make.c_str(), makefile, compiler.c_str()); + } + break; + // ignore these: + case cmTarget::INSTALL_FILES: + case cmTarget::INSTALL_PROGRAMS: + case cmTarget::INSTALL_DIRECTORY: + default: + break; } } } @@ -668,7 +681,7 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) return 2; } else if ((target->GetType()==cmTarget::SHARED_LIBRARY) - || (target->GetType()==cmTarget::MODULE_LIBRARY)) + || (target->GetType()==cmTarget::MODULE_LIBRARY)) { return 3; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 61be233..0a5101f 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -727,8 +727,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // this will not work within the IDE if (ti->first == "edit_cache") { - if (strstr(makefile->GetRequiredDefinition - ("CMAKE_EDIT_COMMAND"), "ccmake")!=NULL) + const char* editCommand = makefile->GetDefinition + ("CMAKE_EDIT_COMMAND"); + if (editCommand == 0) + { + insertTarget = false; + } + else if (strstr(editCommand, "ccmake")!=NULL) { insertTarget = false; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index abe6bc9..bce4137 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2290,7 +2290,7 @@ bool cmFileCommand::HandleRelativePathCommand( { if(args.size() != 4 ) { - this->SetError("called with incorrect number of arguments"); + this->SetError("RELATIVE_PATH called with incorrect number of arguments"); return false; } @@ -2301,7 +2301,7 @@ bool cmFileCommand::HandleRelativePathCommand( if(!cmSystemTools::FileIsFullPath(directoryName.c_str())) { std::string errstring = - "RelativePath must be passed a full path to the directory: " + "RELATIVE_PATH must be passed a full path to the directory: " + directoryName; this->SetError(errstring.c_str()); return false; @@ -2309,7 +2309,7 @@ bool cmFileCommand::HandleRelativePathCommand( if(!cmSystemTools::FileIsFullPath(fileName.c_str())) { std::string errstring = - "RelativePath must be passed a full path to the file: " + "RELATIVE_PATH must be passed a full path to the file: " + fileName; this->SetError(errstring.c_str()); return false; @@ -2328,7 +2328,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args) { if(args.size() != 3) { - this->SetError("given incorrect number of arguments."); + this->SetError("RENAME given incorrect number of arguments."); return false; } @@ -2400,8 +2400,8 @@ bool cmFileCommand::HandleCMakePathCommand(std::vector<std::string> std::vector<std::string>::const_iterator i = args.begin(); if(args.size() != 3) { - this->SetError("FILE(SYSTEM_PATH ENV result) must be called with " - "only three arguments."); + this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " + "called with exactly three arguments."); return false; } i++; // Get rid of subcommand @@ -2465,17 +2465,48 @@ namespace{ cmFileCommandVectorOfChar *vec = static_cast<cmFileCommandVectorOfChar*>(data); vec->insert(vec->end(), chPtr, chPtr + size); - + return size; } - - + + } #endif -bool -cmFileCommand::HandleDownloadCommand(std::vector<std::string> +#if defined(CMAKE_BUILD_WITH_CMAKE) +namespace { + + class cURLEasyGuard + { + public: + cURLEasyGuard(CURL * easy) + : Easy(easy) + {} + + ~cURLEasyGuard(void) + { + if (this->Easy) + { + ::curl_easy_cleanup(this->Easy); + } + } + + inline void release(void) + { + this->Easy = 0; + return; + } + + private: + ::CURL * Easy; + }; + +} +#endif + +bool +cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -2486,25 +2517,25 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> "at least three arguments."); return false; } - i++; // Get rid of subcommand + ++i; // Get rid of subcommand std::string url = *i; - i++; + ++i; std::string file = *i; - i++; - double timeout = 0; + ++i; + long timeout = 0; std::string verboseLog; std::string statusVar; while(i != args.end()) { if(*i == "TIMEOUT") { - i++; + ++i; if(i != args.end()) { - timeout = atof(i->c_str()); + timeout = atol(i->c_str()); } else - { + { this->SetError("FILE(DOWNLOAD url file TIMEOUT time) missing " "time for TIMEOUT."); return false; @@ -2512,7 +2543,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> } else if(*i == "LOG") { - i++; + ++i; if( i == args.end()) { this->SetError("FILE(DOWNLOAD url file LOG VAR) missing " @@ -2523,7 +2554,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> } else if(*i == "STATUS") { - i++; + ++i; if( i == args.end()) { this->SetError("FILE(DOWNLOAD url file STATUS VAR) missing " @@ -2532,15 +2563,16 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> } statusVar = *i; } - i++; + ++i; } std::string dir = cmSystemTools::GetFilenamePath(file.c_str()); if(!cmSystemTools::FileExists(dir.c_str()) && !cmSystemTools::MakeDirectory(dir.c_str())) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot create directory: " - + dir + ". Maybe need administrative privileges."; + std::string errstring = "DOWNLOAD error: cannot create directory '" + + dir + "' - Specify file by full path name and verify that you " + "have directory creation and file write privileges."; this->SetError(errstring.c_str()); return false; } @@ -2552,50 +2584,106 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> "file for write."); return false; } - CURL *curl; - curl_global_init(CURL_GLOBAL_DEFAULT); - curl = curl_easy_init(); + ::CURL *curl; + ::curl_global_init(CURL_GLOBAL_DEFAULT); + curl = ::curl_easy_init(); if(!curl) { this->SetError("FILE(DOWNLOAD ) error " "initializing curl."); return false; } - - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, - cmFileCommandWriteMemoryCallback); - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, - cmFileCommandCurlDebugCallback); + + cURLEasyGuard g_curl(curl); + + ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + if (res != CURLE_OK) + { + std::string errstring = "FILE(DOWNLOAD ) error; cannot set url: "; + errstring += ::curl_easy_strerror(res); + return false; + } + + res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmFileCommandWriteMemoryCallback); + if (res != CURLE_OK) + { + std::string errstring = + "FILE(DOWNLOAD ) error; cannot set write function: "; + errstring += ::curl_easy_strerror(res); + return false; + } + + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmFileCommandCurlDebugCallback); + if (res != CURLE_OK) + { + std::string errstring = + "FILE(DOWNLOAD ) error; cannot set debug function: "; + errstring += ::curl_easy_strerror(res); + return false; + } + cmFileCommandVectorOfChar chunkDebug; - ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&fout); - ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); + + res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&fout); + + if (res != CURLE_OK) + { + std::string errstring = "FILE(DOWNLOAD ) error; cannot set write data: "; + errstring += ::curl_easy_strerror(res); + return false; + } + + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); + if (res != CURLE_OK) + { + std::string errstring = "FILE(DOWNLOAD ) error; cannot set write data: "; + errstring += ::curl_easy_strerror(res); + return false; + } + if(verboseLog.size()) { - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + if (res != CURLE_OK) + { + std::string errstring = "FILE(DOWNLOAD ) error; cannot set verbose: "; + errstring += ::curl_easy_strerror(res); + return false; + } } if(timeout > 0) { - curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout ); + res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout ); + + if (res != CURLE_OK) + { + std::string errstring = "FILE(DOWNLOAD ) error; cannot set verbose: "; + errstring += ::curl_easy_strerror(res); + return false; + } } - CURLcode res = curl_easy_perform(curl); + res = ::curl_easy_perform(curl); /* always cleanup */ - curl_easy_cleanup(curl); + g_curl.release(); + ::curl_easy_cleanup(curl); if(statusVar.size()) { cmOStringStream result; - result << (int)res << ";\"" << curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar.c_str(), + result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; + this->Makefile->AddDefinition(statusVar.c_str(), result.str().c_str()); } - curl_global_cleanup(); + ::curl_global_cleanup(); if(chunkDebug.size()) { chunkDebug.push_back(0); if(CURLE_OPERATION_TIMEOUTED == res) - { + { std::string output = &*chunkDebug.begin(); - + if(verboseLog.size()) { this->Makefile->AddDefinition(verboseLog.c_str(), @@ -2607,9 +2695,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> &*chunkDebug.begin()); } return true; -#else +#else this->SetError("FILE(DOWNLOAD ) " "not supported in bootstrap cmake "); return false; -#endif +#endif } diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index d753862..c6da301 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -152,7 +152,7 @@ public: "and the second element is a string value for the error. A 0 " "numeric error means no error in the operation. " "If TIMEOUT time is specified, the operation will " - "timeout after time seconds, time can be specified as a float." + "timeout after time seconds, time should be specified as an integer." "\n" "The file() command also provides COPY and INSTALL signatures:\n" " file(<COPY|INSTALL> files... DESTINATION <dir>\n" diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index b6ae951..abe66a8 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -31,13 +31,14 @@ void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n"; - fout << "# Visual Studio 10\n"; + fout << "# Visual Studio 2010\n"; } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { - cmLocalGenerator*lg = new cmLocalVisualStudio10Generator; + cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator; + lg->SetPlatformName(this->PlatformName.c_str()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx new file mode 100644 index 0000000..0e821c7 --- /dev/null +++ b/Source/cmGlobalVisualStudio10Win64Generator.cxx @@ -0,0 +1,37 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio10Win64Generator.h" +#include "cmMakefile.h" +#include "cmake.h" + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() +{ + this->PlatformName = "x64"; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Win64Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 10 Win64 project files."; + entry.Full = ""; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Win64Generator::EnableLanguage( + std::vector<std::string> const& lang, cmMakefile *mf, bool optional) +{ + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + cmGlobalVisualStudio10Generator::EnableLanguage(lang, mf, optional); +} diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h new file mode 100644 index 0000000..51b68c0 --- /dev/null +++ b/Source/cmGlobalVisualStudio10Win64Generator.h @@ -0,0 +1,36 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio10Win64Generator_h +#define cmGlobalVisualStudio10Win64Generator_h + +#include "cmGlobalVisualStudio10Generator.h" + +class cmGlobalVisualStudio10Win64Generator : + public cmGlobalVisualStudio10Generator +{ +public: + cmGlobalVisualStudio10Win64Generator(); + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio10Win64Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio10Win64Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 10 Win64";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + virtual void EnableLanguage(std::vector<std::string>const& languages, + cmMakefile *, bool optional); +}; +#endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index dbe9aed..ea9065e 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -615,13 +615,6 @@ 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 73302bc..85ba244 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -92,6 +92,10 @@ public: ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGInitDirectory() { return "$(OutDir)"; } + /** Return true if the target project file should have the option + LinkLibraryDependencies and link to .sln dependencies. */ + virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; } + protected: virtual const char* GetIDEVersion() { return "7.0"; } @@ -133,7 +137,6 @@ 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/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 1084fa9..8aec865 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -110,132 +110,123 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Generator::Generate() +void cmGlobalVisualStudio8Generator::AddCheckTarget() { // Add a special target on which all other targets depend that // checks the build system and optionally re-runs CMake. const char* no_working_directory = 0; std::vector<std::string> no_depends; - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; - for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { - std::vector<cmLocalGenerator*>& generators = it->second; - if(!generators.empty()) - { - // Add the build-system check target to the first local - // generator of this project. - cmLocalVisualStudio7Generator* lg = - static_cast<cmLocalVisualStudio7Generator*>(generators[0]); - cmMakefile* mf = lg->GetMakefile(); + std::vector<cmLocalGenerator*> const& generators = this->LocalGenerators; + cmLocalVisualStudio7Generator* lg = + static_cast<cmLocalVisualStudio7Generator*>(generators[0]); + cmMakefile* mf = lg->GetMakefile(); - // Skip the target if no regeneration is to be done. - if(mf->IsOn("CMAKE_SUPPRESS_REGENERATION")) - { - continue; - } + // Skip the target if no regeneration is to be done. + if(mf->IsOn("CMAKE_SUPPRESS_REGENERATION")) + { + return; + } - std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); - cmCustomCommandLines noCommandLines; - mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, - no_working_directory, no_depends, - noCommandLines); - cmTarget* tgt = mf->FindTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET); - if(!tgt) - { - cmSystemTools::Error("Error adding target " - CMAKE_CHECK_BUILD_SYSTEM_TARGET); - continue; - } + std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); + cmCustomCommandLines noCommandLines; + cmTarget* tgt = + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, + no_working_directory, no_depends, + noCommandLines); - // Create a list of all stamp files for this project. - std::vector<std::string> stamps; - std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); - stampList += "generate.stamp.list"; - { - std::string stampListFile = - generators[0]->GetMakefile()->GetCurrentOutputDirectory(); - stampListFile += "/"; - stampListFile += stampList; - std::string stampFile; - cmGeneratedFileStream fout(stampListFile.c_str()); - for(std::vector<cmLocalGenerator*>::const_iterator - gi = generators.begin(); gi != generators.end(); ++gi) - { - stampFile = (*gi)->GetMakefile()->GetCurrentOutputDirectory(); - stampFile += "/"; - stampFile += cmake::GetCMakeFilesDirectoryPostSlash(); - stampFile += "generate.stamp"; - stampFile = generators[0]->Convert(stampFile.c_str(), - cmLocalGenerator::START_OUTPUT); - fout << stampFile << "\n"; - stamps.push_back(stampFile); - } - } + // Create a list of all stamp files for this project. + std::vector<std::string> stamps; + std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); + stampList += "generate.stamp.list"; + { + std::string stampListFile = + generators[0]->GetMakefile()->GetCurrentOutputDirectory(); + stampListFile += "/"; + stampListFile += stampList; + std::string stampFile; + cmGeneratedFileStream fout(stampListFile.c_str()); + for(std::vector<cmLocalGenerator*>::const_iterator + gi = generators.begin(); gi != generators.end(); ++gi) + { + stampFile = (*gi)->GetMakefile()->GetCurrentOutputDirectory(); + stampFile += "/"; + stampFile += cmake::GetCMakeFilesDirectoryPostSlash(); + stampFile += "generate.stamp"; + stampFile = generators[0]->Convert(stampFile.c_str(), + cmLocalGenerator::START_OUTPUT); + fout << stampFile << "\n"; + stamps.push_back(stampFile); + } + } - // Add a custom rule to re-run CMake if any input files changed. - { - // Collect the input files used to generate all targets in this - // project. - std::vector<std::string> listFiles; - for(unsigned int j = 0; j < generators.size(); ++j) - { - cmMakefile* lmf = generators[j]->GetMakefile(); - listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(), - lmf->GetListFiles().end()); - } - // Sort the list of input files and remove duplicates. - std::sort(listFiles.begin(), listFiles.end(), - std::less<std::string>()); - std::vector<std::string>::iterator new_end = - std::unique(listFiles.begin(), listFiles.end()); - listFiles.erase(new_end, listFiles.end()); + // Add a custom rule to re-run CMake if any input files changed. + { + // Collect the input files used to generate all targets in this + // project. + std::vector<std::string> listFiles; + for(unsigned int j = 0; j < generators.size(); ++j) + { + cmMakefile* lmf = generators[j]->GetMakefile(); + listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(), + lmf->GetListFiles().end()); + } + // Sort the list of input files and remove duplicates. + std::sort(listFiles.begin(), listFiles.end(), + std::less<std::string>()); + std::vector<std::string>::iterator new_end = + std::unique(listFiles.begin(), listFiles.end()); + listFiles.erase(new_end, listFiles.end()); - // Create a rule to re-run CMake. - std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash(); - stampName += "generate.stamp"; - const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND"); - cmCustomCommandLine commandLine; - commandLine.push_back(dsprule); - std::string argH = "-H"; - argH += lg->Convert(mf->GetHomeDirectory(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::UNCHANGED, true); - commandLine.push_back(argH); - std::string argB = "-B"; - argB += lg->Convert(mf->GetHomeOutputDirectory(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::UNCHANGED, true); - commandLine.push_back(argB); - commandLine.push_back("--check-stamp-list"); - commandLine.push_back(stampList.c_str()); - commandLine.push_back("--vs-solution-file"); - commandLine.push_back("\"$(SolutionPath)\""); - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); + // Create a rule to re-run CMake. + std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash(); + stampName += "generate.stamp"; + const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND"); + cmCustomCommandLine commandLine; + commandLine.push_back(dsprule); + std::string argH = "-H"; + argH += lg->Convert(mf->GetHomeDirectory(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED, true); + commandLine.push_back(argH); + std::string argB = "-B"; + argB += lg->Convert(mf->GetHomeOutputDirectory(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED, true); + commandLine.push_back(argB); + commandLine.push_back("--check-stamp-list"); + commandLine.push_back(stampList.c_str()); + commandLine.push_back("--vs-solution-file"); + commandLine.push_back("\"$(SolutionPath)\""); + cmCustomCommandLines commandLines; + commandLines.push_back(commandLine); - // Add the rule. Note that we cannot use the CMakeLists.txt - // file as the main dependency because it would get - // overwritten by the CreateVCProjBuildRule. - // (this could be avoided with per-target source files) - const char* no_main_dependency = 0; - const char* no_working_directory = 0; - mf->AddCustomCommandToOutput( - stamps, listFiles, - no_main_dependency, commandLines, "Checking Build System", - no_working_directory, true); - std::string ruleName = stamps[0]; - ruleName += ".rule"; - if(cmSourceFile* file = mf->GetSource(ruleName.c_str())) - { - tgt->AddSourceFile(file); - } - else - { - cmSystemTools::Error("Error adding rule for ", stamps[0].c_str()); - } - } - } + // Add the rule. Note that we cannot use the CMakeLists.txt + // file as the main dependency because it would get + // overwritten by the CreateVCProjBuildRule. + // (this could be avoided with per-target source files) + const char* no_main_dependency = 0; + const char* no_working_directory = 0; + mf->AddCustomCommandToOutput( + stamps, listFiles, + no_main_dependency, commandLines, "Checking Build System", + no_working_directory, true); + std::string ruleName = stamps[0]; + ruleName += ".rule"; + if(cmSourceFile* file = mf->GetSource(ruleName.c_str())) + { + tgt->AddSourceFile(file); } + else + { + cmSystemTools::Error("Error adding rule for ", stamps[0].c_str()); + } + } +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::Generate() +{ + this->AddCheckTarget(); // All targets depend on the build-system check target. for(std::map<cmStdString,cmTarget *>::const_iterator @@ -290,6 +281,29 @@ cmGlobalVisualStudio8Generator } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( + cmTarget& target) +{ + // Look for utility dependencies that magically link. + for(std::set<cmStdString>::const_iterator ui = + target.GetUtilities().begin(); + ui != target.GetUtilities().end(); ++ui) + { + if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) + { + if(depTarget->GetProperty("EXTERNAL_MSPROJECT")) + { + // This utility dependency names an external .vcproj target. + // We use LinkLibraryDependencies="true" to link to it without + // predicting the .lib file location or name. + return true; + } + } + } + return false; +} + +//---------------------------------------------------------------------------- static cmVS7FlagTable cmVS8ExtraFlagTable[] = { {"CallingConvention", "Gd", "cdecl", "0", 0 }, diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 4313b58..9d836bd 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -38,6 +38,8 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + std::string const& GetPlatformName() const { return this->PlatformName; } + /** * Override Configure and Generate to add the build-system check * target. @@ -58,11 +60,17 @@ public: */ virtual std::string GetUserMacrosRegKeyBase(); + /** Return true if the target project file should have the option + LinkLibraryDependencies and link to .sln dependencies. */ + virtual bool NeedLinkLibraryDependencies(cmTarget& target); + protected: virtual const char* GetIDEVersion() { return "8.0"; } virtual bool VSLinksDependencies() const { return false; } + void AddCheckTarget(); + static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index d799485..0c7cf7f 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,10 +88,11 @@ protected: virtual void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); + + bool CheckTargetLinks(cmTarget& target, const char* name); private: void FixUtilityDependsForTarget(cmTarget& target); void CreateUtilityDependTarget(cmTarget& target); - bool CheckTargetLinks(cmTarget& target, const char* name); }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d2c75b2..7b27f3b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -655,6 +655,10 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, { sourcecode += ".c.c"; } + else if(lang && strcmp(lang, "Fortran") == 0) + { + sourcecode += ".fortran.f90"; + } else if(ext == "png" || ext == "gif" || ext == "jpg") { sourcecode = "image"; @@ -1833,25 +1837,25 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // VERSION -> current_version target.GetTargetVersion(false, major, minor, patch); - if(major == 0 && minor == 0 && patch == 0) + cmOStringStream v; + + // Xcode always wants at least 1.0.0 or nothing + if(!(major == 0 && minor == 0 && patch == 0)) { - // Xcode always wants at least 1.0.0 - major = 1; + v << major << "." << minor << "." << patch; } - cmOStringStream v; - v << major << "." << minor << "." << patch; buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", this->CreateString(v.str().c_str())); // SOVERSION -> compatibility_version target.GetTargetVersion(true, major, minor, patch); - if(major == 0 && minor == 0 && patch == 0) + cmOStringStream vso; + + // Xcode always wants at least 1.0.0 or nothing + if(!(major == 0 && minor == 0 && patch == 0)) { - // Xcode always wants at least 1.0.0 - major = 1; + vso << major << "." << minor << "." << patch; } - cmOStringStream vso; - vso << major << "." << minor << "." << patch; buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", this->CreateString(vso.str().c_str())); } diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index b51fabb..76bbd0c 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -16,6 +16,22 @@ #include <list> #include <cmsys/RegularExpression.hxx> + +static std::string cmIfCommandError( + cmMakefile* mf, std::vector<std::string> const& args) +{ + cmLocalGenerator* lg = mf->GetLocalGenerator(); + std::string err = "given arguments:\n "; + for(std::vector<std::string>::const_iterator i = args.begin(); + i != args.end(); ++i) + { + err += " "; + err += lg->EscapeForCMake(i->c_str()); + } + err += "\n"; + return err; +} + //========================================================================= bool cmIfFunctionBlocker:: IsFunctionBlocked(const cmListFileFunction& lff, @@ -85,16 +101,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, if (errorString.size()) { - std::string err = "given arguments\n "; - unsigned int i; - for(i =0; i < this->Functions[c].Arguments.size(); ++i) - { - err += (this->Functions[c].Arguments[i].Quoted?"\"":""); - err += this->Functions[c].Arguments[i].Value; - err += (this->Functions[c].Arguments[i].Quoted?"\"":""); - err += " "; - } - err += "\n"; + std::string err = cmIfCommandError(&mf, expandedArguments); err += errorString; mf.IssueMessage(messType, err); if (messType == cmake::FATAL_ERROR) @@ -175,16 +182,7 @@ bool cmIfCommand if (errorString.size()) { - std::string err = "given arguments\n "; - unsigned int i; - for(i =0; i < args.size(); ++i) - { - err += (args[i].Quoted?"\"":""); - err += args[i].Value; - err += (args[i].Quoted?"\"":""); - err += " "; - } - err += "\n"; + std::string err = cmIfCommandError(this->Makefile, expandedArguments); err += errorString; if (status == cmake::FATAL_ERROR) { @@ -215,84 +213,69 @@ bool cmIfCommand namespace { //========================================================================= - // returns true if succesfull, the resulting bool parsed is stored in result - bool GetBooleanValue(std::string &newArg, - cmMakefile *makefile, - bool &result, - std::string &errorString, - cmPolicies::PolicyStatus Policy12Status, - cmake::MessageType &status) + bool GetBooleanValue(std::string& arg, cmMakefile* mf) { - if (Policy12Status != cmPolicies::OLD && - Policy12Status != cmPolicies::WARN) - { - // please note IsOn(var) does not always equal !IsOff(var) - // that is why each is called - if (cmSystemTools::IsOn(newArg.c_str())) - { - result = true; - return true; - } - if (cmSystemTools::IsOff(newArg.c_str())) - { - result = false; - return true; - } - return false; - } - - // Old policy is more complex... - // 0 and 1 are very common, test for them first quickly - if (newArg == "0") + // Check basic constants. + if (arg == "0") { - result = false; - return true; + return false; } - if (newArg == "1") + if (arg == "1") { - result = true; - return true; + return true; } - // old behavior is to dereference the var - if (Policy12Status == cmPolicies::OLD) + // Check named constants. + if (cmSystemTools::IsOn(arg.c_str())) { - return false; + return true; + } + if (cmSystemTools::IsOff(arg.c_str())) + { + return false; } - // now test for values that may be the name of a variable - // warn if used - if (cmSystemTools::IsOn(newArg.c_str())) + // Check for numbers. + if(!arg.empty()) + { + char* end; + double d = strtod(arg.c_str(), &end); + if(*end == '\0') { - // only warn if the value would change - const char *def = makefile->GetDefinition(newArg.c_str()); - if (cmSystemTools::IsOff(def)) - { - cmPolicies* policies = makefile->GetPolicies(); - errorString = "A variable or argument named \"" - + newArg - + "\" appears in a conditional statement. " - + policies->GetPolicyWarning(cmPolicies::CMP0012); - status = cmake::AUTHOR_WARNING; - } - return false; + // The whole string is a number. Use C conversion to bool. + return d? true:false; } - if (cmSystemTools::IsOff(newArg.c_str())) + } + + // Check definition. + const char* def = mf->GetDefinition(arg.c_str()); + return !cmSystemTools::IsOff(def); + } + + //========================================================================= + // Boolean value behavior from CMake 2.6.4 and below. + bool GetBooleanValueOld(std::string const& arg, cmMakefile* mf, bool one) + { + if(one) + { + // Old IsTrue behavior for single argument. + if(arg == "0") + { return false; } + else if(arg == "1") + { return true; } + else + { return !cmSystemTools::IsOff(mf->GetDefinition(arg.c_str())); } + } + else + { + // Old GetVariableOrNumber behavior. + const char* def = mf->GetDefinition(arg.c_str()); + if(!def && atoi(arg.c_str())) { - // only warn if the value would change - const char *def = makefile->GetDefinition(newArg.c_str()); - if (!cmSystemTools::IsOff(def)) - { - cmPolicies* policies = makefile->GetPolicies(); - errorString = "A variable or argument named \"" - + newArg - + "\" appears in a conditional statement. " - + policies->GetPolicyWarning(cmPolicies::CMP0012); - status = cmake::AUTHOR_WARNING; - } - return false; + def = arg.c_str(); } - return false; + return !cmSystemTools::IsOff(def); + } } //========================================================================= @@ -302,16 +285,50 @@ namespace cmMakefile *makefile, std::string &errorString, cmPolicies::PolicyStatus Policy12Status, - cmake::MessageType &status) + cmake::MessageType &status, + bool oneArg = false) { - bool result = false; - if (GetBooleanValue(newArg, makefile, result, - errorString, Policy12Status, status)) + // Use the policy if it is set. + if (Policy12Status == cmPolicies::NEW) { - return result; + return GetBooleanValue(newArg, makefile); } - const char *def = makefile->GetDefinition(newArg.c_str()); - return !cmSystemTools::IsOff(def); + else if (Policy12Status == cmPolicies::OLD) + { + return GetBooleanValueOld(newArg, makefile, oneArg); + } + + // Check policy only if old and new results differ. + bool newResult = GetBooleanValue(newArg, makefile); + bool oldResult = GetBooleanValueOld(newArg, makefile, oneArg); + if(newResult != oldResult) + { + switch(Policy12Status) + { + case cmPolicies::WARN: + { + cmPolicies* policies = makefile->GetPolicies(); + errorString = "An argument named \"" + newArg + + "\" appears in a conditional statement. " + + policies->GetPolicyWarning(cmPolicies::CMP0012); + status = cmake::AUTHOR_WARNING; + } + case cmPolicies::OLD: + return oldResult; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + { + cmPolicies* policies = makefile->GetPolicies(); + errorString = "An argument named \"" + newArg + + "\" appears in a conditional statement. " + + policies->GetRequiredPolicyError(cmPolicies::CMP0012); + status = cmake::FATAL_ERROR; + } + case cmPolicies::NEW: + break; + } + } + return newResult; } //========================================================================= @@ -893,7 +910,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, makefile, errorString, Policy12Status, - status); + status, true); } //========================================================================= diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 90d1447..74692b7 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -121,16 +121,24 @@ public: "Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES " "will be evaluated. Then NOT operators and finally AND, OR operators " "will be evaluated. Possible expressions are:\n" - " if(variable)\n" - "True if the variable's value is not empty, 0, N, NO, OFF, FALSE, " - "NOTFOUND, or <variable>-NOTFOUND.\n" - " if(NOT variable)\n" - "True if the variable's value is empty, 0, N, NO, OFF, FALSE, " - "NOTFOUND, or <variable>-NOTFOUND.\n" - " if(variable1 AND variable2)\n" - "True if both variables would be considered true individually.\n" - " if(variable1 OR variable2)\n" - "True if either variable would be considered true individually.\n" + " if(<constant>)\n" + "True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. " + "False if the constant is 0, OFF, NO, FALSE, N, IGNORE, \"\", " + "or ends in the suffix '-NOTFOUND'. " + "Named boolean constants are case-insensitive." + "\n" + " if(<variable>)\n" + "True if the variable's value is not a false constant." + "\n" + " if(NOT <expression>)\n" + "True if the expression is not true." + "\n" + " if(<expr1> AND <expr2>)\n" + "True if both expressions would be considered true individually." + "\n" + " if(<expr1> OR <expr2>)\n" + "True if either expression would be considered true individually." + "\n" " if(COMMAND command-name)\n" "True if the given name is a command, macro or function that can be " "invoked.\n" diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 382192e0..8df0ffa 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -13,7 +13,7 @@ #include "cmTarget.h" #include "cmMakefile.h" #include "cmVisualStudio10TargetGenerator.h" -#include "cmGlobalVisualStudio7Generator.h" +#include "cmGlobalVisualStudio10Generator.h" #include <cm_expat.h> #include "cmXMLParser.h" class cmVS10XMLParser : public cmXMLParser @@ -93,9 +93,9 @@ void cmLocalVisualStudio10Generator::Generate() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - cmVisualStudio10TargetGenerator tg(&l->second, - (cmGlobalVisualStudio7Generator*) - this->GetGlobalGenerator()); + cmVisualStudio10TargetGenerator tg( + &l->second, static_cast<cmGlobalVisualStudio10Generator*>( + this->GetGlobalGenerator())); tg.Generate(); } this->WriteStampFiles(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 8639adb..2084808 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -588,7 +588,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, std::string flags; if(strcmp(configType, "10") != 0) { - const char* linkLanguage = target.GetLinkerLanguage(configName); + const char* linkLanguage = (this->FortranProject? "Fortran": + target.GetLinkerLanguage(configName)); if(!linkLanguage) { cmSystemTools::Error @@ -845,6 +846,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, cmTarget &target, bool isDebug) { + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); std::string temp; std::string extraLinkOptions; if(target.GetType() == cmTarget::EXECUTABLE) @@ -948,6 +951,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; + if(!gg->NeedLinkLibraryDependencies(target)) + { + fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; + } linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. @@ -1020,6 +1027,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; + if(!gg->NeedLinkLibraryDependencies(target)) + { + fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; + } linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 0d35b65..6b35b5b 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -358,19 +358,24 @@ cmPolicies::cmPolicies() this->DefinePolicy( CMP0012, "CMP0012", - "The if() command can recognize named boolean constants.", - "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, " + "if() recognizes numbers and boolean constants.", + "In CMake versions 2.6.4 and lower the if() command implicitly " + "dereferenced arguments corresponding to variables, even those named " + "like numbers or boolean constants, except for 0 and 1. " + "Numbers and 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. " "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.", + "Numbers such as 2 were recognized only in " + "boolean expressions like \"if(NOT 2)\" (leading to false) " + "but not as a single-argument like \"if(2)\" (also leading to false). " + "Later versions of CMake prefer to treat numbers and boolean constants " + "literally, so they should not be used as variable names." + "\n" + "The OLD behavior for this policy is to implicitly dereference variables " + "named like numbers and boolean constants. " + "The NEW behavior for this policy is to recognize numbers and " + "boolean constants without dereferencing variables with such names.", 2,8,0, cmPolicies::WARN); this->DefinePolicy( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index cf808bd..4d1c3fc 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -47,7 +47,7 @@ public: CMP0009, // GLOB_RECURSE should not follow symlinks by default CMP0010, // Bad variable reference syntax is an error CMP0011, // Strong policy scope for include and find_package - CMP0012, // Strong handling of boolean constants + CMP0012, // Recognize numbers and boolean constants in if() CMP0013, // Duplicate binary directories not allowed CMP0014, // Input directories must have CMakeLists.txt diff --git a/Source/cmVS10CLFlagTable.h b/Source/cmVS10CLFlagTable.h index 10f2c9b..a7b1b36 100644 --- a/Source/cmVS10CLFlagTable.h +++ b/Source/cmVS10CLFlagTable.h @@ -102,9 +102,11 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = "Fast", "Fast", 0}, {"PrecompiledHeader", "Yc", - "Create", "Create", 0}, + "Create", "Create", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"PrecompiledHeader", "Yu", - "Use", "Use", 0}, + "Use", "Use", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0}, @@ -136,7 +138,7 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = {"ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0}, {"ErrorReporting", "errorReport:prompt", - "Prompt Immediatelly", "Prompt", 0}, + "Prompt Immediately", "Prompt", 0}, {"ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue", 0}, {"ErrorReporting", "errorReport:send", @@ -180,7 +182,7 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = {"FunctionLevelLinking", "Gy", "", "true", 0}, {"FloatingPointExceptions", "fp:except-", "", "false", 0}, {"FloatingPointExceptions", "fp:except", "", "true", 0}, - {"CodeGeneration", "hotpatch", "", "true", 0}, + {"CreateHotpatchableImage", "hotpatch", "", "true", 0}, {"DisableLanguageExtensions", "Za", "", "true", 0}, {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0}, {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0}, @@ -199,14 +201,16 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = {"UseUnicodeForAssemblerListing", "FAu", "", "true", 0}, //Bool Properties With Argument - {"MultiProcessorCompilation", "MP", "", "true", cmVS7FlagTable::Continue}, + {"MultiProcessorCompilation", "MP", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"ProcessorNumber", "MP", "Multi-processor Compilation", "", cmVS7FlagTable::UserValueRequired}, {"GenerateXMLDocumentationFiles", "doc", "", "true", - cmVS7FlagTable::Continue}, + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "", cmVS7FlagTable::UserValueRequired}, - {"BrowseInformation", "FR", "", "true", cmVS7FlagTable::Continue}, + {"BrowseInformation", "FR", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"BrowseInformationFile", "FR", "Enable Browse Information", "", cmVS7FlagTable::UserValueRequired}, @@ -238,7 +242,15 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = //String Properties // Skip [TrackerLogDirectory] - no command line Switch. - // Skip [PrecompiledHeaderFile] - no command line Switch. + {"PreprocessOutputPath", "Fi", + "Preprocess Output Path", + "", cmVS7FlagTable::UserValue}, + {"PrecompiledHeaderFile", "Yc", + "Precompiled Header Name", + "", cmVS7FlagTable::UserValueRequired}, + {"PrecompiledHeaderFile", "Yu", + "Precompiled Header Name", + "", cmVS7FlagTable::UserValueRequired}, {"PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "", cmVS7FlagTable::UserValue}, diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index c1f1dda..c60e8eb 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -191,13 +191,16 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = {"LinkDLL", "DLL", "", "true", 0}, //Bool Properties With Argument - {"EnableUAC", "MANIFESTUAC:NO", "", "false", cmVS7FlagTable::Continue}, + {"EnableUAC", "MANIFESTUAC:NO", "", "false", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"EnableUAC", "MANIFESTUAC:NO", "Enable User Account Control (UAC)", "", cmVS7FlagTable::UserValueRequired}, - {"EnableUAC", "MANIFESTUAC:", "", "true", cmVS7FlagTable::Continue}, + {"EnableUAC", "MANIFESTUAC:", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", cmVS7FlagTable::UserValueRequired}, - {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::Continue}, + {"GenerateMapFile", "MAP", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"MapFileName", "MAP", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index e7a8784..32fcead 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -10,7 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmVisualStudio10TargetGenerator.h" -#include "cmGlobalVisualStudio7Generator.h" +#include "cmGlobalVisualStudio10Generator.h" #include "cmTarget.h" #include "cmComputeLinkInformation.h" #include "cmGeneratedFileStream.h" @@ -22,6 +22,8 @@ #include "cmVS10LinkFlagTable.h" #include "cmVS10LibFlagTable.h" +#include <cmsys/auto_ptr.hxx> + static std::string cmVS10EscapeXML(std::string arg) { cmSystemTools::ReplaceString(arg, "&", "&"); @@ -32,7 +34,7 @@ static std::string cmVS10EscapeXML(std::string arg) cmVisualStudio10TargetGenerator:: cmVisualStudio10TargetGenerator(cmTarget* target, - cmGlobalVisualStudio7Generator* gg) + cmGlobalVisualStudio10Generator* gg) { this->GlobalGenerator = gg; this->Target = target; @@ -43,13 +45,18 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->Name = this->Target->GetName(); this->GlobalGenerator->CreateGUID(this->Name.c_str()); this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); - this->Platform = "|Win32"; + this->Platform = gg->GetPlatformName(); this->ComputeObjectNames(); this->BuildFileStream = 0; } cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() { + for(OptionsMap::iterator i = this->ClOptions.begin(); + i != this->ClOptions.end(); ++i) + { + delete i->second; + } if(!this->BuildFileStream) { return; @@ -80,7 +87,7 @@ void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( (*stream ) << ""; (*stream ) << "<" << tag << " Condition=\"'$(Configuration)|$(Platform)'=='"; - (*stream ) << config << this->Platform << "'\""; + (*stream ) << config << "|" << this->Platform << "'\""; if(attribute) { (*stream ) << attribute; @@ -103,6 +110,7 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line, (*this->BuildFileStream ) << line; } +#define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" void cmVisualStudio10TargetGenerator::Generate() { @@ -115,6 +123,10 @@ void cmVisualStudio10TargetGenerator::Generate() this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str()); this->Target->SetProperty("GENERATOR_FILE_NAME_EXT", ".vcxproj"); + if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY) + { + this->ComputeClOptions(); + } cmMakefile* mf = this->Target->GetMakefile(); std::string path = mf->GetStartOutputDirectory(); path += "/"; @@ -141,6 +153,8 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<SccProjectName />\n", 2); this->WriteString("<SccLocalPath />\n", 2); this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); + this->WriteString("<Platform>", 2); + (*this->BuildFileStream) << this->Platform << "</Platform>\n"; this->WriteString("</PropertyGroup>\n", 1); this->WriteString("<Import Project=" "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n", @@ -151,12 +165,9 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1); this->WriteString("</ImportGroup>\n", 1); this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1); - this->WriteString("<Import Project=" - "\"$(LocalAppData)\\Microsoft\\VisualStudio\\10.0\\" - "Microsoft.Cpp.$(Platform).user.props\" " - "Condition=\"exists('$(LocalAppData)\\Microsoft" - "\\VisualStudio\\10.0\\" - "Microsoft.Cpp.$(Platform).user.props')\" />\n", 2); + this->WriteString("<Import Project=\"" VS10_USER_PROPS "\"" + " Condition=\"exists('" VS10_USER_PROPS "')\"" + " Label=\"LocalAppDataPlatform\" />", 2); this->WriteString("</ImportGroup>\n", 1); this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1); this->WritePathAndIncrementalLinkOptions(); @@ -187,10 +198,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() i != configs->end(); ++i) { this->WriteString("<ProjectConfiguration Include=\"", 2); - (*this->BuildFileStream ) << *i << this->Platform << "\">\n"; + (*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n"; this->WriteString("<Configuration>", 3); (*this->BuildFileStream ) << *i << "</Configuration>\n"; - this->WriteString("<Platform>Win32</Platform>\n", 3); + this->WriteString("<Platform>", 3); + (*this->BuildFileStream) << this->Platform << "</Platform>\n"; this->WriteString("</ProjectConfiguration>\n", 2); } this->WriteString("</ItemGroup>\n", 1); @@ -236,7 +248,15 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() { this->WriteString("<UseOfMfc>false</UseOfMfc>\n", 2); } - this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2); + if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY && + this->ClOptions[*i]->UsingUnicode()) + { + this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); + } + else + { + this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2); + } this->WriteString("</PropertyGroup>\n", 1); } } @@ -375,6 +395,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector<cmSourceFile*> clCompile; std::vector<cmSourceFile*> customBuild; std::vector<cmSourceFile*> none; + std::vector<cmSourceFile*> headers; for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); s != classes.end(); s++) @@ -384,7 +405,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups() cmSourceGroup& sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); groupsUsed.insert(&sourceGroup); - const char* lang = sf->GetLanguage(); + const char* lang = sf->GetLanguage(); + bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY") + || this->GlobalGenerator->IgnoreFile + ((*s)->GetExtension().c_str()); if(!lang) { lang = "None"; @@ -397,6 +421,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups() { customBuild.push_back(sf); } + else if(header) + { + headers.push_back(sf); + } else { none.push_back(sf); @@ -419,6 +447,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() "developer/msbuild/2003\">\n", 0); this->WriteGroupSources("ClCompile", clCompile, sourceGroups); + this->WriteGroupSources("ClInclude", headers, sourceGroups); this->WriteGroupSources("CustomBuild", customBuild, sourceGroups); this->WriteString("<ItemGroup>\n", 1); @@ -532,13 +561,13 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() { // if it is not a custom command then add it as a c/c++ file, // TODO: need to check for idl or rc - if(!(*source)->GetCustomCommand() - && !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY") - && !this->GlobalGenerator->IgnoreFile - ((*source)->GetExtension().c_str())) + if(!(*source)->GetCustomCommand()) { + bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY") + || this->GlobalGenerator->IgnoreFile + ((*source)->GetExtension().c_str()); const char* lang = (*source)->GetLanguage(); - if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0)) + bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0); { std::string sourceFile = (*source)->GetFullPath(); sourceFile = cmSystemTools::RelativePath( @@ -546,10 +575,21 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() sourceFile.c_str()); this->ConvertToWindowsSlash(sourceFile); // output the source file - this->WriteString("<ClCompile Include=\"", 2); + if(header) + { + this->WriteString("<ClInclude Include=\"", 2); + } + else if(cl) + { + this->WriteString("<ClCompile Include=\"", 2); + } + else + { + this->WriteString("<None Include=\"", 2); + } (*this->BuildFileStream ) << sourceFile << "\""; // ouput any flags specific to this source file - if(this->OutputSourceSpecificFlags(*source)) + if(cl && this->OutputSourceSpecificFlags(*source)) { // if the source file has specific flags the tag // is ended on a new line @@ -814,21 +854,31 @@ OutputLinkIncremental(std::string const& configName) << "</LinkIncremental>\n"; } +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator::ComputeClOptions() +{ + std::vector<std::string> const* configs = + this->GlobalGenerator->GetConfigurations(); + for(std::vector<std::string>::const_iterator i = configs->begin(); + i != configs->end(); ++i) + { + this->ComputeClOptions(*i); + } +} -void -cmVisualStudio10TargetGenerator:: -WriteClOptions(std::string const& configName, - std::vector<std::string> const & includes) +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator::ComputeClOptions( + std::string const& configName) { - // much of this was copied from here: // copied from cmLocalVisualStudio7Generator.cxx 805 + // TODO: Integrate code below with cmLocalVisualStudio7Generator. + + cmsys::auto_ptr<Options> pOptions( + new Options(this->LocalGenerator, 10, Options::Compiler, + cmVS10CLFlagTable)); + Options& clOptions = *pOptions; - this->WriteString("<ClCompile>\n", 2); - cmVisualStudioGeneratorOptions - clOptions(this->LocalGenerator, - 10, cmVisualStudioGeneratorOptions::Compiler, - cmVS10CLFlagTable); std::string flags; // collect up flags for if(this->Target->GetType() < cmTarget::UTILITY) @@ -898,6 +948,17 @@ WriteClOptions(std::string const& configName, { clOptions.AddDefine(exportMacro); } + + this->ClOptions[configName] = pOptions.release(); +} + +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator::WriteClOptions( + std::string const& configName, + std::vector<std::string> const& includes) +{ + Options& clOptions = *(this->ClOptions[configName]); + this->WriteString("<ClCompile>\n", 2); clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->OutputIncludes(includes); clOptions.OutputFlagMap(*this->BuildFileStream, " "); @@ -1080,11 +1141,12 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& // first just full path linkDirs += sep; linkDirs += *d; + sep = ";"; linkDirs += sep; // next path with configuration type Debug, Release, etc linkDirs += *d; linkDirs += "/$(Configuration)"; - sep = ";"; + linkDirs += sep; } linkDirs += "%(AdditionalLibraryDirectories)"; linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str()); @@ -1115,13 +1177,15 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& targetNameImport, targetNamePDB, config.c_str()); } - std::string imLib = this->Target->GetDirectory(config.c_str(), true); - std::string dir = this->Target->GetDirectory(config.c_str(), true); + + std::string dir = this->Target->GetDirectory(config.c_str()); dir += "/"; - imLib += "/"; - imLib += targetNameImport; std::string pdb = dir; pdb += targetNamePDB; + std::string imLib = this->Target->GetDirectory(config.c_str(), true); + imLib += "/"; + imLib += targetNameImport; + linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ProgramDataBaseFileName", pdb.c_str()); linkOptions.Parse(flags.c_str()); @@ -1134,6 +1198,13 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& linkOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("</Link>\n", 2); + if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target)) + { + this->WriteString("<ProjectReference>\n", 2); + this->WriteString( + " <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2); + this->WriteString("</ProjectReference>\n", 2); + } } void cmVisualStudio10TargetGenerator::AddLibraries( diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 127554f..989db71 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -16,18 +16,19 @@ class cmTarget; class cmMakefile; class cmGeneratedFileStream; -class cmGlobalVisualStudio7Generator; +class cmGlobalVisualStudio10Generator; class cmSourceFile; class cmCustomCommand; class cmLocalVisualStudio7Generator; class cmComputeLinkInformation; +class cmVisualStudioGeneratorOptions; #include "cmSourceGroup.h" class cmVisualStudio10TargetGenerator { public: cmVisualStudio10TargetGenerator(cmTarget* target, - cmGlobalVisualStudio7Generator* gg); + cmGlobalVisualStudio10Generator* gg); ~cmVisualStudio10TargetGenerator(); void Generate(); // used by cmVisualStudioGeneratorOptions @@ -49,6 +50,8 @@ private: void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); + void ComputeClOptions(); + void ComputeClOptions(std::string const& configName); void WriteClOptions(std::string const& config, std::vector<std::string> const & includes); void WriteRCOptions(std::string const& config, @@ -75,6 +78,9 @@ private: std::vector<cmSourceFile*> const& sources, std::vector<cmSourceGroup>& ); private: + typedef cmVisualStudioGeneratorOptions Options; + typedef std::map<cmStdString, Options*> OptionsMap; + OptionsMap ClOptions; std::string ModuleDefinitionFile; std::string PathToVcxproj; cmTarget* Target; @@ -82,7 +88,7 @@ private: std::string Platform; std::string GUID; std::string Name; - cmGlobalVisualStudio7Generator* GlobalGenerator; + cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; std::set<cmSourceFile*> SourcesVisited; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 48a0e83..a2e4a11 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -63,6 +63,7 @@ # include "cmGlobalVisualStudio9Generator.h" # include "cmGlobalVisualStudio9Win64Generator.h" # include "cmGlobalVisualStudio10Generator.h" +# include "cmGlobalVisualStudio10Win64Generator.h" # include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" @@ -2413,6 +2414,8 @@ void cmake::AddDefaultGenerators() &cmGlobalVisualStudio7Generator::New; this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] = &cmGlobalVisualStudio10Generator::New; + this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = + &cmGlobalVisualStudio10Win64Generator::New; this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = &cmGlobalVisualStudio71Generator::New; this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = diff --git a/Source/cmparseMSBuildXML.py b/Source/cmparseMSBuildXML.py index 4e3f34e..4877e59 100755 --- a/Source/cmparseMSBuildXML.py +++ b/Source/cmparseMSBuildXML.py @@ -3,7 +3,9 @@ # more information see here: # http://blogs.msdn.com/vcblog/archive/2008/12/16/msbuild-task.aspx -# cl.xml +# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/cl.xml" +# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/lib.xml" +# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/link.xml" # # BoolProperty <Name>true|false</Name> # simple example: @@ -215,11 +217,25 @@ class MSBuildToCMake: def toCMake(self): toReturn = "static cmVS7FlagTable cmVS10CxxTable[] =\n{\n" toReturn += "\n //Enum Properties\n" + lastProp = {} for i in self.enumProperties: + if i.attributes["Name"] == "CompileAsManaged": + #write these out after the rest of the enumProperties + lastProp = i + continue for j in i.values: - toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.DisplayName+"\", \""+j.attributes["Name"]+"\", 0},\n" + #hardcore Brad King's manual fixes for cmVS10CLFlagTable.h + if i.attributes["Name"] == "PrecompiledHeader" and j.attributes["Switch"] != "": + toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.DisplayName+"\", \""+j.attributes["Name"]+"\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" + else: + #default (normal, non-hardcoded) case + toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.DisplayName+"\", \""+j.attributes["Name"]+"\", 0},\n" toReturn += "\n" + if lastProp != {}: + for j in lastProp.values: + toReturn+=" {\""+lastProp.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.DisplayName+"\", \""+j.attributes["Name"]+"\", 0},\n" + toReturn += "\n" toReturn += "\n //Bool Properties\n" for i in self.boolProperties: @@ -233,10 +249,10 @@ class MSBuildToCMake: for i in self.boolProperties: if i.argumentProperty != "": if i.attributes["ReverseSwitch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\", cmVS7FlagTable::Continue},\n" + toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \""+i.DisplayName+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n" if i.attributes["Switch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\", cmVS7FlagTable::Continue},\n" + toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" toReturn += " {\""+i.argumentProperty+"\", \""+i.attributes["Switch"]+"\", \""+i.DisplayName+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n" toReturn += "\n //String List Properties\n" @@ -249,7 +265,16 @@ class MSBuildToCMake: toReturn += "\n //String Properties\n" for i in self.stringProperties: if i.attributes["Switch"] == "": - toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n"; + if i.attributes["Name"] == "PrecompiledHeaderFile": + #more hardcoding + toReturn += " {\"PrecompiledHeaderFile\", \"Yc\",\n" + toReturn += " \"Precompiled Header Name\",\n" + toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n" + toReturn += " {\"PrecompiledHeaderFile\", \"Yu\",\n" + toReturn += " \"Precompiled Header Name\",\n" + toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n" + else: + toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n"; else: toReturn +=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+i.attributes["Separator"]+"\",\n \""+i.DisplayName+"\",\n \"\", cmVS7FlagTable::UserValue},\n" diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 22135fe..e2935eb 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -1921,7 +1921,7 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout, { /* The first time this is called, we need to calculate the time at which the child will timeout. */ - if(cp->Timeout && cp->TimeoutTime.tv_sec < 0) + if(cp->Timeout > 0 && cp->TimeoutTime.tv_sec < 0) { kwsysProcessTime length = kwsysProcessTimeFromDouble(cp->Timeout); cp->TimeoutTime = kwsysProcessTimeAdd(cp->StartTime, length); @@ -2710,7 +2710,7 @@ static void kwsysProcessesSignalHandler(int signum kwsysProcess_ssize_t status= read(cp->PipeReadEnds[KWSYSPE_PIPE_SIGNAL], &buf, 1); status=write(cp->SignalPipe, &buf, 1); - + (void)status; } } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 8ed6315..a6dee1b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3959,7 +3959,20 @@ bool SystemTools::GetLineFromStream(kwsys_ios::istream& is, line = ""; long leftToRead = sizeLimit; - + + // Early short circuit return if stream is no good. Just return + // false and the empty line. (Probably means caller tried to + // create a file stream with a non-existent file name...) + // + if(!is) + { + if(has_newline) + { + *has_newline = false; + } + return false; + } + // If no characters are read from the stream, the end of file has // been reached. Clear the fail bit just before reading. while(!haveNewline && |