diff options
Diffstat (limited to 'Source')
84 files changed, 994 insertions, 3653 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ab70568..8dd58af 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -452,8 +452,6 @@ if (WIN32) cmGlobalNMakeMakefileGenerator.h cmGlobalJOMMakefileGenerator.cxx cmGlobalJOMMakefileGenerator.h - cmGlobalVisualStudio6Generator.cxx - cmGlobalVisualStudio6Generator.h cmGlobalVisualStudio71Generator.cxx cmGlobalVisualStudio71Generator.h cmGlobalVisualStudio7Generator.cxx @@ -481,8 +479,6 @@ if (WIN32) cmIDEFlagTable.h cmIDEOptions.cxx cmIDEOptions.h - cmLocalVisualStudio6Generator.cxx - cmLocalVisualStudio6Generator.h cmLocalVisualStudio7Generator.cxx cmLocalVisualStudio7Generator.h cmLocalVisualStudioGenerator.cxx @@ -728,7 +724,7 @@ endif() add_library(CPackLib ${CPACK_SRCS}) target_link_libraries(CPackLib CMakeLib) if(APPLE) - target_link_libraries(CPackLib "-framework Carbon") + target_link_libraries(CPackLib "-framework CoreServices") endif() if(APPLE) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 129a882..e667257 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 5) -set(CMake_VERSION_PATCH 0) -#set(CMake_VERSION_RC 0) +set(CMake_VERSION_PATCH 20160318) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 7b94ca3..521b395 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -20,21 +20,12 @@ #include <iomanip> -#include <CoreFoundation/CFBase.h> -#include <CoreFoundation/CFString.h> -#include <CoreFoundation/CFLocale.h> - -// The carbon framework is deprecated, but the Region codes it supplies are -// needed for the LPic data structure used for generating multi-lingual SLAs. -// There does not seem to be a replacement API for these region codes. -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-declarations" -#endif -#include <Carbon/Carbon.h> -#if defined(__clang__) -# pragma clang diagnostic pop -#endif +#include <CoreFoundation/CoreFoundation.h> + +// For the old LocaleStringToLangAndRegionCodes() function, to convert +// to the old Script Manager RegionCode values needed for the 'LPic' data +// structure used for generating multi-lingual SLAs. +#include <CoreServices/CoreServices.h> static const char* SLAHeader = "data 'LPic' (5000) {\n" diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 22d4bf0..3eca280 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -723,10 +723,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf( new cmMakefile(&gg, cm.GetCurrentSnapshot())); - std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { - realInstallDirectory += installSubDirectory; + tempInstallDirectory += installSubDirectory; } if (componentInstall) { diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 2c2cd48..fd62696 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -983,7 +983,7 @@ int cmCTestCoverageHandler::HandleDelphiCoverage( std::string BinDir = this->CTest->GetBinaryDir(); - std::string coverageFile = BinDir+ "/*.html"; + std::string coverageFile = BinDir+ "/*(*.pas).html"; g.FindFiles(coverageFile); @@ -1017,9 +1017,25 @@ int cmCTestCoverageHandler::HandleBlanketJSCoverage( std::string coverageFile = SourceDir+ "/*.json"; cmsys::Glob g; std::vector<std::string> files; + std::vector<std::string> blanketFiles; g.FindFiles(coverageFile); files=g.GetFiles(); - if (!files.empty()) + // Ensure that the JSON files found are the result of the + // Blanket.js output. Check for the "node-jscoverage" + // string on the second line + std::string line; + for(unsigned int fileEntry=0;fileEntry<files.size();fileEntry++) + { + cmsys::ifstream in(files[fileEntry].c_str()); + cmSystemTools::GetLineFromStream(in, line); + cmSystemTools::GetLineFromStream(in, line); + if (line.find("node-jscoverage") != line.npos) + { + blanketFiles.push_back(files[fileEntry]); + } + } + // Take all files with the node-jscoverage string and parse those + if (!blanketFiles.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found BlanketJS output JSON, Performing Coverage" << std::endl, diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 76ed038..b5688a8 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -426,3 +426,35 @@ std::string cmCommonTargetGenerator::GetManifests() return cmJoin(manifests, " "); } + +void cmCommonTargetGenerator +::AppendOSXVerFlag(std::string& flags, const std::string& lang, + const char* name, bool so) +{ + // Lookup the flag to specify the version. + std::string fvar = "CMAKE_"; + fvar += lang; + fvar += "_OSX_"; + fvar += name; + fvar += "_VERSION_FLAG"; + const char* flag = this->Makefile->GetDefinition(fvar); + + // Skip if no such flag. + if(!flag) + { + return; + } + + // Lookup the target version information. + int major; + int minor; + int patch; + this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); + if(major > 0 || minor > 0 || patch > 0) + { + // Append the flag since a non-zero version is specified. + std::ostringstream vflag; + vflag << flag << major << "." << minor << "." << patch; + this->LocalGenerator->AppendFlags(flags, vflag.str()); + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 0c17500..bfb6b79 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -79,6 +79,9 @@ protected: virtual void AddIncludeFlags(std::string& flags, std::string const& lang) = 0; + void AppendOSXVerFlag(std::string& flags, const std::string& lang, + const char* name, bool so); + typedef std::map<std::string, std::string> ByLanguageMap; std::string GetFlags(const std::string &l); ByLanguageMap FlagsByLanguage; diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 13098ad..2796fdf 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -931,7 +931,7 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component) //---------------------------------------------------------------------------- int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { - int count = 2; + unsigned int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { if(cmGeneratorTarget const* target = this->EntryList[*ni].Target) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 4a1f770..b639c15 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -19,13 +19,42 @@ #include <assert.h> -int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) +int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, + bool isTryRun) { this->BinaryDirectory = argv[1].c_str(); this->OutputFile = ""; // which signature were we called with ? this->SrcFileSignature = true; + cmState::TargetType targetType = cmState::EXECUTABLE; + const char* tt = + this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE"); + if (!isTryRun && tt && *tt) + { + if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0) + { + targetType = cmState::EXECUTABLE; + } + else if (strcmp(tt, + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY)) == 0) + { + targetType = cmState::STATIC_LIBRARY; + } + else + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + std::string("Invalid value '") + tt + "' for " + "CMAKE_TRY_COMPILE_TARGET_TYPE. Only " + "'" + cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and " + "'" + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) + "' " + "are allowed." + ); + return -1; + } + } + const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; std::string targetName; @@ -486,11 +515,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee); } - /* Put the executable at a known location (for COPY_FILE). */ - fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", - this->BinaryDirectory.c_str()); - /* Create the actual executable. */ - fprintf(fout, "add_executable(%s", targetName.c_str()); + if (targetType == cmState::EXECUTABLE) + { + /* Put the executable at a known location (for COPY_FILE). */ + fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", + this->BinaryDirectory.c_str()); + /* Create the actual executable. */ + fprintf(fout, "add_executable(%s", targetName.c_str()); + } + else // if (targetType == cmState::STATIC_LIBRARY) + { + /* Put the static library at a known location (for COPY_FILE). */ + fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n", + this->BinaryDirectory.c_str()); + /* Create the actual static library. */ + fprintf(fout, "add_library(%s STATIC", targetName.c_str()); + } for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) { @@ -549,7 +589,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (this->SrcFileSignature) { std::string copyFileErrorMessage; - this->FindOutputFile(targetName); + this->FindOutputFile(targetName, targetType); if ((res==0) && !copyFile.empty()) { @@ -651,13 +691,26 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } } -void cmCoreTryCompile::FindOutputFile(const std::string& targetName) +void cmCoreTryCompile::FindOutputFile(const std::string& targetName, + cmState::TargetType targetType) { this->FindErrorMessage = ""; this->OutputFile = ""; std::string tmpOutputFile = "/"; - tmpOutputFile += targetName; - tmpOutputFile +=this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); + if (targetType == cmState::EXECUTABLE) + { + tmpOutputFile += targetName; + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); + } + else // if (targetType == cmState::STATIC_LIBRARY) + { + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); + tmpOutputFile += targetName; + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); + } // a list of directories where to search for the compilation result // at first directly in the binary dir diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 3272462..c2beea8 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -30,7 +30,7 @@ public: * commands, such as TryRun can access the same logic without * duplication. */ - int TryCompileCode(std::vector<std::string> const& argv); + int TryCompileCode(std::vector<std::string> const& argv, bool isTryRun); /** * This deletes all the files created by TryCompileCode. @@ -44,8 +44,8 @@ public: TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ - void FindOutputFile(const std::string& targetName); - + void FindOutputFile(const std::string& targetName, + cmState::TargetType targetType); cmTypeMacro(cmCoreTryCompile, cmCommand); diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index 54c27d6..e670991 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -78,8 +78,7 @@ bool cmCreateTestSourceList driver += *i; ++i; - std::string configFile = - this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); + std::string configFile = cmSystemTools::GetCMakeRoot(); configFile += "/Templates/TestDriver.cxx.in"; // Create the test driver file diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 9348ef2..476d3ac 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -259,13 +259,12 @@ void cmExtraCodeBlocksGenerator } // Convert - const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT"); for (std::vector<std::string>::const_iterator jt = listFiles.begin(); jt != listFiles.end(); ++jt) { // don't put cmake's own files into the project (#12110): - if (jt->find(cmakeRoot) == 0) + if (jt->find(cmSystemTools::GetCMakeRoot()) == 0) { continue; } @@ -300,6 +299,8 @@ void cmExtraCodeBlocksGenerator // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_CODEBLOCKS_MAKE_ARGUMENTS"); fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" "<CodeBlocks_project_file>\n" @@ -311,7 +312,8 @@ void cmExtraCodeBlocksGenerator " "<<virtualFolders<<"\n" " <Build>\n"; - this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str()); + this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str(), + makeArgs); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -333,7 +335,8 @@ void cmExtraCodeBlocksGenerator (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), + makeArgs); } } break; @@ -350,7 +353,7 @@ void cmExtraCodeBlocksGenerator } this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(),makeArgs); break; case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: @@ -360,11 +363,11 @@ void cmExtraCodeBlocksGenerator { cmGeneratorTarget* gt = *ti; this->AppendTarget(fout, targetName, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); std::string fastTarget = targetName; fastTarget += "/fast"; this->AppendTarget(fout, fastTarget, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); } break; default: @@ -555,7 +558,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, - const char* compiler) + const char* compiler, + const std::string& makeFlags) { cmMakefile const* makefile = lg->GetMakefile(); std::string makefileName = lg->GetCurrentBinaryDirectory(); @@ -663,16 +667,18 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, fout<<" <MakeCommands>\n" " <Build command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), targetName) + << this->BuildMakeCommand(make, makefileName.c_str(), targetName, + makeFlags) << "\" />\n" " <CompileFile command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(),""$file"") + << this->BuildMakeCommand(make, makefileName.c_str(),""$file"", + makeFlags) << "\" />\n" " <Clean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " <DistClean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " </MakeCommands>\n" " </Target>\n"; @@ -684,18 +690,38 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) { // figure out which language to use - // for now care only for C and C++ - std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; - if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) + // for now care only for C, C++, and Fortran + + // projects with C/C++ and Fortran are handled as C/C++ projects + bool pureFortran = false; + std::string compilerIdVar; + if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true) + { + compilerIdVar = "CMAKE_CXX_COMPILER_ID"; + } + else if (this->GlobalGenerator->GetLanguageEnabled("C") == true) { compilerIdVar = "CMAKE_C_COMPILER_ID"; } + else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true) + { + compilerIdVar = "CMAKE_Fortran_COMPILER_ID"; + pureFortran = true; + } + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") { - compiler = "msvc8"; + if( mf->IsDefinitionSet("MSVC10") == true ) + { + compiler = "msvc10"; + } + else + { + compiler = "msvc8"; + } } else if (compilerId == "Borland") { @@ -707,15 +733,44 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) } else if (compilerId == "Intel") { - compiler = "icc"; + if (pureFortran && mf->IsDefinitionSet("WIN32")) + { + compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran) + } + else + { + compiler = "icc"; + } } else if (compilerId == "Watcom" || compilerId == "OpenWatcom") { compiler = "ow"; } + else if (compilerId == "Clang") + { + compiler = "clang"; + } + else if (compilerId == "PGI") + { + if (pureFortran) + { + compiler = "pgifortran"; + } + else + { + compiler = "pgi"; // does not exist as default in CodeBlocks 16.01 + } + } else if (compilerId == "GNU") { - compiler = "gcc"; + if (pureFortran) + { + compiler = "gfortran"; + } + else + { + compiler = "gcc"; + } } return compiler; } @@ -753,9 +808,15 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( const std::string& make, const char* makefile, - const std::string& target) + const std::string& target, const std::string& makeFlags) { std::string command = make; + if (makeFlags.size() > 0) + { + command += " "; + command += makeFlags; + } + std::string generator = this->GlobalGenerator->GetName(); if (generator == "NMake Makefiles") { diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 0c3846d..4abfa7e 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -54,13 +54,16 @@ private: std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmGeneratorTarget* target); std::string BuildMakeCommand(const std::string& make, const char* makefile, - const std::string& target); + const std::string& target, + const std::string& makeFlags); void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName, cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, - const char* compiler); + const char* compiler, + const std::string& makeFlags + ); }; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index aedf6f4..133a85a 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -42,6 +42,8 @@ cmExtraEclipseCDT4Generator this->GenerateLinkedResources = true; this->SupportsGmakeErrorParser = true; this->SupportsMachO64Parser = true; + this->CEnabled = false; + this->CXXEnabled = false; } //---------------------------------------------------------------------------- @@ -64,10 +66,12 @@ void cmExtraEclipseCDT4Generator { this->Natures.insert("org.eclipse.cdt.core.ccnature"); this->Natures.insert("org.eclipse.cdt.core.cnature"); + this->CXXEnabled = true; } else if (*lit == "C") { this->Natures.insert("org.eclipse.cdt.core.cnature"); + this->CEnabled = true; } else if (*lit == "Java") { @@ -890,7 +894,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // add system defined c macros const char* cDefs=mf->GetDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS"); - if(cDefs) + if(this->CEnabled && cDefs) { // Expand the list. std::vector<std::string> defs; @@ -925,7 +929,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // add system defined c++ macros const char* cxxDefs = mf->GetDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS"); - if(cxxDefs) + if(this->CXXEnabled && cxxDefs) { // Expand the list. std::vector<std::string> defs; @@ -979,7 +983,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the // standard headers. std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER"); - if (!compiler.empty()) + if (this->CEnabled && !compiler.empty()) { std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); @@ -988,7 +992,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const this->AppendIncludeDirectories(fout, dirs, emmited); } compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); - if (!compiler.empty()) + if (this->CXXEnabled && !compiler.empty()) { std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 16675f2..1da2077 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -116,6 +116,8 @@ private: bool SupportsVirtualFolders; bool SupportsGmakeErrorParser; bool SupportsMachO64Parser; + bool CEnabled; + bool CXXEnabled; }; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b3557f9..1fa27eb 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3300,6 +3300,15 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " status: [" << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"]" << std::endl ; + + if(!statusVar.empty() && res == 0) + { + std::string status = "1;HASH mismatch: " + "expected: " + expectedHash + + " actual: " + actualHash; + this->Makefile->AddDefinition(statusVar, status.c_str()); + } + this->SetError(oss.str()); return false; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ff12320..d7c2782 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3909,8 +3909,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, std::vector<std::string> props; cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + std::string pdir = cmSystemTools::GetCMakeRoot(); pdir += "/Help/prop_tgt/"; for(std::vector<std::string>::iterator pi = props.begin(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d96a32c..65c29f5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -599,7 +599,7 @@ private: { ImportInfo(): NoSOName(false), Multiplicity(0) {} bool NoSOName; - int Multiplicity; + unsigned int Multiplicity; std::string Location; std::string SOName; std::string ImportLibrary; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 848028f..1d0ade4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -398,6 +398,21 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, return; } + std::set<std::string> cur_languages(languages.begin(), languages.end()); + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + if (!this->LanguagesInProgress.insert(*li).second) + { + std::ostringstream e; + e << "Language '" << *li << "' is currently being enabled. " + "Recursive call not allowed."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return; + } + } + if(this->TryCompileOuterMakefile) { // In a try-compile we can only enable languages provided by caller. @@ -805,7 +820,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // Now load files that can override any settings on the platform or for // the project First load the project compatibility file if it is in // cmake - std::string projectCompatibility = mf->GetDefinition("CMAKE_ROOT"); + std::string projectCompatibility = cmSystemTools::GetCMakeRoot(); projectCompatibility += "/Modules/"; projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME"); projectCompatibility += "Compatibility.cmake"; @@ -823,6 +838,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { cmSystemTools::SetFatalErrorOccured(); } + + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + this->LanguagesInProgress.erase(*li); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 48fa704..14c7d67 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -241,11 +241,6 @@ public: */ virtual void FindMakeProgram(cmMakefile*); -#if defined(_WIN32) && !defined(__CYGWIN__) - /** Is this the Visual Studio 6 generator? */ - bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; } -#endif - ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; @@ -457,6 +452,7 @@ private: // in EnableLanguagesFromGenerator std::map<std::string, bool> IgnoreExtensions; std::set<std::string> LanguagesReady; // Ready for try_compile + std::set<std::string> LanguagesInProgress; std::map<std::string, std::string> OutputExtensions; std::map<std::string, std::string> LanguageToOutputExtension; std::map<std::string, std::string> ExtensionToLanguage; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0f06e43..83422b7 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -642,7 +642,6 @@ void cmGlobalNinjaGenerator // cmGlobalUnixMakefileGenerator3 // cmGlobalGhsMultiGenerator // cmGlobalVisualStudio10Generator -// cmGlobalVisualStudio6Generator // cmGlobalVisualStudio7Generator // cmGlobalXCodeGenerator // Called by: @@ -991,6 +990,7 @@ cmGlobalNinjaGenerator std::set<std::string> const& utils = target->GetUtilities(); std::copy(utils.begin(), utils.end(), std::back_inserter(outputs)); } else { + cmNinjaDeps outs; cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target); for (cmTargetDependSet::const_iterator i = targetDeps.begin(); i != targetDeps.end(); ++i) @@ -999,8 +999,10 @@ cmGlobalNinjaGenerator { continue; } - this->AppendTargetOutputs(*i, outputs); + this->AppendTargetOutputs(*i, outs); } + std::sort(outs.begin(), outs.end()); + outputs.insert(outputs.end(), outs.begin(), outs.end()); } } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx deleted file mode 100644 index 5866c0e..0000000 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ /dev/null @@ -1,451 +0,0 @@ -/*============================================================================ - 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 "cmGlobalVisualStudio6Generator.h" -#include "cmLocalVisualStudio6Generator.h" -#include "cmMakefile.h" -#include "cmake.h" -#include "cmGeneratedFileStream.h" -#include <cmsys/FStream.hxx> - -// Utility function to make a valid VS6 *.dsp filename out -// of a CMake target name: -// -std::string GetVS6TargetName(const std::string& targetName) -{ - std::string name(targetName); - - // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames... - // Replace them with underscores. - // - cmSystemTools::ReplaceString(name, "-", "_"); - - return name; -} - -cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator(cmake* cm) - : cmGlobalVisualStudioGenerator(cm) -{ - this->MSDevCommandInitialized = false; - this->Version = VS6; -} - -void cmGlobalVisualStudio6Generator -::EnableLanguage(std::vector<std::string>const& lang, - cmMakefile *mf, - bool optional) -{ - mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); - mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - this->GenerateConfigurations(mf); - this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); -} - -void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) -{ - std::string fname= mf->GetRequiredDefinition("CMAKE_ROOT"); - const char* def= mf->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); - if(def) - { - fname = def; - } - else - { - fname += "/Templates"; - } - fname += "/CMakeVisualStudio6Configurations.cmake"; - if(!mf->ReadDependentFile(fname.c_str())) - { - cmSystemTools::Error("Cannot open ", fname.c_str(), - ". Please copy this file from the main " - "CMake/Templates directory and edit it for " - "your build configurations."); - } - else if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::Error("CMAKE_CONFIGURATION_TYPES not set by ", - fname.c_str(), - ". Please copy this file from the main " - "CMake/Templates directory and edit it for " - "your build configurations."); - } -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf) -{ - this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); - mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND", - this->GetMSDevCommand().c_str()); -} - -//---------------------------------------------------------------------------- -std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() -{ - if(!this->MSDevCommandInitialized) - { - this->MSDevCommandInitialized = true; - this->MSDevCommand = this->FindMSDevCommand(); - } - return this->MSDevCommand; -} - -//---------------------------------------------------------------------------- -std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() -{ - std::string vscmd; - std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir"; - if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, - cmSystemTools::KeyWOW64_32)) - { - cmSystemTools::ConvertToUnixSlashes(vscmd); - vscmd += "/MSDev98/Bin/"; - } - vscmd += "msdev.exe"; - return vscmd; -} - -//---------------------------------------------------------------------------- -void -cmGlobalVisualStudio6Generator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& /*projectDir*/, - const std::string& targetName, - const std::string& config, - bool /*fast*/, bool /*verbose*/, - std::vector<std::string> const& makeOptions - ) -{ - // now build the test - makeCommand.push_back( - this->SelectMakeProgram(makeProgram, this->GetMSDevCommand()) - ); - - makeCommand.push_back(std::string(projectName)+".dsw"); - makeCommand.push_back("/MAKE"); - std::string targetArg; - bool clean = false; - std::string realTarget = targetName; - if ( realTarget == "clean" ) - { - clean = true; - realTarget = "ALL_BUILD"; - } - if (!realTarget.empty()) - { - targetArg += realTarget; - } - else - { - targetArg += "ALL_BUILD"; - } - targetArg += " - "; - if(!config.empty()) - { - targetArg += config; - } - else - { - targetArg += "Debug"; - } - makeCommand.push_back(targetArg); - if(clean) - { - makeCommand.push_back("/CLEAN"); - } - else - { - makeCommand.push_back("/BUILD"); - } - makeCommand.insert(makeCommand.end(), - makeOptions.begin(), makeOptions.end()); -} - -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) -{ - return new cmLocalVisualStudio6Generator(this, mf); -} - - -void cmGlobalVisualStudio6Generator::Generate() -{ - // first do the superclass method - this->cmGlobalVisualStudioGenerator::Generate(); - - // Now write out the DSW - this->OutputDSWFile(); - - if (!this->CMakeInstance->GetIsInTryCompile()) - { - const char* cmakeWarnVS6 = - this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS6"); - if (!cmakeWarnVS6 || !cmSystemTools::IsOff(cmakeWarnVS6)) - { - this->CMakeInstance->IssueMessage( - cmake::WARNING, - "The \"Visual Studio 6\" generator is deprecated " - "and will be removed in a future version of CMake." - "\n" - "Add CMAKE_WARN_VS6=OFF to the cache to disable this warning." - ); - } - } -} - -// Write a DSW file to the stream -void cmGlobalVisualStudio6Generator -::WriteDSWFile(std::ostream& fout,cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators) -{ - // Write out the header for a DSW file - this->WriteDSWHeader(fout); - - // Collect all targets under this root generator and the transitive - // closure of their dependencies. - TargetDependSet projectTargets; - TargetDependSet originalTargets; - this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); - - for(OrderedTargetDependSet::const_iterator - tt = orderedProjectTargets.begin(); - tt != orderedProjectTargets.end(); ++tt) - { - cmGeneratorTarget const* target = *tt; - if(target->GetType() == cmState::INTERFACE_LIBRARY) - { - continue; - } - // Write the project into the DSW file - const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); - if(expath) - { - std::string project = target->GetName(); - std::string location = expath; - this->WriteExternalProject(fout, project.c_str(), - location.c_str(), target->GetUtilities()); - } - else - { - std::string dspname = GetVS6TargetName(target->GetName()); - std::string dir = - target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); - this->WriteProject(fout, dspname.c_str(), dir.c_str(), target); - } - } - - // Write the footer for the DSW file - this->WriteDSWFooter(fout); -} - -void cmGlobalVisualStudio6Generator -::OutputDSWFile(cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators) -{ - if(generators.empty()) - { - return; - } - std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); - fname += "/"; - fname += root->GetProjectName(); - fname += ".dsw"; - cmsys::ofstream fout(fname.c_str()); - if(!fout) - { - cmSystemTools::Error("Error can not open DSW file for write: ", - fname.c_str()); - cmSystemTools::ReportLastSystemError(""); - return; - } - this->WriteDSWFile(fout, root, generators); -} - -// output the DSW file -void cmGlobalVisualStudio6Generator::OutputDSWFile() -{ - std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; - for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { - this->OutputDSWFile(it->second[0], it->second); - } -} - -// Write a dsp file into the DSW file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, - const std::string& dspname, - const char* dir, - const cmGeneratorTarget *target) -{ - fout << "#########################################################" - "######################\n\n"; - fout << "Project: \"" << dspname << "\"=" - << dir << "\\" << dspname << ".dsp - Package Owner=<4>\n\n"; - fout << "Package=<5>\n{{{\n}}}\n\n"; - fout << "Package=<4>\n"; - fout << "{{{\n"; - VSDependSet const& depends = this->VSTargetDepends[target]; - for(VSDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) - { - const char* name = di->c_str(); - fout << "Begin Project Dependency\n"; - fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n"; - fout << "End Project Dependency\n"; - } - fout << "}}}\n\n"; - - UtilityDependsMap::iterator ui = this->UtilityDepends.find(target); - if(ui != this->UtilityDepends.end()) - { - const char* uname = ui->second.c_str(); - fout << "Project: \"" << uname << "\"=" - << dir << "\\" << uname << ".dsp - Package Owner=<4>\n\n"; - fout << - "Package=<5>\n{{{\n}}}\n\n" - "Package=<4>\n" - "{{{\n" - "Begin Project Dependency\n" - "Project_Dep_Name " << dspname << "\n" - "End Project Dependency\n" - "}}}\n\n"; - ; - } -} - - -// Write a dsp file into the DSW file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, - const std::string& name, - const char* location, - const std::set<std::string>& dependencies) -{ - fout << "#########################################################" - "######################\n\n"; - fout << "Project: \"" << name << "\"=" - << location << " - Package Owner=<4>\n\n"; - fout << "Package=<5>\n{{{\n}}}\n\n"; - fout << "Package=<4>\n"; - fout << "{{{\n"; - - - std::set<std::string>::const_iterator i, end; - // write dependencies. - i = dependencies.begin(); - end = dependencies.end(); - for(;i!= end; ++i) - { - fout << "Begin Project Dependency\n"; - fout << "Project_Dep_Name " << GetVS6TargetName(*i) << "\n"; - fout << "End Project Dependency\n"; - } - fout << "}}}\n\n"; -} - - - -// Standard end of dsw file -void cmGlobalVisualStudio6Generator::WriteDSWFooter(std::ostream& fout) -{ - fout << "######################################################" - "#########################\n\n"; - fout << "Global:\n\n"; - fout << "Package=<5>\n{{{\n}}}\n\n"; - fout << "Package=<3>\n{{{\n}}}\n\n"; - fout << "#####################################################" - "##########################\n\n"; -} - - -// ouput standard header for dsw file -void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) -{ - fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n"; - fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n"; -} - -//---------------------------------------------------------------------------- -std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend( - const cmGeneratorTarget *target) -{ - std::string pname = target->GetName(); - pname += "_UTILITY"; - pname = GetVS6TargetName(pname.c_str()); - std::string fname = - target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fname += "/"; - fname += pname; - fname += ".dsp"; - cmGeneratedFileStream fout(fname.c_str()); - fout.SetCopyIfDifferent(true); - fout << - "# Microsoft Developer Studio Project File - Name=\"" - << pname << "\" - Package Owner=<4>\n" - "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n" - "# ** DO NOT EDIT **\n" - "\n" - "# TARGTYPE \"Win32 (x86) Generic Project\" 0x010a\n" - "\n" - "CFG=" << pname << " - Win32 Debug\n" - "!MESSAGE \"" << pname << " - Win32 Debug\"" - " (based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 Release\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 MinSizeRel\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 RelWithDebInfo\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "\n" - "# Begin Project\n" - "# Begin Target\n" - "# Name \"" << pname << " - Win32 Debug\"\n" - "# Name \"" << pname << " - Win32 Release\"\n" - "# Name \"" << pname << " - Win32 MinSizeRel\"\n" - "# Name \"" << pname << " - Win32 RelWithDebInfo\"\n" - "# End Target\n" - "# End Project\n" - ; - return pname; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio6Generator -::GetDocumentation(cmDocumentationEntry& entry) -{ - entry.Name = cmGlobalVisualStudio6Generator::GetActualName(); - entry.Brief = "Deprecated. Generates Visual Studio 6 project files."; -} - -//---------------------------------------------------------------------------- -void -cmGlobalVisualStudio6Generator -::AppendDirectoryForConfig(const std::string& prefix, - const std::string& config, - const std::string& suffix, - std::string& dir) -{ - if(!config.empty()) - { - dir += prefix; - dir += config; - dir += suffix; - } -} diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h deleted file mode 100644 index ae2988e..0000000 --- a/Source/cmGlobalVisualStudio6Generator.h +++ /dev/null @@ -1,113 +0,0 @@ -/*============================================================================ - 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 cmGlobalVisualStudio6Generator_h -#define cmGlobalVisualStudio6Generator_h - -#include "cmGlobalVisualStudioGenerator.h" -#include "cmGlobalGeneratorFactory.h" - -/** \class cmGlobalVisualStudio6Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio6Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator -{ -public: - cmGlobalVisualStudio6Generator(cmake* cm); - static cmGlobalGeneratorFactory* NewFactory() { - return new cmGlobalGeneratorSimpleFactory - <cmGlobalVisualStudio6Generator>(); } - - ///! Get the name for the generator. - virtual std::string GetName() const { - return cmGlobalVisualStudio6Generator::GetActualName();} - static std::string GetActualName() {return "Visual Studio 6";} - - /** Get the documentation entry for this generator. */ - static void GetDocumentation(cmDocumentationEntry& entry); - - /** - * Utilized by the generator factory to determine if this generator - * supports toolsets. - */ - static bool SupportsToolset() { return false; } - - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); - - /** - * Try to determine system information such as shared library - * extension, pthreads, byte order etc. - */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); - - /** - * Try running cmake and building a file. This is used for dynalically - * loaded commands, not as part of the usual build process. - */ - virtual void GenerateBuildCommand( - std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, - bool fast, bool verbose, - std::vector<std::string> const& makeOptions = std::vector<std::string>() - ); - - /** - * Generate the DSW workspace file. - */ - virtual void OutputDSWFile(); - virtual void OutputDSWFile(cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators); - virtual void WriteDSWFile(std::ostream& fout, - cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators); - - /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const std::string& prefix, - const std::string& config, - const std::string& suffix, - std::string& dir); - - ///! What is the configurations directory variable called? - virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; } - - virtual void FindMakeProgram(cmMakefile*); - -protected: - virtual void Generate(); - virtual const char* GetIDEVersion() { return "6.0"; } -private: - virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } - void GenerateConfigurations(cmMakefile* mf); - void WriteDSWFile(std::ostream& fout); - void WriteDSWHeader(std::ostream& fout); - void WriteProject(std::ostream& fout, - const std::string& name, const char* path, - cmGeneratorTarget const* t); - void WriteExternalProject(std::ostream& fout, - const std::string& name, const char* path, - const std::set<std::string>& dependencies); - void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target); - std::string MSDevCommand; - bool MSDevCommandInitialized; - std::string const& GetMSDevCommand(); - std::string FindMSDevCommand(); -}; - -#endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f5848ab..c1c8c77 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -335,23 +335,6 @@ void cmGlobalVisualStudio7Generator::Generate() { this->CallVisualStudioMacro(MacroReload); } - - if (!this->CMakeInstance->GetIsInTryCompile() && - this->GetName() == "Visual Studio 7") - { - const char* cmakeWarnVS70 = - this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS70"); - if (!cmakeWarnVS70 || !cmSystemTools::IsOff(cmakeWarnVS70)) - { - this->CMakeInstance->IssueMessage( - cmake::WARNING, - "The \"Visual Studio 7\" generator is deprecated " - "and will be removed in a future version of CMake." - "\n" - "Add CMAKE_WARN_VS70=OFF to the cache to disable this warning." - ); - } - } } void cmGlobalVisualStudio7Generator @@ -551,71 +534,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( } //---------------------------------------------------------------------------- -// Write a SLN file to the stream -void cmGlobalVisualStudio7Generator -::WriteSLNFile(std::ostream& fout, - cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators) -{ - std::vector<std::string> configs; - root->GetMakefile()->GetConfigurations(configs); - - // Write out the header for a SLN file - this->WriteSLNHeader(fout); - - // Collect all targets under this root generator and the transitive - // closure of their dependencies. - TargetDependSet projectTargets; - TargetDependSet originalTargets; - this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); - - this->WriteTargetsToSolution(fout, root, orderedProjectTargets); - - bool useFolderProperty = this->UseFolderProperty(); - if (useFolderProperty) - { - this->WriteFolders(fout); - } - - // Write out the configurations information for the solution - fout << "Global\n" - << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; - - int c = 0; - for(std::vector<std::string>::iterator i = configs.begin(); - i != configs.end(); ++i) - { - fout << "\t\tConfigName." << c << " = " << *i << "\n"; - c++; - } - fout << "\tEndGlobalSection\n"; - // Write out project(target) depends - fout << "\tGlobalSection(ProjectDependencies) = postSolution\n"; - this->WriteTargetDepends(fout, orderedProjectTargets); - fout << "\tEndGlobalSection\n"; - - if (useFolderProperty) - { - // Write out project folders - fout << "\tGlobalSection(NestedProjects) = preSolution\n"; - this->WriteFoldersContent(fout); - fout << "\tEndGlobalSection\n"; - } - - // Write out the configurations for all the targets in the project - fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; - this->WriteTargetConfigurations(fout, configs, orderedProjectTargets); - fout << "\tEndGlobalSection\n"; - - // Write out global sections - this->WriteSLNGlobalSections(fout, root); - - // Write the footer for the SLN file - this->WriteSLNFooter(fout); -} - -//---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) { const char *prefix = "CMAKE_FOLDER_GUID_"; @@ -680,134 +598,6 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) return d; } -// Write a dsp file into the SLN file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, - const std::string& dspname, - const char* dir, - cmGeneratorTarget const* target) -{ - // check to see if this is a fortran build - const char* ext = ".vcproj"; - const char* project = - "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""; - if(this->TargetIsFortranOnly(target)) - { - ext = ".vfproj"; - project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \""; - } - - fout << project - << dspname << "\", \"" - << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"") - << dspname << ext << "\", \"{" - << this->GetGUID(dspname) << "}\"\nEndProject\n"; - - UtilityDependsMap::iterator ui = this->UtilityDepends.find(target); - if(ui != this->UtilityDepends.end()) - { - const char* uname = ui->second.c_str(); - fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" - << uname << "\", \"" - << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"") - << uname << ".vcproj" << "\", \"{" - << this->GetGUID(uname) << "}\"\n" - << "EndProject\n"; - } -} - - - -// Write a dsp file into the SLN file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void -cmGlobalVisualStudio7Generator -::WriteProjectDepends(std::ostream& fout, - const std::string& dspname, - const char*, cmGeneratorTarget const* target) -{ - int depcount = 0; - std::string dspguid = this->GetGUID(dspname); - VSDependSet const& depends = this->VSTargetDepends[target]; - for(VSDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) - { - const char* name = di->c_str(); - std::string guid = this->GetGUID(name); - if(guid.empty()) - { - std::string m = "Target: "; - m += target->GetName(); - m += " depends on unknown target: "; - m += name; - cmSystemTools::Error(m.c_str()); - } - fout << "\t\t{" << dspguid << "}." << depcount << " = {" << guid << "}\n"; - depcount++; - } - - UtilityDependsMap::iterator ui = this->UtilityDepends.find(target); - if(ui != this->UtilityDepends.end()) - { - const char* uname = ui->second.c_str(); - fout << "\t\t{" << this->GetGUID(uname) << "}.0 = {" << dspguid << "}\n"; - } -} - - -// Write a dsp file into the SLN file, Note, that dependencies from -// executables to the libraries it uses are also done here -void cmGlobalVisualStudio7Generator -::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType, - std::vector<std::string> const& configs, - const std::set<std::string>& configsPartOfDefaultBuild, - const std::string& platformMapping) -{ - const std::string& platformName = - !platformMapping.empty() ? platformMapping : this->GetPlatformName(); - std::string guid = this->GetGUID(name); - for(std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i) - { - fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|" << platformName << "\n"; - std::set<std::string>::const_iterator - ci = configsPartOfDefaultBuild.find(*i); - if(!(ci == configsPartOfDefaultBuild.end())) - { - fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|" << platformName << "\n"; - } - } -} - - - -// Write a dsp file into the SLN file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, - const std::string& name, - const char* location, - const char* typeGuid, - const std::set<std::string>&) -{ - fout << "Project(" - << "\"{" - << (typeGuid ? typeGuid : this->ExternalProjectType(location)) - << "}\") = \"" - << name << "\", \"" - << this->ConvertToSolutionPath(location) << "\", \"{" - << this->GetGUID(name) - << "}\"\n"; - fout << "EndProject\n"; -} - - - void cmGlobalVisualStudio7Generator ::WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root) @@ -871,21 +661,12 @@ void cmGlobalVisualStudio7Generator << "\tEndGlobalSection\n"; } - - // Standard end of dsw file void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) { fout << "EndGlobal\n"; } - -// ouput standard header for dsw file -void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n"; -} - //---------------------------------------------------------------------------- std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend( @@ -970,14 +751,6 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name) } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio7Generator -::GetDocumentation(cmDocumentationEntry& entry) -{ - entry.Name = cmGlobalVisualStudio7Generator::GetActualName(); - entry.Brief = "Deprecated. Generates Visual Studio .NET 2002 project files."; -} - -//---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator ::AppendDirectoryForConfig(const std::string& prefix, diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index de2d35e..02f9809 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -30,15 +30,6 @@ public: const std::string& platformName = ""); ~cmGlobalVisualStudio7Generator(); - static cmGlobalGeneratorFactory* NewFactory() { - return new cmGlobalGeneratorSimpleFactory - <cmGlobalVisualStudio7Generator>(); } - - ///! Get the name for the generator. - virtual std::string GetName() const { - return cmGlobalVisualStudio7Generator::GetActualName();} - static std::string GetActualName() {return "Visual Studio 7";} - ///! Get the name for the platform. std::string const& GetPlatformName() const; @@ -49,9 +40,6 @@ public: virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); - /** Get the documentation entry for this generator. */ - static void GetDocumentation(cmDocumentationEntry& entry); - /** * Utilized by the generator factory to determine if this generator * supports toolsets. @@ -117,7 +105,7 @@ public: protected: virtual void Generate(); - virtual const char* GetIDEVersion() { return "7.0"; } + virtual const char* GetIDEVersion() = 0; std::string const& GetDevEnvCommand(); virtual std::string FindDevEnvCommand(); @@ -127,22 +115,22 @@ protected: virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators); + std::vector<cmLocalGenerator*>& generators) = 0; virtual void WriteProject(std::ostream& fout, const std::string& name, const char* path, - const cmGeneratorTarget *t); + const cmGeneratorTarget *t) = 0; virtual void WriteProjectDepends(std::ostream& fout, const std::string& name, const char* path, - cmGeneratorTarget const* t); + cmGeneratorTarget const* t) = 0; virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmState::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, - const std::string& platformMapping = ""); + const std::string& platformMapping = "") = 0; virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); - virtual void WriteSLNHeader(std::ostream& fout); + virtual void WriteSLNHeader(std::ostream& fout) = 0; virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target); virtual void WriteTargetsToSolution( @@ -162,7 +150,7 @@ protected: const char* path, const char* typeGuid, const std::set<std::string>& - dependencies); + dependencies) = 0; std::string ConvertToSolutionPath(const char* path); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6a1aa29..00bb511 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -184,12 +184,11 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); std::string dir = this->GetUserMacrosDirectory(); if (dir != "") { - std::string src = mf->GetRequiredDefinition("CMAKE_ROOT"); + std::string src = cmSystemTools::GetCMakeRoot(); src += "/Templates/" CMAKE_VSMACROS_FILENAME; std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index f827f26..ac9111e 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -26,7 +26,6 @@ public: /** Known versions of Visual Studio. */ enum VSVersion { - VS6 = 60, VS7 = 70, VS71 = 71, VS8 = 80, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 526e32f..7c85281 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -593,19 +593,28 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( cmGeneratedFileStream makefileStream (this->CurrentReRunCMakeMakefile.c_str()); makefileStream.SetCopyIfDifferent(true); - makefileStream << "# Generated by CMake, DO NOT EDIT\n"; - std::string checkCache = root->GetBinaryDirectory(); - checkCache += "/"; - checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); - checkCache += "cmake.check_cache"; - makefileStream << this->ConvertToRelativeForMake(checkCache.c_str()) - << ": "; + makefileStream << "# Generated by CMake, DO NOT EDIT\n\n"; + + makefileStream << "empty:= \n"; + makefileStream << "space:= $(empty) $(empty)\n"; + makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n"; + for(std::vector<std::string>::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { - makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str()); + makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard " + << this->ConvertToRelativeForMake(i->c_str()) + << "))\n"; } - makefileStream << "\n\t" << + + std::string checkCache = root->GetBinaryDirectory(); + checkCache += "/"; + checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); + checkCache += "cmake.check_cache"; + + makefileStream << "\n" << this->ConvertToRelativeForMake(checkCache.c_str()) + << ": $(TARGETS)\n"; + makefileStream << "\t" << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str()) << " -H" << this->ConvertToRelativeForMake( root->GetSourceDirectory()) @@ -2805,7 +2814,10 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt, fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); - fileRef->AddAttribute("refType", this->CreateString("0")); + if(this->XcodeVersion == 15) + { + fileRef->AddAttribute("refType", this->CreateString("0")); + } fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); fileRef->SetComment(gtgt->GetName().c_str()); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 2d78a41..26a1485 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -33,6 +33,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, + args.GetExcludeFromAll(), args.GetOptional() || forceOpt); } @@ -48,7 +49,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetRename().c_str(), args.GetOptional()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -117,6 +119,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -128,6 +131,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -175,7 +182,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -183,7 +190,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -949,6 +956,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; const char* destination = 0; @@ -1130,6 +1138,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + std::ostringstream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1273,6 +1294,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) configurations, component.c_str(), message, + exclude_from_all, literal_args.c_str(), optional)); @@ -1403,7 +1425,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), message, fname.c_str(), + ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled()); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 236ca1f..6ded365 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index f2e8609..6ad6c75 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -23,9 +23,11 @@ cmInstallDirectoryGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), LocalGenerator(0), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index 9b732d3..b137f44 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -27,6 +27,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 9570ba3..80fc054 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,9 +33,11 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld) - :cmInstallGenerator(destination, configurations, component, message) + :cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 885ed05..1b1c046 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,6 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 68557bd..d3d258e 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -122,6 +122,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -131,7 +132,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 383031b..3dd5528 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -24,9 +24,11 @@ cmInstallFilesGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), LocalGenerator(0), Files(files), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index bfe4039..efaf62b 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -26,6 +26,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 2e1c5f0..660e44f 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -19,11 +19,13 @@ cmInstallGenerator ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message): + MessageLevel message, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), Component(component? component:""), - Message(message) + Message(message), + ExcludeFromAll(exclude_from_all) { } @@ -146,12 +148,16 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, + bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -163,7 +169,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index b8e5b53..db895908 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -36,7 +36,8 @@ public: cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message); + MessageLevel message, + bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -67,12 +68,14 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, + bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; MessageLevel Message; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index e6fbe88..b6d0c45 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -85,6 +85,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -94,7 +95,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 933aa07..d58d039 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 5e88fa2..3d44fe2 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -30,8 +30,10 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), TargetName(targetName), Target(0), FilePermissions(file_permissions), diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 18b3130..46b4532 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -28,6 +28,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index b603bcc..561293e 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -73,7 +73,7 @@ struct cmLinkInterface: public cmLinkInterfaceLibraries // Number of repetitions of a strongly connected component of two // or more static libraries. - int Multiplicity; + unsigned int Multiplicity; // Libraries listed for other configurations. // Needed only for OLD behavior of CMP0003. diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 6041fb7..15a1af5 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -14,6 +14,7 @@ #include <cmsys/SystemTools.hxx> #include "cmAlgorithms.h" +#include <algorithm> #include <stdlib.h> // required for atoi #include <ctype.h> #include <assert.h> @@ -68,6 +69,10 @@ bool cmListCommand { return this->HandleReverseCommand(args); } + if(subCommand == "FILTER") + { + return this->HandleFilterCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e); @@ -517,3 +522,107 @@ bool cmListCommand::HandleRemoveAtCommand( return true; } +//---------------------------------------------------------------------------- +bool cmListCommand::HandleFilterCommand( + std::vector<std::string> const& args) +{ + if(args.size() < 2) + { + this->SetError("sub-command FILTER requires a list to be specified."); + return false; + } + + if(args.size() < 3) + { + this->SetError("sub-command FILTER requires an operator to be specified."); + return false; + } + + if(args.size() < 4) + { + this->SetError("sub-command FILTER requires a mode to be specified."); + return false; + } + + const std::string& listName = args[1]; + // expand the variable + std::vector<std::string> varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName) ) + { + this->SetError("sub-command FILTER requires list to be present."); + return false; + } + + const std::string& op = args[2]; + bool includeMatches; + if(op == "INCLUDE") + { + includeMatches = true; + } + else if(op == "EXCLUDE") + { + includeMatches = false; + } + else + { + this->SetError("sub-command FILTER does not recognize operator " + op); + return false; + } + + const std::string& mode = args[3]; + if(mode == "REGEX") + { + if(args.size() != 5) + { + this->SetError("sub-command FILTER, mode REGEX " + "requires five arguments."); + return false; + } + return this->FilterRegex(args, includeMatches, listName, varArgsExpanded); + } + + this->SetError("sub-command FILTER does not recognize mode " + mode); + return false; +} + +//---------------------------------------------------------------------------- +class MatchesRegex { +public: + MatchesRegex(cmsys::RegularExpression& in_regex, bool in_includeMatches) + : regex(in_regex), includeMatches(in_includeMatches) {} + + bool operator()(const std::string& target) { + return regex.find(target) ^ includeMatches; + } + +private: + cmsys::RegularExpression& regex; + const bool includeMatches; +}; + +bool cmListCommand::FilterRegex(std::vector<std::string> const& args, + bool includeMatches, + std::string const& listName, + std::vector<std::string>& varArgsExpanded) +{ + const std::string& pattern = args[4]; + cmsys::RegularExpression regex(pattern); + if(!regex.is_valid()) + { + std::string error = "sub-command FILTER, mode REGEX "; + error += "failed to compile regex \""; + error += pattern; + error += "\"."; + this->SetError(error); + return false; + } + + std::vector<std::string>::iterator argsBegin = varArgsExpanded.begin(); + std::vector<std::string>::iterator argsEnd = varArgsExpanded.end(); + std::vector<std::string>::iterator newArgsEnd = + std::remove_if(argsBegin, argsEnd, MatchesRegex(regex, includeMatches)); + + std::string value = cmJoin(cmMakeRange(argsBegin, newArgsEnd), ";"); + this->Makefile->AddDefinition(listName, value.c_str()); + return true; +} diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index 5ea1d9f..25edee8 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -58,6 +58,12 @@ protected: bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args); bool HandleSortCommand(std::vector<std::string> const& args); bool HandleReverseCommand(std::vector<std::string> const& args); + bool HandleFilterCommand(std::vector<std::string> const& args); + bool FilterRegex(std::vector<std::string> const& args, + bool includeMatches, + std::string const& listName, + std::vector<std::string>& varArgsExpanded + ); bool GetList(std::vector<std::string>& list, const std::string& var); diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 03e0abe..4d3055f 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -58,8 +58,9 @@ struct cmListFileArgument long Line; }; -struct cmListFileContext +class cmListFileContext { +public: std::string Name; std::string FilePath; long Line; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 912be0c..1be39a9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2455,7 +2455,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, else { // Make the definition appear properly on the command line. Use - // -DNAME="value" instead of -D"NAME=value" to help VS6 parser. + // -DNAME="value" instead of -D"NAME=value" for historical reasons. std::string::size_type eq = defineIt->find("="); def += defineIt->substr(0, eq); if(eq != defineIt->npos) @@ -2559,7 +2559,7 @@ public: cmInstallTargetGenerator( t, dest, implib, "", std::vector<std::string>(), "Unspecified", cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), - false) + false, false) { this->Compute(lg); } @@ -2586,7 +2586,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -2647,7 +2647,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index b2927a9..8a68af6 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -454,13 +454,24 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc, cmGeneratorTarget* target) { - this->CustomCommandTargets[cc].insert(target); + CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>()); + std::pair<CustomCommandTargetMap::iterator, bool> + ins = this->CustomCommandTargets.insert(v); + if (ins.second) + { + this->CustomCommands.push_back(cc); + } + ins.first->second.insert(target); } void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() { - for (CustomCommandTargetMap::iterator i = this->CustomCommandTargets.begin(); - i != this->CustomCommandTargets.end(); ++i) { + for (std::vector<cmCustomCommand const*>::iterator vi = + this->CustomCommands.begin(); vi != this->CustomCommands.end(); ++vi) + { + CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi); + assert(i != this->CustomCommandTargets.end()); + // A custom command may appear on multiple targets. However, some build // systems exist where the target dependencies on some of the targets are // overspecified, leading to a dependency cycle. If we assume all target diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index b6987ef..5e1d6f2 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -106,6 +106,7 @@ private: typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> > CustomCommandTargetMap; CustomCommandTargetMap CustomCommandTargets; + std::vector<cmCustomCommand const*> CustomCommands; }; #endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx deleted file mode 100644 index cdacb9e..0000000 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ /dev/null @@ -1,2002 +0,0 @@ -/*============================================================================ - 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 "cmGlobalGenerator.h" -#include "cmLocalVisualStudio6Generator.h" -#include "cmMakefile.h" -#include "cmSystemTools.h" -#include "cmSourceFile.h" -#include "cmGeneratorTarget.h" -#include "cmCustomCommandGenerator.h" -#include "cmake.h" - -#include "cmComputeLinkInformation.h" - -#include <cmsys/RegularExpression.hxx> -#include <cmsys/FStream.hxx> - -cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): - cmLocalVisualStudioGenerator(gg, mf) -{ -} - -cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator() -{ -} - -//---------------------------------------------------------------------------- -// Helper class to write build events. -class cmLocalVisualStudio6Generator::EventWriter -{ -public: - EventWriter(cmLocalVisualStudio6Generator* lg, - const std::string& config, std::string& code): - LG(lg), Config(config), Code(code), First(true) {} - void Start(const char* event) - { - this->First = true; - this->Event = event; - } - void Finish() - { - this->Code += (this->First? "" : "\n"); - } - void Write(std::vector<cmCustomCommand> const& ccs) - { - for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin(); - ci != ccs.end(); ++ci) - { - this->Write(*ci); - } - } - void Write(cmCustomCommand const& cc) - { - cmCustomCommandGenerator ccg(cc, this->Config, this->LG); - if(this->First) - { - this->Code += this->Event + "_Cmds="; - this->First = false; - } - else - { - this->Code += "\\\n\t"; - } - this->Code += this->LG->ConstructScript(ccg, "\\\n\t"); - } -private: - cmLocalVisualStudio6Generator* LG; - std::string Config; - std::string& Code; - bool First; - std::string Event; -}; - -void cmLocalVisualStudio6Generator::AddCMakeListsRules() -{ - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); - l != tgts.end(); ++l) - { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY - || (*l)->GetType() == cmState::GLOBAL_TARGET) - { - continue; - } - - // Add a rule to regenerate the build system when the target - // specification source changes. - const char* suppRegenRule = - this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); - if (!cmSystemTools::IsOn(suppRegenRule)) - { - this->AddDSPBuildRule(*l); - } - } -} - -void cmLocalVisualStudio6Generator::Generate() -{ - this->OutputDSPFile(); -} - -void cmLocalVisualStudio6Generator::OutputDSPFile() -{ - // If not an in source build, then create the output directory - if(strcmp(this->GetCurrentBinaryDirectory(), - this->GetSourceDirectory()) != 0) - { - if(!cmSystemTools::MakeDirectory - (this->GetCurrentBinaryDirectory())) - { - cmSystemTools::Error("Error creating directory ", - this->GetCurrentBinaryDirectory()); - } - } - - // Create the DSP or set of DSP's for libraries and executables - - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); - l != tgts.end(); ++l) - { - switch((*l)->GetType()) - { - case cmState::STATIC_LIBRARY: - case cmState::OBJECT_LIBRARY: - this->SetBuildType(STATIC_LIBRARY, - (*l)->GetName().c_str(), *l); - break; - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - this->SetBuildType(DLL, - (*l)->GetName().c_str(), *l); - break; - case cmState::EXECUTABLE: - this->SetBuildType(EXECUTABLE, - (*l)->GetName().c_str(), *l); - break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - this->SetBuildType(UTILITY, - (*l)->GetName().c_str(), *l); - break; - case cmState::INTERFACE_LIBRARY: - continue; - default: - cmSystemTools::Error("Bad target type: ", (*l)->GetName().c_str()); - break; - } - // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace - // so don't build a projectfile for it - const char* path = - (*l)->GetProperty("EXTERNAL_MSPROJECT"); - if(!path) - { - // check to see if the dsp is going into a sub-directory - std::string::size_type pos = (*l)->GetName().rfind('/'); - if(pos != std::string::npos) - { - std::string dir = this->GetCurrentBinaryDirectory(); - dir += "/"; - dir += (*l)->GetName().substr(0, pos); - if(!cmSystemTools::MakeDirectory(dir.c_str())) - { - cmSystemTools::Error("Error creating directory: ", dir.c_str()); - } - } - this->CreateSingleDSP((*l)->GetName().c_str(), *l); - } - } -} - -// Utility function to make a valid VS6 *.dsp filename out -// of a CMake target name: -// -extern std::string GetVS6TargetName(const std::string& targetName); - -void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, - cmGeneratorTarget* target) -{ - // add to the list of projects - std::string pname = GetVS6TargetName(lname); - - // create the dsp.cmake file - std::string fname; - fname = this->GetCurrentBinaryDirectory(); - fname += "/"; - fname += pname; - fname += ".dsp"; - // save the name of the real dsp file - std::string realDSP = fname; - fname += ".cmake"; - cmsys::ofstream fout(fname.c_str()); - if(!fout) - { - cmSystemTools::Error("Error Writing ", fname.c_str()); - cmSystemTools::ReportLastSystemError(""); - } - this->WriteDSPFile(fout,pname.c_str(),target); - fout.close(); - // if the dsp file has changed, then write it. - cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str()); -} - - -void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmGeneratorTarget *tgt) -{ - std::string dspname = GetVS6TargetName(tgt->GetName()); - dspname += ".dsp.cmake"; - cmCustomCommandLine commandLine; - commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->GetCurrentSourceDirectory(); - makefileIn += "/"; - makefileIn += "CMakeLists.txt"; - if(!cmSystemTools::FileExists(makefileIn.c_str())) - { - return; - } - std::string comment = "Building Custom Rule "; - comment += makefileIn; - std::string args; - args = "-H"; - args += this->GetSourceDirectory(); - commandLine.push_back(args); - args = "-B"; - args += this->GetBinaryDirectory(); - commandLine.push_back(args); - - std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); - - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); - const char* no_working_directory = 0; - this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, - makefileIn.c_str(), commandLines, - comment.c_str(), - no_working_directory, true); - if(this->Makefile->GetSource(makefileIn.c_str())) - { - tgt->AddSource(makefileIn); - } - else - { - cmSystemTools::Error("Error adding rule for ", makefileIn.c_str()); - } -} - - -void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, - const std::string& libName, - cmGeneratorTarget *target) -{ - // For utility targets need custom command since pre- and post- - // build does not do anything in Visual Studio 6. In order for the - // rules to run in the correct order as custom commands, we need - // special care for dependencies. The first rule must depend on all - // the dependencies of all the rules. The later rules must each - // depend only on the previous rule. - if ((target->GetType() == cmState::UTILITY || - target->GetType() == cmState::GLOBAL_TARGET) && - (!target->GetPreBuildCommands().empty() || - !target->GetPostBuildCommands().empty())) - { - // Accumulate the dependencies of all the commands. - std::vector<std::string> depends; - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPreBuildCommands().begin(); - cr != target->GetPreBuildCommands().end(); ++cr) - { - depends.insert(depends.end(), - cr->GetDepends().begin(), cr->GetDepends().end()); - } - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPostBuildCommands().begin(); - cr != target->GetPostBuildCommands().end(); ++cr) - { - depends.insert(depends.end(), - cr->GetDepends().begin(), cr->GetDepends().end()); - } - - // Add the pre- and post-build commands in order. - int count = 1; - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPreBuildCommands().begin(); - cr != target->GetPreBuildCommands().end(); ++cr) - { - this->AddUtilityCommandHack(target, count++, depends, *cr); - } - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPostBuildCommands().begin(); - cr != target->GetPostBuildCommands().end(); ++cr) - { - this->AddUtilityCommandHack(target, count++, depends, *cr); - } - } - - // We may be modifying the source groups temporarily, so make a copy. - std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - - // get the classes from the source lists then add them to the groups - std::vector<cmSourceFile*> classes; - if (!target->GetConfigCommonSourceFiles(classes)) - { - return; - } - - // now all of the source files have been properly assigned to the target - // now stick them into source groups using the reg expressions - for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); - i != classes.end(); i++) - { - if (!(*i)->GetObjectLibrary().empty()) - { - continue; - } - - // Add the file to the list of sources. - std::string source = (*i)->GetFullPath(); - cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup->AssignSource(*i); - // while we are at it, if it is a .rule file then for visual studio 6 we - // must generate it - if ((*i)->GetPropertyAsBool("__CMAKE_RULE")) - { - if(!cmSystemTools::FileExists(source.c_str())) - { - cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); - // Make sure the path exists for the file - std::string path = cmSystemTools::GetFilenamePath(source); - cmSystemTools::MakeDirectory(path.c_str()); -#if defined(_WIN32) || defined(__CYGWIN__) - cmsys::ofstream sourceFout(source.c_str(), - std::ios::binary | std::ios::out - | std::ios::trunc); -#else - cmsys::ofstream sourceFout(source.c_str(), - std::ios::out | std::ios::trunc); -#endif - if(sourceFout) - { - sourceFout.write("# generated from CMake",22); - sourceFout.flush(); - sourceFout.close(); - } - } - } - } - - // Write the DSP file's header. - this->WriteDSPHeader(fout, libName, target, sourceGroups); - - - // Loop through every source group. - for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin(); - sg != sourceGroups.end(); ++sg) - { - this->WriteGroup(&(*sg), target, fout, libName); - } - - // Write the DSP file's footer. - this->WriteDSPFooter(fout); -} - -void cmLocalVisualStudio6Generator -::WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target, - std::ostream &fout, const std::string& libName) -{ - const std::vector<const cmSourceFile *> &sourceFiles = - sg->GetSourceFiles(); - // If the group is empty, don't write it at all. - - if(sourceFiles.empty() && sg->GetGroupChildren().empty()) - { - return; - } - - // If the group has a name, write the header. - std::string name = sg->GetName(); - if(name != "") - { - this->WriteDSPBeginGroup(fout, name.c_str(), ""); - } - - // Loop through each source in the source group. - for(std::vector<const cmSourceFile *>::const_iterator sf = - sourceFiles.begin(); sf != sourceFiles.end(); ++sf) - { - if (!(*sf)->GetObjectLibrary().empty()) - { - continue; - } - - std::string source = (*sf)->GetFullPath(); - const cmCustomCommand *command = - (*sf)->GetCustomCommand(); - std::string compileFlags; - std::vector<std::string> depends; - std::string objectNameDir; - if(target->HasExplicitObjectName(*sf)) - { - objectNameDir = - cmSystemTools::GetFilenamePath(target->GetObjectName(*sf)); - } - - // Add per-source file flags. - if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS")) - { - compileFlags += cflags; - } - - const std::string& lang = this->GetSourceFileLanguage(*(*sf)); - if(lang == "CXX") - { - // force a C++ file type - compileFlags += " /TP "; - } - else if(lang == "C") - { - // force to c file type - compileFlags += " /TC "; - } - - // Add per-source and per-configuration preprocessor definitions. - std::map<std::string, std::string> cdmap; - - { - std::set<std::string> targetCompileDefinitions; - - this->AppendDefines(targetCompileDefinitions, - (*sf)->GetProperty("COMPILE_DEFINITIONS")); - this->JoinDefines(targetCompileDefinitions, compileFlags, lang); - } - - if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG")) - { - std::set<std::string> debugCompileDefinitions; - this->AppendDefines(debugCompileDefinitions, cdefs); - this->JoinDefines(debugCompileDefinitions, cdmap["DEBUG"], lang); - } - if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE")) - { - std::set<std::string> releaseCompileDefinitions; - this->AppendDefines(releaseCompileDefinitions, cdefs); - this->JoinDefines(releaseCompileDefinitions, cdmap["RELEASE"], lang); - } - if(const char* cdefs = - (*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL")) - { - std::set<std::string> minsizerelCompileDefinitions; - this->AppendDefines(minsizerelCompileDefinitions, cdefs); - this->JoinDefines(minsizerelCompileDefinitions, cdmap["MINSIZEREL"], - lang); - } - if(const char* cdefs = - (*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO")) - { - std::set<std::string> relwithdebinfoCompileDefinitions; - this->AppendDefines(relwithdebinfoCompileDefinitions, cdefs); - this->JoinDefines(relwithdebinfoCompileDefinitions, - cdmap["RELWITHDEBINFO"], lang); - } - - bool excludedFromBuild = - (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); - - // Check for extra object-file dependencies. - const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); - if(dependsValue) - { - cmSystemTools::ExpandListArgument(dependsValue, depends); - } - if (GetVS6TargetName(source) != libName || - target->GetType() == cmState::UTILITY || - target->GetType() == cmState::GLOBAL_TARGET) - { - fout << "# Begin Source File\n\n"; - - // Tell MS-Dev what the source is. If the compiler knows how to - // build it, then it will. - fout << "SOURCE=" << - this->ConvertToOutputFormat(source.c_str(), SHELL) << "\n\n"; - if(!depends.empty()) - { - // Write out the dependencies for the rule. - fout << "USERDEP__HACK="; - for(std::vector<std::string>::const_iterator d = depends.begin(); - d != depends.end(); ++d) - { - fout << "\\\n\t" << - this->ConvertToOutputFormat(d->c_str(), SHELL); - } - fout << "\n"; - } - if (command) - { - const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; - this->WriteCustomRule(fout, source.c_str(), *command, flags); - } - else if(!compileFlags.empty() || !objectNameDir.empty() || - excludedFromBuild || !cdmap.empty()) - { - for(std::vector<std::string>::iterator i - = this->Configurations.begin(); - i != this->Configurations.end(); ++i) - { - // Strip the subdirectory name out of the configuration name. - std::string config = this->GetConfigName(*i); - if (i == this->Configurations.begin()) - { - fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; - } - else - { - fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; - } - if(excludedFromBuild) - { - fout << "# PROP Exclude_From_Build 1\n"; - } - if(!compileFlags.empty()) - { - fout << "\n# ADD CPP " << compileFlags << "\n\n"; - } - std::map<std::string, std::string>::iterator cdi = - cdmap.find(cmSystemTools::UpperCase(config)); - if(cdi != cdmap.end() && !cdi->second.empty()) - { - fout << "\n# ADD CPP " << cdi->second << "\n\n"; - } - if(!objectNameDir.empty()) - { - // Setup an alternate object file directory. - fout << "\n# PROP Intermediate_Dir \"" - << config << "/" << objectNameDir << "\"\n\n"; - } - } - fout << "!ENDIF\n\n"; - } - fout << "# End Source File\n"; - } - } - - std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); - - for(unsigned int i=0;i<children.size();++i) - { - this->WriteGroup(&children[i], target, fout, libName); - } - - - - - // If the group has a name, write the footer. - if(name != "") - { - this->WriteDSPEndGroup(fout); - } - -} - - -void -cmLocalVisualStudio6Generator -::AddUtilityCommandHack(cmGeneratorTarget *target, int count, - std::vector<std::string>& depends, - const cmCustomCommand& origCommand) -{ - // Create a fake output that forces the rule to run. - char* output = new char[(strlen(this->GetCurrentBinaryDirectory()) - + target->GetName().size() + 30)]; - sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(), - target->GetName().c_str(), count); - const char* comment = origCommand.GetComment(); - if(!comment && origCommand.GetOutputs().empty()) - { - comment = "<hack>"; - } - - // Add the rule with the given dependencies and commands. - std::string no_main_dependency = ""; - if(cmSourceFile* outsf = - this->Makefile->AddCustomCommandToOutput( - output, depends, no_main_dependency, - origCommand.GetCommandLines(), comment, - origCommand.GetWorkingDirectory().c_str())) - { - target->AddSource(outsf->GetFullPath()); - } - - // Replace the dependencies with the output of this rule so that the - // next rule added will run after this one. - depends.clear(); - depends.push_back(output); - - // Free the fake output name. - delete [] output; -} - -void -cmLocalVisualStudio6Generator -::WriteCustomRule(std::ostream& fout, - const char* source, - const cmCustomCommand& command, - const char* flags) -{ - // Write the rule for each configuration. - std::vector<std::string>::iterator i; - for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) - { - std::string config = this->GetConfigName(*i); - cmCustomCommandGenerator ccg(command, config, this); - std::string comment = - this->ConstructComment(ccg, "Building Custom Rule $(InputPath)"); - if(comment == "<hack>") - { - comment = ""; - } - - std::string script = - this->ConstructScript(ccg, "\\\n\t"); - - if (i == this->Configurations.begin()) - { - fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; - } - else - { - fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; - } - if(flags) - { - fout << "\n# ADD CPP " << flags << "\n\n"; - } - // Write out the dependencies for the rule. - fout << "USERDEP__HACK="; - for(std::vector<std::string>::const_iterator d = - ccg.GetDepends().begin(); - d != ccg.GetDepends().end(); - ++d) - { - // Lookup the real name of the dependency in case it is a CMake target. - std::string dep; - if(this->GetRealDependency(d->c_str(), config.c_str(), dep)) - { - fout << "\\\n\t" << - this->ConvertToOutputFormat(dep.c_str(), SHELL); - } - } - fout << "\n"; - - fout << "# PROP Ignore_Default_Tool 1\n"; - fout << "# Begin Custom Build -"; - if(!comment.empty()) - { - fout << " " << comment.c_str(); - } - fout << "\n\n"; - if(ccg.GetOutputs().empty()) - { - fout << source - << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << script.c_str() << "\n\n"; - } - else - { - for(std::vector<std::string>::const_iterator o = - ccg.GetOutputs().begin(); - o != ccg.GetOutputs().end(); - ++o) - { - // Write a rule for every output generated by this command. - fout << this->ConvertToOutputFormat(o->c_str(), SHELL) - << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << script.c_str() << "\n\n"; - } - } - fout << "# End Custom Build\n\n"; - } - - fout << "!ENDIF\n\n"; -} - - -void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter) -{ - fout << "# Begin Group \"" << group << "\"\n" - "# PROP Default_Filter \"" << filter << "\"\n"; -} - - -void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout) -{ - fout << "# End Group\n"; -} - - - - -void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, - const std::string& libName, - cmGeneratorTarget *target) -{ - std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); - const char *def= - this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); - - if( def) - { - root = def; - } - else - { - root += "/Templates"; - } - - switch(b) - { - case WIN32_EXECUTABLE: - break; - case STATIC_LIBRARY: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/staticLibFooter.dsptemplate"; - break; - case DLL: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/DLLHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/DLLFooter.dsptemplate"; - break; - case EXECUTABLE: - if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") ) - { - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; - } - else - { - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/EXEHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; - } - break; - case UTILITY: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/UtilityFooter.dsptemplate"; - break; - } - - // once the build type is set, determine what configurations are - // possible - cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); - - cmsys::RegularExpression reg("# Name "); - if(!fin) - { - cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); - } - - // reset this->Configurations - this->Configurations.erase(this->Configurations.begin(), - this->Configurations.end()); - - // now add all the configurations possible - std::string vs6name = GetVS6TargetName(libName); - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str()); - if (reg.find(line)) - { - this->Configurations.push_back(line.substr(reg.end())); - } - } -} - -//---------------------------------------------------------------------------- -cmsys::auto_ptr<cmCustomCommand> -cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmGeneratorTarget* target, - const std::string& config) -{ - cmsys::auto_ptr<cmCustomCommand> pcc; - - // VS6 forgets to create the output directory for archives if it - // differs from the intermediate directory. - if(target->GetType() != cmState::STATIC_LIBRARY) { return pcc; } - - std::string outDir = target->GetDirectory(config, false); - - // Add a pre-link event to create the directory. - cmCustomCommandLine command; - command.push_back(cmSystemTools::GetCMakeCommand()); - command.push_back("-E"); - command.push_back("make_directory"); - command.push_back(outDir); - std::vector<std::string> no_output; - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - cmCustomCommandLines commands; - commands.push_back(command); - pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, - no_depends, commands, 0, 0)); - pcc->SetEscapeOldStyle(false); - pcc->SetEscapeAllowMakeVars(true); - return pcc; -} - -// look for custom rules on a target and collect them together -std::string -cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target, - const std::string& configName, - const std::string& /* libName */) -{ - if (target->GetType() >= cmState::UTILITY ) - { - return ""; - } - - std::string customRuleCode = "# Begin Special Build Tool\n"; - EventWriter event(this, configName, customRuleCode); - - // Write the pre-build and pre-link together (VS6 does not support both). - event.Start("PreLink"); - event.Write(target->GetPreBuildCommands()); - event.Write(target->GetPreLinkCommands()); - cmsys::auto_ptr<cmCustomCommand> pcc( - this->MaybeCreateImplibDir(target, configName, false)); - if(pcc.get()) - { - event.Write(*pcc); - } - pcc = this->MaybeCreateOutputDir(target, configName); - if(pcc.get()) - { - event.Write(*pcc); - } - event.Finish(); - - // Write the post-build rules. - event.Start("PostBuild"); - event.Write(target->GetPostBuildCommands()); - event.Finish(); - - customRuleCode += "# End Special Build Tool\n"; - return customRuleCode; -} - - -inline std::string removeQuotes(const std::string& s) -{ - if(s[0] == '\"' && s[s.size()-1] == '\"') - { - return s.substr(1, s.size()-2); - } - return s; -} - - -std::string -cmLocalVisualStudio6Generator::GetTargetIncludeOptions( - cmGeneratorTarget *target, - const std::string& config) -{ - std::string includeOptions; - - // Setup /I and /LIBPATH options for the resulting DSP file. VS 6 - // truncates long include paths so make it as short as possible if - // the length threatens this problem. - unsigned int maxIncludeLength = 3000; - bool useShortPath = false; - - for(int j=0; j < 2; ++j) - { - std::vector<std::string> includes; - this->GetIncludeDirectories(includes, target, "C", config); - - std::vector<std::string>::iterator i; - for(i = includes.begin(); i != includes.end(); ++i) - { - std::string tmp = - this->ConvertToOutputFormat(i->c_str(), SHELL); - if(useShortPath) - { - cmSystemTools::GetShortPath(tmp.c_str(), tmp); - } - includeOptions += " /I "; - - // quote if not already quoted - if (tmp[0] != '"') - { - includeOptions += "\""; - includeOptions += tmp; - includeOptions += "\""; - } - else - { - includeOptions += tmp; - } - } - - if(j == 0 && includeOptions.size() > maxIncludeLength) - { - includeOptions = ""; - useShortPath = true; - } - else - { - break; - } - } - - return includeOptions; -} - - -// Code in blocks surrounded by a test for this definition is needed -// only for compatibility with user project's replacement DSP -// templates. The CMake templates no longer use them. -#define CM_USE_OLD_VS6 - -void cmLocalVisualStudio6Generator -::WriteDSPHeader(std::ostream& fout, - const std::string& libName, cmGeneratorTarget* target, - std::vector<cmSourceGroup> &) -{ - bool targetBuilds = (target->GetType() >= cmState::EXECUTABLE && - target->GetType() <= cmState::MODULE_LIBRARY); -#ifdef CM_USE_OLD_VS6 - // Lookup the library and executable output directories. - std::string libPath; - if(this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) - { - libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); - } - std::string exePath; - if(this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - } - - // Make sure there are trailing slashes. - if(!libPath.empty()) - { - if(libPath[libPath.size()-1] != '/') - { - libPath += "/"; - } - } - if(!exePath.empty()) - { - if(exePath[exePath.size()-1] != '/') - { - exePath += "/"; - } - } - - std::set<std::string> pathEmitted; - - // determine the link directories - std::string libOptions; - std::string libDebugOptions; - std::string libOptimizedOptions; - - std::string libMultiLineOptions; - std::string libMultiLineOptionsForDebug; - std::string libMultiLineDebugOptions; - std::string libMultiLineOptimizedOptions; - - if(!libPath.empty()) - { - std::string lpath = - this->ConvertToOutputFormat(libPath.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = libPath + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - if(!exePath.empty()) - { - std::string lpath = - this->ConvertToOutputFormat(exePath.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = exePath + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - std::vector<std::string>::const_iterator i; - const std::vector<std::string>& libdirs = - target->GetLinkDirectories(); - for(i = libdirs.begin(); i != libdirs.end(); ++i) - { - std::string path = *i; - if(path[path.size()-1] != '/') - { - path += "/"; - } - std::string lpath = - this->ConvertToOutputFormat(path.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = path + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - // find link libraries - const cmTarget::LinkLibraryVectorType& libs = - target->Target->GetLinkLibrariesForVS6(); - cmTarget::LinkLibraryVectorType::const_iterator j; - for(j = libs.begin(); j != libs.end(); ++j) - { - // add libraries to executables and dlls (but never include - // a library in a library, bad recursion) - // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES - if ((target->GetType() != cmState::SHARED_LIBRARY - && target->GetType() != cmState::STATIC_LIBRARY - && target->GetType() != cmState::MODULE_LIBRARY) || - (target->GetType()==cmState::SHARED_LIBRARY - && libName != GetVS6TargetName(j->first)) || - (target->GetType()==cmState::MODULE_LIBRARY - && libName != GetVS6TargetName(j->first))) - { - // Compute the proper name to use to link this library. - std::string lib; - std::string libDebug; - cmGeneratorTarget* tgt = - this->GlobalGenerator->FindGeneratorTarget(j->first.c_str()); - if(tgt) - { - lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); - libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); - lib += ".lib"; - libDebug += ".lib"; - } - else - { - lib = j->first.c_str(); - libDebug = j->first.c_str(); - if(j->first.find(".lib") == std::string::npos) - { - lib += ".lib"; - libDebug += ".lib"; - } - } - lib = this->ConvertToOutputFormat(lib.c_str(), SHELL); - libDebug = - this->ConvertToOutputFormat(libDebug.c_str(), SHELL); - - if (j->second == GENERAL_LibraryType) - { - libOptions += " "; - libOptions += lib; - libMultiLineOptions += "# ADD LINK32 "; - libMultiLineOptions += lib; - libMultiLineOptions += "\n"; - libMultiLineOptionsForDebug += "# ADD LINK32 "; - libMultiLineOptionsForDebug += libDebug; - libMultiLineOptionsForDebug += "\n"; - } - if (j->second == DEBUG_LibraryType) - { - libDebugOptions += " "; - libDebugOptions += lib; - - libMultiLineDebugOptions += "# ADD LINK32 "; - libMultiLineDebugOptions += libDebug; - libMultiLineDebugOptions += "\n"; - } - if (j->second == OPTIMIZED_LibraryType) - { - libOptimizedOptions += " "; - libOptimizedOptions += lib; - - libMultiLineOptimizedOptions += "# ADD LINK32 "; - libMultiLineOptimizedOptions += lib; - libMultiLineOptimizedOptions += "\n"; - } - } - } -#endif - - // Get include options for this target. - std::string includeOptionsDebug = this->GetTargetIncludeOptions(target, - "DEBUG"); - std::string includeOptionsRelease = this->GetTargetIncludeOptions(target, - "RELEASE"); - std::string includeOptionsRelWithDebInfo = this->GetTargetIncludeOptions( - target, - "RELWITHDEBINFO"); - std::string includeOptionsMinSizeRel = this->GetTargetIncludeOptions(target, - "MINSIZEREL"); - - // Get extra linker options for this target type. - std::string extraLinkOptions; - std::string extraLinkOptionsDebug; - std::string extraLinkOptionsRelease; - std::string extraLinkOptionsMinSizeRel; - std::string extraLinkOptionsRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO"); - } - if(target->GetType() == cmState::SHARED_LIBRARY) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO"); - } - if(target->GetType() == cmState::MODULE_LIBRARY) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO"); - } - - // Get extra linker options for this target. - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS")) - { - extraLinkOptions += " "; - extraLinkOptions += targetLinkFlags; - } - - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_DEBUG")) - { - extraLinkOptionsDebug += " "; - extraLinkOptionsDebug += targetLinkFlags; - } - - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_RELEASE")) - { - extraLinkOptionsRelease += " "; - extraLinkOptionsRelease += targetLinkFlags; - } - - if(const char* targetLinkFlags = - target->GetProperty("LINK_FLAGS_MINSIZEREL")) - { - extraLinkOptionsMinSizeRel += " "; - extraLinkOptionsMinSizeRel += targetLinkFlags; - } - - if(const char* targetLinkFlags = - target->GetProperty("LINK_FLAGS_RELWITHDEBINFO")) - { - extraLinkOptionsRelWithDebInfo += " "; - extraLinkOptionsRelWithDebInfo += targetLinkFlags; - } - - // Get standard libraries for this language. - if(targetBuilds) - { - // Get the language to use for linking. - std::vector<std::string> configs; - target->Target->GetMakefile()->GetConfigurations(configs); - std::vector<std::string>::const_iterator it = configs.begin(); - const std::string& linkLanguage = target->GetLinkerLanguage(*it); - for ( ; it != configs.end(); ++it) - { - const std::string& configLinkLanguage = target->GetLinkerLanguage(*it); - if (configLinkLanguage != linkLanguage) - { - cmSystemTools::Error - ("Linker language must not vary by configuration for target: ", - target->GetName().c_str()); - } - } - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - target->GetName().c_str()); - return; - } - - // Compute the variable name to lookup standard libraries for this - // language. - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += linkLanguage; - standardLibsVar += "_STANDARD_LIBRARIES"; - - // Add standard libraries. - if(const char* stdLibs = - this->Makefile->GetDefinition(standardLibsVar.c_str())) - { - extraLinkOptions += " "; - extraLinkOptions += stdLibs; - } - } - - // Compute version number information. - std::string targetVersionFlag; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - int major; - int minor; - target->GetTargetVersion(major, minor); - std::ostringstream targetVersionStream; - targetVersionStream << "/version:" << major << "." << minor; - targetVersionFlag = targetVersionStream.str(); - } - - // Compute the real name of the target. - std::string outputName = - "(OUTPUT_NAME is for libraries and executables only)"; - std::string outputNameDebug = outputName; - std::string outputNameRelease = outputName; - std::string outputNameMinSizeRel = outputName; - std::string outputNameRelWithDebInfo = outputName; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - outputName = target->GetFullName(); - outputNameDebug = target->GetFullName("Debug"); - outputNameRelease = target->GetFullName("Release"); - outputNameMinSizeRel = target->GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target->GetFullName("RelWithDebInfo"); - } - else if(target->GetType() == cmState::OBJECT_LIBRARY) - { - outputName = target->GetName(); - outputName += ".lib"; - outputNameDebug = outputName; - outputNameRelease = outputName; - outputNameMinSizeRel = outputName; - outputNameRelWithDebInfo = outputName; - } - - // Compute the output directory for the target. - std::string outputDirOld; - std::string outputDirDebug; - std::string outputDirRelease; - std::string outputDirMinSizeRel; - std::string outputDirRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { -#ifdef CM_USE_OLD_VS6 - outputDirOld = - removeQuotes(this->ConvertToOutputFormat - (target->GetDirectory().c_str(), SHELL)); -#endif - outputDirDebug = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("Debug").c_str(), SHELL)); - outputDirRelease = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("Release").c_str(), SHELL)); - outputDirMinSizeRel = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("MinSizeRel").c_str(), SHELL)); - outputDirRelWithDebInfo = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("RelWithDebInfo").c_str(), SHELL)); - } - else if(target->GetType() == cmState::OBJECT_LIBRARY) - { - std::string outputDir = cmake::GetCMakeFilesDirectoryPostSlash(); - outputDirDebug = outputDir + "Debug"; - outputDirRelease = outputDir + "Release"; - outputDirMinSizeRel = outputDir + "MinSizeRel"; - outputDirRelWithDebInfo = outputDir + "RelWithDebInfo"; - } - - // Compute the proper link information for the target. - std::string optionsDebug; - std::string optionsRelease; - std::string optionsMinSizeRel; - std::string optionsRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - extraLinkOptionsDebug = - extraLinkOptions + " " + extraLinkOptionsDebug; - extraLinkOptionsRelease = - extraLinkOptions + " " + extraLinkOptionsRelease; - extraLinkOptionsMinSizeRel = - extraLinkOptions + " " + extraLinkOptionsMinSizeRel; - extraLinkOptionsRelWithDebInfo = - extraLinkOptions + " " + extraLinkOptionsRelWithDebInfo; - this->ComputeLinkOptions(target, "Debug", extraLinkOptionsDebug, - optionsDebug); - this->ComputeLinkOptions(target, "Release", extraLinkOptionsRelease, - optionsRelease); - this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel, - optionsMinSizeRel); - this->ComputeLinkOptions(target, "RelWithDebInfo", - extraLinkOptionsRelWithDebInfo, - optionsRelWithDebInfo); - } - - // Compute the path of the import library. - std::string targetImplibFlagDebug; - std::string targetImplibFlagRelease; - std::string targetImplibFlagMinSizeRel; - std::string targetImplibFlagRelWithDebInfo; - if(target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY || - target->GetType() == cmState::EXECUTABLE) - { - std::string fullPathImpDebug = target->GetDirectory("Debug", true); - std::string fullPathImpRelease = target->GetDirectory("Release", true); - std::string fullPathImpMinSizeRel = - target->GetDirectory("MinSizeRel", true); - std::string fullPathImpRelWithDebInfo = - target->GetDirectory("RelWithDebInfo", true); - fullPathImpDebug += "/"; - fullPathImpRelease += "/"; - fullPathImpMinSizeRel += "/"; - fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target->GetFullName("Debug", true); - fullPathImpRelease += target->GetFullName("Release", true); - fullPathImpMinSizeRel += target->GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target->GetFullName("RelWithDebInfo", true); - - targetImplibFlagDebug = "/implib:"; - targetImplibFlagRelease = "/implib:"; - targetImplibFlagMinSizeRel = "/implib:"; - targetImplibFlagRelWithDebInfo = "/implib:"; - targetImplibFlagDebug += - this->ConvertToOutputFormat(fullPathImpDebug.c_str(), SHELL); - targetImplibFlagRelease += - this->ConvertToOutputFormat(fullPathImpRelease.c_str(), SHELL); - targetImplibFlagMinSizeRel += - this->ConvertToOutputFormat(fullPathImpMinSizeRel.c_str(), SHELL); - targetImplibFlagRelWithDebInfo += - this->ConvertToOutputFormat(fullPathImpRelWithDebInfo.c_str(), SHELL); - } - -#ifdef CM_USE_OLD_VS6 - // Compute link information for the target. - if(!extraLinkOptions.empty()) - { - libOptions += " "; - libOptions += extraLinkOptions; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 "; - libMultiLineOptions += extraLinkOptions; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 "; - libMultiLineOptionsForDebug += extraLinkOptions; - libMultiLineOptionsForDebug += " \n"; - } -#endif - - // are there any custom rules on the target itself - // only if the target is a lib or exe - std::string customRuleCodeRelease - = this->CreateTargetRules(target, "RELEASE", libName); - std::string customRuleCodeDebug - = this->CreateTargetRules(target, "DEBUG", libName); - std::string customRuleCodeMinSizeRel - = this->CreateTargetRules(target, "MINSIZEREL", libName); - std::string customRuleCodeRelWithDebInfo - = this->CreateTargetRules(target, "RELWITHDEBINFO", libName); - - cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); - if(!fin) - { - cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); - } - std::string staticLibOptions; - std::string staticLibOptionsDebug; - std::string staticLibOptionsRelease; - std::string staticLibOptionsMinSizeRel; - std::string staticLibOptionsRelWithDebInfo; - if(target->GetType() == cmState::STATIC_LIBRARY ) - { - const char *libflagsGlobal = - this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"); - this->AppendFlags(staticLibOptions, libflagsGlobal); - this->AppendFlags(staticLibOptionsDebug, libflagsGlobal); - this->AppendFlags(staticLibOptionsRelease, libflagsGlobal); - this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal); - this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal); - - this->AppendFlags(staticLibOptionsDebug, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG")); - this->AppendFlags(staticLibOptionsRelease, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE")); - this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL")); - this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO")); - - const char *libflags = target->GetProperty("STATIC_LIBRARY_FLAGS"); - this->AppendFlags(staticLibOptions, libflags); - this->AppendFlags(staticLibOptionsDebug, libflags); - this->AppendFlags(staticLibOptionsRelease, libflags); - this->AppendFlags(staticLibOptionsMinSizeRel, libflags); - this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags); - - this->AppendFlags(staticLibOptionsDebug, - target->GetProperty("STATIC_LIBRARY_FLAGS_DEBUG")); - this->AppendFlags(staticLibOptionsRelease, - target->GetProperty("STATIC_LIBRARY_FLAGS_RELEASE")); - this->AppendFlags(staticLibOptionsMinSizeRel, - target->GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL")); - this->AppendFlags(staticLibOptionsRelWithDebInfo, - target->GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO")); - - std::string objects; - this->OutputObjects(target, "LIB", objects); - if(!objects.empty()) - { - objects = "\n" + objects; - staticLibOptionsDebug += objects; - staticLibOptionsRelease += objects; - staticLibOptionsMinSizeRel += objects; - staticLibOptionsRelWithDebInfo += objects; - } - } - - // Add the export symbol definition for shared library objects. - std::string exportSymbol; - if(const char* exportMacro = target->GetExportMacro()) - { - exportSymbol = exportMacro; - } - - std::string line; - std::string libnameExports; - if(!exportSymbol.empty()) - { - libnameExports = "/D \""; - libnameExports += exportSymbol; - libnameExports += "\""; - } - while(cmSystemTools::GetLineFromStream(fin, line)) - { - const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); - if(!mfcFlag) - { - mfcFlag = "0"; - } - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS", - libnameExports.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG", - mfcFlag); - if(target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::OBJECT_LIBRARY) - { - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG", - staticLibOptionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE", - staticLibOptionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL", - staticLibOptionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO", - staticLibOptionsRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS", - staticLibOptions.c_str()); - } - if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) - { - cmSystemTools::ReplaceString(line, "/nologo", ""); - } - -#ifdef CM_USE_OLD_VS6 - cmSystemTools::ReplaceString(line, "CM_LIBRARIES", - libOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES", - libDebugOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES", - libOptimizedOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG", - libMultiLineOptionsForDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES", - libMultiLineOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES", - libMultiLineDebugOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES", - libMultiLineOptimizedOptions.c_str()); -#endif - - // Substitute the rules for custom command. When specifying just the - // target name for the command the command can be different for - // different configs - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE", - customRuleCodeRelease.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG", - customRuleCodeDebug.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL", - customRuleCodeMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO", - customRuleCodeRelWithDebInfo.c_str()); - - // Substitute the real output name into the template. - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG", - outputNameDebug.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE", - outputNameRelease.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL", - outputNameMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO", - outputNameRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str()); - - // Substitute the proper link information into the template. - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG", - optionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE", - optionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL", - optionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO", - optionsRelWithDebInfo.c_str()); - - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_DEBUG", - includeOptionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELEASE", - includeOptionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_MINSIZEREL", - includeOptionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELWITHDEBINFO", - includeOptionsRelWithDebInfo.c_str()); - - cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG", - targetVersionFlag.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG", - targetImplibFlagDebug.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELEASE", - targetImplibFlagRelease.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_MINSIZEREL", - targetImplibFlagMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO", - targetImplibFlagRelWithDebInfo.c_str()); - - std::string vs6name = GetVS6TargetName(libName); - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str()); - -#ifdef CM_USE_OLD_VS6 - // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH - // are already quoted in the template file, - // we need to remove the quotes here, we still need - // to convert to output path for unix to win32 conversion - cmSystemTools::ReplaceString - (line, "LIBRARY_OUTPUT_PATH", - removeQuotes(this->ConvertToOutputFormat - (libPath.c_str(), SHELL)).c_str()); - cmSystemTools::ReplaceString - (line, "EXECUTABLE_OUTPUT_PATH", - removeQuotes(this->ConvertToOutputFormat - (exePath.c_str(), SHELL)).c_str()); -#endif - - if(targetBuilds || target->GetType() == cmState::OBJECT_LIBRARY) - { - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG", - outputDirDebug.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELEASE", - outputDirRelease.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_MINSIZEREL", - outputDirMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELWITHDEBINFO", - outputDirRelWithDebInfo.c_str()); - if(!outputDirOld.empty()) - { - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY", - outputDirOld.c_str()); - } - } - - cmSystemTools::ReplaceString(line, - "EXTRA_DEFINES", - this->Makefile->GetDefineFlags()); - const char* debugPostfix - = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX", - debugPostfix?debugPostfix:""); - if(target->GetType() >= cmState::EXECUTABLE && - target->GetType() <= cmState::OBJECT_LIBRARY) - { - // store flags for each configuration - std::string flags = " "; - std::string flagsRelease = " "; - std::string flagsMinSizeRel = " "; - std::string flagsDebug = " "; - std::string flagsRelWithDebInfo = " "; - std::vector<std::string> configs; - target->Target->GetMakefile()->GetConfigurations(configs); - std::vector<std::string>::const_iterator it = configs.begin(); - const std::string& linkLanguage = target->GetLinkerLanguage(*it); - for ( ; it != configs.end(); ++it) - { - const std::string& configLinkLanguage = target->GetLinkerLanguage(*it); - if (configLinkLanguage != linkLanguage) - { - cmSystemTools::Error - ("Linker language must not vary by configuration for target: ", - target->GetName().c_str()); - } - } - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - target->GetName().c_str()); - return; - } - // if CXX is on and the target contains cxx code then add the cxx flags - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += linkLanguage; - baseFlagVar += "_FLAGS"; - flags = this->Makefile->GetSafeDefinition(baseFlagVar.c_str()); - - std::string flagVar = baseFlagVar + "_RELEASE"; - flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" "; - - flagVar = baseFlagVar + "_MINSIZEREL"; - flagsMinSizeRel = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsMinSizeRel += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" "; - - flagVar = baseFlagVar + "_DEBUG"; - flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" "; - - flagVar = baseFlagVar + "_RELWITHDEBINFO"; - flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - - this->AddCompileOptions(flags, target, linkLanguage, ""); - this->AddCompileOptions(flagsDebug, target, linkLanguage, "Debug"); - this->AddCompileOptions(flagsRelease, target, linkLanguage, "Release"); - this->AddCompileOptions(flagsMinSizeRel, target, linkLanguage, - "MinSizeRel"); - this->AddCompileOptions(flagsRelWithDebInfo, target, linkLanguage, - "RelWithDebInfo"); - - // if _UNICODE and _SBCS are not found, then add -D_MBCS - std::string defs = this->Makefile->GetDefineFlags(); - if(flags.find("D_UNICODE") == flags.npos && - defs.find("D_UNICODE") == flags.npos && - flags.find("D_SBCS") == flags.npos && - defs.find("D_SBCS") == flags.npos) - { - flags += " /D \"_MBCS\""; - } - - // Add per-target and per-configuration preprocessor definitions. - std::set<std::string> definesSet; - std::set<std::string> debugDefinesSet; - std::set<std::string> releaseDefinesSet; - std::set<std::string> minsizeDefinesSet; - std::set<std::string> debugrelDefinesSet; - - this->AddCompileDefinitions(definesSet, target, "", linkLanguage); - this->AddCompileDefinitions(debugDefinesSet, target, - "DEBUG", linkLanguage); - this->AddCompileDefinitions(releaseDefinesSet, target, - "RELEASE", linkLanguage); - this->AddCompileDefinitions(minsizeDefinesSet, target, - "MINSIZEREL", linkLanguage); - this->AddCompileDefinitions(debugrelDefinesSet, target, - "RELWITHDEBINFO", linkLanguage); - - std::string defines = " "; - std::string debugDefines = " "; - std::string releaseDefines = " "; - std::string minsizeDefines = " "; - std::string debugrelDefines = " "; - - this->JoinDefines(definesSet, defines, ""); - this->JoinDefines(debugDefinesSet, debugDefines, ""); - this->JoinDefines(releaseDefinesSet, releaseDefines, ""); - this->JoinDefines(minsizeDefinesSet, minsizeDefines, ""); - this->JoinDefines(debugrelDefinesSet, debugrelDefines, ""); - - flags += defines; - flagsDebug += debugDefines; - flagsRelease += releaseDefines; - flagsMinSizeRel += minsizeDefines; - flagsRelWithDebInfo += debugrelDefines; - - // The template files have CXX FLAGS in them, that need to be replaced. - // There are not separate CXX and C template files, so we use the same - // variable names. The previous code sets up flags* variables to - // contain the correct C or CXX flags - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", - flagsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", - flagsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO", - flagsRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", - flagsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str()); - - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_MINSIZEREL", - minsizeDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_DEBUG", - debugDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELWITHDEBINFO", - debugrelDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELEASE", - releaseDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS", - defines.c_str()); - } - - fout << line.c_str() << std::endl; - } -} - -void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) -{ - cmsys::ifstream fin(this->DSPFooterTemplate.c_str()); - if(!fin) - { - cmSystemTools::Error("Error Reading ", - this->DSPFooterTemplate.c_str()); - } - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - fout << line << std::endl; - } -} - -//---------------------------------------------------------------------------- -void cmLocalVisualStudio6Generator -::ComputeLinkOptions(cmGeneratorTarget *target, - const std::string& configName, - const std::string extraOptions, - std::string& options) -{ - // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); - if(!pcli) - { - return; - } - cmComputeLinkInformation& cli = *pcli; - typedef cmComputeLinkInformation::ItemVector ItemVector; - ItemVector const& linkLibs = cli.GetItems(); - std::vector<std::string> const& linkDirs = cli.GetDirectories(); - - this->OutputObjects(target, "LINK", options); - - // Build the link options code. - for(std::vector<std::string>::const_iterator d = linkDirs.begin(); - d != linkDirs.end(); ++d) - { - std::string dir = *d; - if(!dir.empty()) - { - if(dir[dir.size()-1] != '/') - { - dir += "/"; - } - dir += "$(IntDir)"; - options += "# ADD LINK32 /LIBPATH:"; - options += this->ConvertToOutputFormat(dir.c_str(), SHELL); - options += " /LIBPATH:"; - options += this->ConvertToOutputFormat(d->c_str(), SHELL); - options += "\n"; - } - } - for(ItemVector::const_iterator l = linkLibs.begin(); - l != linkLibs.end(); ++l) - { - options += "# ADD LINK32 "; - if(l->IsPath) - { - options += - this->ConvertToOutputFormat(l->Value.c_str(), SHELL); - } - else if (!l->Target - || l->Target->GetType() != cmState::INTERFACE_LIBRARY) - { - options += l->Value; - } - options += "\n"; - } - - // Add extra options if any. - if(!extraOptions.empty()) - { - options += "# ADD LINK32 "; - options += extraOptions; - options += "\n"; - } -} - -//---------------------------------------------------------------------------- -void cmLocalVisualStudio6Generator -::OutputObjects(cmGeneratorTarget* target, const char* tool, - std::string& options) -{ - // VS 6 does not support per-config source locations so we - // list object library content on the link line instead. - std::vector<std::string> objs; - target->UseObjectLibraries(objs, ""); - for(std::vector<std::string>::const_iterator - oi = objs.begin(); oi != objs.end(); ++oi) - { - options += "# ADD "; - options += tool; - options += "32 "; - options += this->ConvertToOutputFormat(oi->c_str(), SHELL); - options += "\n"; - } -} - -std::string -cmLocalVisualStudio6Generator -::GetTargetDirectory(cmGeneratorTarget const*) const -{ - // No per-target directory for this generator (yet). - return ""; -} - -//---------------------------------------------------------------------------- -std::string -cmLocalVisualStudio6Generator -::ComputeLongestObjectDirectory(cmGeneratorTarget const*) const -{ - // Compute the maximum length configuration name. - std::string config_max; - for(std::vector<std::string>::const_iterator - i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) - { - // Strip the subdirectory name out of the configuration name. - std::string config = this->GetConfigName(*i); - if(config.size() > config_max.size()) - { - config_max = config; - } - } - - // Compute the maximum length full path to the intermediate - // files directory for any configuration. This is used to construct - // object file names that do not produce paths that are too long. - std::string dir_max; - dir_max += this->GetCurrentBinaryDirectory(); - dir_max += "/"; - dir_max += config_max; - dir_max += "/"; - return dir_max; -} - -std::string -cmLocalVisualStudio6Generator -::GetConfigName(std::string const& configuration) const -{ - // Strip the subdirectory name out of the configuration name. - std::string config = configuration; - std::string::size_type pos = config.find_last_of(" "); - config = config.substr(pos+1, std::string::npos); - config = config.substr(0, config.size()-1); - return config; -} - -//---------------------------------------------------------------------------- -bool -cmLocalVisualStudio6Generator -::CheckDefinition(std::string const& define) const -{ - // Perform the standard check first. - if(!this->cmLocalGenerator::CheckDefinition(define)) - { - return false; - } - - // Now do the VS6-specific check. - if(define.find_first_of(" ") != define.npos && - define.find_first_of("\"$;") != define.npos) - { - std::ostringstream e; - e << "WARNING: The VS6 IDE does not support preprocessor definition " - << "values with spaces and '\"', '$', or ';'.\n" - << "CMake is dropping a preprocessor definition: " << define << "\n" - << "Consider defining the macro in a (configured) header file.\n"; - cmSystemTools::Message(e.str().c_str()); - return false; - } - - // Assume it is supported. - return true; -} diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h deleted file mode 100644 index dab32a5..0000000 --- a/Source/cmLocalVisualStudio6Generator.h +++ /dev/null @@ -1,105 +0,0 @@ -/*============================================================================ - 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 cmLocalVisualStudio6Generator_h -#define cmLocalVisualStudio6Generator_h - -#include "cmLocalVisualStudioGenerator.h" - -class cmSourceFile; -class cmSourceGroup; -class cmCustomCommand; - -/** \class cmLocalVisualStudio6Generator - * \brief Write a LocalUnix makefiles. - * - * cmLocalVisualStudio6Generator produces a LocalUnix makefile from its - * member this->Makefile. - */ -class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator -{ -public: - ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); - - virtual ~cmLocalVisualStudio6Generator(); - - virtual void AddCMakeListsRules(); - - /** - * Generate the makefile for this directory. - */ - virtual void Generate(); - - void OutputDSPFile(); - - enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY}; - - /** - * Specify the type of the build: static, dll, or executable. - */ - void SetBuildType(BuildType, const std::string& libName, cmGeneratorTarget*); - - virtual - std::string GetTargetDirectory(cmGeneratorTarget const* target) const; - virtual std::string - ComputeLongestObjectDirectory(cmGeneratorTarget const*) const; -private: - std::string DSPHeaderTemplate; - std::string DSPFooterTemplate; - - void CreateSingleDSP(const std::string& lname, cmGeneratorTarget* tgt); - void WriteDSPFile(std::ostream& fout, const std::string& libName, - cmGeneratorTarget* tgt); - void WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter); - void WriteDSPEndGroup(std::ostream& fout); - - void WriteDSPHeader(std::ostream& fout, const std::string& libName, - cmGeneratorTarget* tgt, std::vector<cmSourceGroup> &sgs); - - void WriteDSPFooter(std::ostream& fout); - void AddDSPBuildRule(cmGeneratorTarget* tgt); - void WriteCustomRule(std::ostream& fout, - const char* source, - const cmCustomCommand& command, - const char* flags); - void AddUtilityCommandHack(cmGeneratorTarget* target, int count, - std::vector<std::string>& depends, - const cmCustomCommand& origCommand); - void WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target, - std::ostream &fout, const std::string& libName); - class EventWriter; - friend class EventWriter; - cmsys::auto_ptr<cmCustomCommand> - MaybeCreateOutputDir(cmGeneratorTarget *target, const std::string& config); - std::string CreateTargetRules(cmGeneratorTarget* target, - const std::string& configName, - const std::string& libName); - void ComputeLinkOptions(cmGeneratorTarget* target, - const std::string& configName, - const std::string extraOptions, - std::string& options); - void OutputObjects(cmGeneratorTarget* target, const char* tool, - std::string& options); - std::string GetTargetIncludeOptions(cmGeneratorTarget* target, - const std::string& config); - std::vector<std::string> Configurations; - - std::string GetConfigName(std::string const& configuration) const; - - // Special definition check for VS6. - virtual bool CheckDefinition(std::string const& define) const; -}; - -#endif - diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ae6a24e..abae564 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -25,7 +25,7 @@ #include <ctype.h> // for isspace -static bool cmLVS6G_IsFAT(const char* dir); +static bool cmLVS7G_IsFAT(const char* dir); class cmLocalVisualStudio7GeneratorInternals { @@ -999,7 +999,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // Check if we need the FAT32 workaround. // Check the filesystem type where the target will be written. - if (cmLVS6G_IsFAT(target->GetDirectory(configName).c_str())) + if (cmLVS7G_IsFAT(target->GetDirectory(configName).c_str())) { // Add a flag telling the manifest tool to use a workaround // for FAT32 file systems, which can cause an empty manifest @@ -1012,6 +1012,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, this->OutputTargetRules(fout, configName, target, libName); this->OutputBuildTool(fout, configName, target, targetOptions); + this->OutputDeploymentDebuggerTool(fout, configName, target); fout << "\t\t</Configuration>\n"; } @@ -1374,6 +1375,32 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } } +void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool( + std::ostream& fout, std::string const& config, cmGeneratorTarget* target) +{ + if (this->WindowsCEProject) + { + if (const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY")) + { + fout << + "\t\t\t<DeploymentTool\n" + "\t\t\t\tForceDirty=\"-1\"\n" + "\t\t\t\tRemoteDirectory=\"" << this->EscapeForXML(dir) << "\"\n" + "\t\t\t\tRegisterOutput=\"0\"\n" + "\t\t\t\tAdditionalFiles=\"\"/>\n" + ; + std::string const exe = + dir + std::string("\\") + target->GetFullName(config); + fout << + "\t\t\t<DebuggerTool\n" + "\t\t\t\tRemoteExecutable=\"" << this->EscapeForXML(exe) << "\"\n" + "\t\t\t\tArguments=\"\"\n" + "\t\t\t/>\n" + ; + } + } +} + //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator @@ -2365,7 +2392,7 @@ std::string cmLocalVisualStudio7Generator //---------------------------------------------------------------------------- #include <windows.h> -static bool cmLVS6G_IsFAT(const char* dir) +static bool cmLVS7G_IsFAT(const char* dir) { if(dir[0] && dir[1] == ':') { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 7bb9cc6..562f485 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -92,6 +92,9 @@ private: const std::string& libName); void OutputBuildTool(std::ostream& fout, const std::string& configName, cmGeneratorTarget* t, const Options& targetOptions); + void OutputDeploymentDebuggerTool(std::ostream& fout, + std::string const& config, + cmGeneratorTarget* target); void OutputLibraryDirectories(std::ostream& fout, std::vector<std::string> const& dirs); void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget *target); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 950b247..1df5cec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -733,26 +733,6 @@ void cmMakefile::ConfigureFinalPass() "with CMake 2.4 or later. For compatibility with older versions please " "use any CMake 2.8.x release or lower."); } -#if defined(_WIN32) && !defined(__CYGWIN__) - // Do old-style link dependency analysis only for CM_USE_OLD_VS6. - if(this->GetGlobalGenerator()->IsForVS6()) - { - for (cmTargets::iterator l = this->Targets.begin(); - l != this->Targets.end(); l++) - { - if (l->second.GetType() == cmState::INTERFACE_LIBRARY) - { - continue; - } - // Erase any cached link information that might have been comptued - // on-demand during the configuration. This ensures that build - // system generation uses up-to-date information even if other cache - // invalidation code in this source file is buggy. - - l->second.AnalyzeLibDependenciesForVS6(*this); - } - } -#endif } //---------------------------------------------------------------------------- @@ -1334,14 +1314,6 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) return false; } - // VS6 IDE does not support definition values with spaces in - // combination with '"', '$', or ';'. - if((this->GetGlobalGenerator()->GetName() == "Visual Studio 6") && - (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos)) - { - return false; - } - // Definitions with non-trivial values require a policy check. static cmsys::RegularExpression trivial("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$"); @@ -3766,17 +3738,13 @@ std::string cmMakefile::GetModulesFile(const char* filename) const } // Always search in the standard modules location. - const char* cmakeRoot = this->GetDefinition("CMAKE_ROOT"); - if(cmakeRoot) - { - moduleInCMakeRoot = cmakeRoot; - moduleInCMakeRoot += "/Modules/"; - moduleInCMakeRoot += filename; - cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot); - if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) - { - moduleInCMakeRoot = ""; - } + moduleInCMakeRoot = cmSystemTools::GetCMakeRoot(); + moduleInCMakeRoot += "/Modules/"; + moduleInCMakeRoot += filename; + cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot); + if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) + { + moduleInCMakeRoot = ""; } // Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file @@ -3791,7 +3759,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) { const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); - std::string mods = cmakeRoot + std::string("/Modules/"); + std::string mods = cmSystemTools::GetCMakeRoot() + "/Modules/"; if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0) { switch (this->GetPolicyStatus(cmPolicies::CMP0017)) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 1923ea4..435844e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -841,37 +841,3 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),libCleanFiles.end()); } - -//---------------------------------------------------------------------------- -void -cmMakefileLibraryTargetGenerator -::AppendOSXVerFlag(std::string& flags, const std::string& lang, - const char* name, bool so) -{ - // Lookup the flag to specify the version. - std::string fvar = "CMAKE_"; - fvar += lang; - fvar += "_OSX_"; - fvar += name; - fvar += "_VERSION_FLAG"; - const char* flag = this->Makefile->GetDefinition(fvar); - - // Skip if no such flag. - if(!flag) - { - return; - } - - // Lookup the target version information. - int major; - int minor; - int patch; - this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); - if(major > 0 || minor > 0 || patch > 0) - { - // Append the flag since a non-zero version is specified. - std::ostringstream vflag; - vflag << flag << major << "." << minor << "." << patch; - this->LocalGenerator->AppendFlags(flags, vflag.str()); - } -} diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 68980c3..009f15d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -38,9 +38,6 @@ protected: // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; - - void AppendOSXVerFlag(std::string& flags, const std::string& lang, - const char* name, bool so); }; #endif diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 17561b5..c34df3c 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -504,6 +504,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } + // Add OS X version flags, if any. + if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) + { + this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, + "COMPATIBILITY", true); + this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, + "CURRENT", false); + } + this->addPoolNinjaVariable("JOB_POOL_LINK", >, vars); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 08caea3..4cab81f 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -1003,8 +1003,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( SetupAutoRccTarget(target); } - const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); - std::string inputFile = cmakeRoot; + std::string inputFile = cmSystemTools::GetCMakeRoot(); inputFile += "/Modules/AutogenInfo.cmake.in"; std::string outputFile = targetDir; outputFile += "/AutogenInfo.cmake"; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3ba7287..9af54bf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -60,8 +60,7 @@ #endif #if defined(CMAKE_BUILD_WITH_CMAKE) -# include <fcntl.h> -# include "cmCryptoHash.h" +# include "cmCryptoHash.h" #endif #if defined(CMAKE_USE_ELF_PARSER) @@ -2184,8 +2183,10 @@ unsigned int cmSystemTools::RandomSeed() } seed; // Try using a real random source. - cmsys::ifstream fin("/dev/urandom"); - if(fin && fin.read(seed.bytes, sizeof(seed)) && + cmsys::ifstream fin; + fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read. + fin.open("/dev/urandom"); + if(fin.good() && fin.read(seed.bytes, sizeof(seed)) && fin.gcount() == sizeof(seed)) { return seed.integer; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1986e5f..576189f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,9 +55,6 @@ public: cmTarget::cmTarget() { this->Makefile = 0; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6Analyzed = false; -#endif this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -699,9 +696,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, cmTarget::LibraryID tmp; tmp.first = lib; tmp.second = llt; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6.push_back( tmp ); -#endif this->OriginalLinkLibraries.push_back(tmp); // Add the explicit dependency information for this target. This is @@ -811,298 +805,6 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces); } -#if defined(_WIN32) && !defined(__CYGWIN__) -//---------------------------------------------------------------------------- -void -cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf ) -{ - // There are two key parts of the dependency analysis: (1) - // determining the libraries in the link line, and (2) constructing - // the dependency graph for those libraries. - // - // The latter is done using the cache entries that record the - // dependencies of each library. - // - // The former is a more thorny issue, since it is not clear how to - // determine if two libraries listed on the link line refer to the a - // single library or not. For example, consider the link "libraries" - // /usr/lib/libtiff.so -ltiff - // Is this one library or two? The solution implemented here is the - // simplest (and probably the only practical) one: two libraries are - // the same if their "link strings" are identical. Thus, the two - // libraries above are considered distinct. This also means that for - // dependency analysis to be effective, the CMake user must specify - // libraries build by his project without using any linker flags or - // file extensions. That is, - // LINK_LIBRARIES( One Two ) - // instead of - // LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a ) - // The former is probably what most users would do, but it never - // hurts to document the assumptions. :-) Therefore, in the analysis - // code, the "canonical name" of a library is simply its name as - // given to a LINK_LIBRARIES command. - // - // Also, we will leave the original link line intact; we will just add any - // dependencies that were missing. - // - // There is a problem with recursive external libraries - // (i.e. libraries with no dependency information that are - // recursively dependent). We must make sure that the we emit one of - // the libraries twice to satisfy the recursion, but we shouldn't - // emit it more times than necessary. In particular, we must make - // sure that handling this improbable case doesn't cost us when - // dealing with the common case of non-recursive libraries. The - // solution is to assume that the recursion is satisfied at one node - // of the dependency tree. To illustrate, assume libA and libB are - // extrenal and mutually dependent. Suppose libX depends on - // libA, and libY on libA and libX. Then - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B A ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB -lA". This is the correct way to - // specify the dependencies, since the mutual dependency of A and B - // is resolved *every time libA is specified*. - // - // Something like - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB", and the mutual dependency - // information is lost. This is because in some case (Y), the mutual - // dependency of A and B is listed, while in another other case (X), - // it is not. Depending on which line actually emits A, the mutual - // dependency may or may not be on the final link line. We can't - // handle this pathalogical case cleanly without emitting extra - // libraries for the normal cases. Besides, the dependency - // information for X is wrong anyway: if we build an executable - // depending on X alone, we would not have the mutual dependency on - // A and B resolved. - // - // IMPROVEMENTS: - // -- The current algorithm will not always pick the "optimal" link line - // when recursive dependencies are present. It will instead break the - // cycles at an aribtrary point. The majority of projects won't have - // cyclic dependencies, so this is probably not a big deal. Note that - // the link line is always correct, just not necessary optimal. - - { - // Expand variables in link library names. This is for backwards - // compatibility with very early CMake versions and should - // eventually be removed. This code was moved here from the end of - // old source list processing code which was called just before this - // method. - for(LinkLibraryVectorType::iterator p = this->LinkLibrariesForVS6.begin(); - p != this->LinkLibrariesForVS6.end(); ++p) - { - this->Makefile->ExpandVariablesInString(p->first, true, true); - } - } - - // The dependency map. - DependencyMap dep_map; - - // 1. Build the dependency graph - // - for(LinkLibraryVectorType::reverse_iterator lib - = this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - this->GatherDependenciesForVS6( mf, *lib, dep_map); - } - - // 2. Remove any dependencies that are already satisfied in the original - // link line. - // - for(LinkLibraryVectorType::iterator lib = this->LinkLibrariesForVS6.begin(); - lib != this->LinkLibrariesForVS6.end(); ++lib) - { - for( LinkLibraryVectorType::iterator lib2 = lib; - lib2 != this->LinkLibrariesForVS6.end(); ++lib2) - { - this->DeleteDependencyForVS6( dep_map, *lib, *lib2); - } - } - - - // 3. Create the new link line by simply emitting any dependencies that are - // missing. Start from the back and keep adding. - // - std::set<DependencyMap::key_type> done, visited; - std::vector<DependencyMap::key_type> newLinkLibrariesForVS6; - for(LinkLibraryVectorType::reverse_iterator lib = - this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - // skip zero size library entries, this may happen - // if a variable expands to nothing. - if (!lib->first.empty()) - { - this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 ); - } - } - - // 4. Add the new libraries to the link line. - // - for( std::vector<DependencyMap::key_type>::reverse_iterator k = - newLinkLibrariesForVS6.rbegin(); - k != newLinkLibrariesForVS6.rend(); ++k ) - { - // get the llt from the dep_map - this->LinkLibrariesForVS6.push_back( std::make_pair(k->first,k->second) ); - } - this->LinkLibrariesForVS6Analyzed = true; -} - -//---------------------------------------------------------------------------- -void cmTarget::InsertDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - depMap[lib].push_back(dep); -} - -//---------------------------------------------------------------------------- -void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - // Make sure there is an entry in the map for lib. If so, delete all - // dependencies to dep. There may be repeated entries because of - // external libraries that are specified multiple times. - DependencyMap::iterator map_itr = depMap.find( lib ); - if( map_itr != depMap.end() ) - { - DependencyList& depList = map_itr->second; - DependencyList::iterator begin = - std::remove(depList.begin(), depList.end(), dep); - depList.erase(begin, depList.end()); - } -} - -//---------------------------------------------------------------------------- -void cmTarget::EmitForVS6(const LibraryID lib, - const DependencyMap& dep_map, - std::set<LibraryID>& emitted, - std::set<LibraryID>& visited, - DependencyList& link_line ) -{ - // It's already been emitted - if( emitted.find(lib) != emitted.end() ) - { - return; - } - - // Emit the dependencies only if this library node hasn't been - // visited before. If it has, then we have a cycle. The recursion - // that got us here should take care of everything. - - if( visited.insert(lib).second ) - { - if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies? - { - const DependencyList& dep_on = dep_map.find( lib )->second; - DependencyList::const_reverse_iterator i; - - // To cater for recursive external libraries, we must emit - // duplicates on this link line *unless* they were emitted by - // some other node, in which case we assume that the recursion - // was resolved then. We making the simplifying assumption that - // any duplicates on a single link line are on purpose, and must - // be preserved. - - // This variable will keep track of the libraries that were - // emitted directly from the current node, and not from a - // recursive call. This way, if we come across a library that - // has already been emitted, we repeat it iff it has been - // emitted here. - std::set<DependencyMap::key_type> emitted_here; - for( i = dep_on.rbegin(); i != dep_on.rend(); ++i ) - { - if( emitted_here.find(*i) != emitted_here.end() ) - { - // a repeat. Must emit. - emitted.insert(*i); - link_line.push_back( *i ); - } - else - { - // Emit only if no-one else has - if( emitted.find(*i) == emitted.end() ) - { - // emit dependencies - this->EmitForVS6( *i, dep_map, emitted, visited, link_line ); - // emit self - emitted.insert(*i); - emitted_here.insert(*i); - link_line.push_back( *i ); - } - } - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf, - const LibraryID& lib, - DependencyMap& dep_map) -{ - // If the library is already in the dependency map, then it has - // already been fully processed. - if( dep_map.find(lib) != dep_map.end() ) - { - return; - } - - const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" ); - if( deps && strcmp(deps,"") != 0 ) - { - // Make sure this library is in the map, even if it has an empty - // set of dependencies. This distinguishes the case of explicitly - // no dependencies with that of unspecified dependencies. - dep_map[lib]; - - // Parse the dependency information, which is a set of - // type, library pairs separated by ";". There is always a trailing ";". - cmTargetLinkLibraryType llt = GENERAL_LibraryType; - std::string depline = deps; - std::string::size_type start = 0; - std::string::size_type end; - end = depline.find( ";", start ); - while( end != std::string::npos ) - { - std::string l = depline.substr( start, end-start ); - if(!l.empty()) - { - if (l == "debug") - { - llt = DEBUG_LibraryType; - } - else if (l == "optimized") - { - llt = OPTIMIZED_LibraryType; - } - else if (l == "general") - { - llt = GENERAL_LibraryType; - } - else - { - LibraryID lib2(l,llt); - this->InsertDependencyForVS6( dep_map, lib, lib2); - this->GatherDependenciesForVS6( mf, lib2, dep_map); - llt = GENERAL_LibraryType; - } - } - start = end+1; // skip the ; - end = depline.find( ";", start ); - } - // cannot depend on itself - this->DeleteDependencyForVS6( dep_map, lib, lib); - } -} -#endif - //---------------------------------------------------------------------------- static bool whiteListedInterfaceProperty(const std::string& prop) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 97b0871..4e97c2c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -245,13 +245,6 @@ public: cmStringRange GetLinkImplementationEntries() const; cmBacktraceRange GetLinkImplementationBacktraces() const; -#if defined(_WIN32) && !defined(__CYGWIN__) - const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { - return this->LinkLibrariesForVS6;} - - void AnalyzeLibDependenciesForVS6( const cmMakefile& mf ); -#endif - struct StrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; @@ -259,57 +252,6 @@ public: private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; -#if defined(_WIN32) && !defined(__CYGWIN__) - /** - * A list of direct dependencies. Use in conjunction with DependencyMap. - */ - typedef std::vector< LibraryID > DependencyList; - - /** - * This map holds the dependency graph. map[x] returns a set of - * direct dependencies of x. Note that the direct depenencies are - * ordered. This is necessary to handle direct dependencies that - * themselves have no dependency information. - */ - typedef std::map< LibraryID, DependencyList > DependencyMap; - - /** - * Inserts \a dep at the end of the dependency list of \a lib. - */ - void InsertDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep); - - /* - * Deletes \a dep from the dependency list of \a lib. - */ - void DeleteDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep); - - /** - * Emits the library \a lib and all its dependencies into link_line. - * \a emitted keeps track of the libraries that have been emitted to - * avoid duplicates--it is more efficient than searching - * link_line. \a visited is used detect cycles. Note that \a - * link_line is in reverse order, in that the dependencies of a - * library are listed before the library itself. - */ - void EmitForVS6( const LibraryID lib, - const DependencyMap& dep_map, - std::set<LibraryID>& emitted, - std::set<LibraryID>& visited, - DependencyList& link_line); - - /** - * Finds the dependencies for \a lib and inserts them into \a - * dep_map. - */ - void GatherDependenciesForVS6( const cmMakefile& mf, - const LibraryID& lib, - DependencyMap& dep_map); -#endif - const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; @@ -338,9 +280,6 @@ private: std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands; LinkLibraryVectorType PrevLinkedLibraries; LinkLibraryVectorType OriginalLinkLibraries; -#if defined(_WIN32) && !defined(__CYGWIN__) - LinkLibraryVectorType LinkLibrariesForVS6; -#endif cmMakefile* Makefile; cmTargetInternalPointer Internal; cmState::TargetType TargetTypeValue; @@ -351,9 +290,6 @@ private: bool IsImportedTarget; bool ImportedGloballyVisible; bool BuildInterfaceIncludesAppended; -#if defined(_WIN32) && !defined(__CYGWIN__) - bool LinkLibrariesForVS6Analyzed; -#endif std::string ProcessSourceItemCMP0049(const std::string& s); diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 6fd6ab7..1c795c4 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -12,9 +12,11 @@ #include "cmTimestamp.h" #include <cstring> +#include <cstdlib> #include <sys/types.h> #include <sys/stat.h> +#include <sstream> //---------------------------------------------------------------------------- std::string cmTimestamp::CurrentTime( @@ -44,7 +46,7 @@ std::string cmTimestamp::FileModificationTime(const char* path, //---------------------------------------------------------------------------- std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, - std::string formatString, bool utcFlag) + std::string formatString, bool utcFlag) const { if(formatString.empty()) { @@ -79,12 +81,12 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, for(std::string::size_type i = 0; i < formatString.size(); ++i) { char c1 = formatString[i]; - char c2 = (i+1 < formatString.size()) ? - formatString[i+1] : static_cast<char>(0); + char c2 = (i + 1 < formatString.size()) ? + formatString[i + 1] : static_cast<char>(0); if(c1 == '%' && c2 != 0) { - result += AddTimestampComponent(c2, timeStruct); + result += AddTimestampComponent(c2, timeStruct, timeT); ++i; } else @@ -97,8 +99,40 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, } //---------------------------------------------------------------------------- +time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm &tm) const +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return _mkgmtime(&tm); +#else + // From Linux timegm() manpage. + + std::string tz_old = "TZ="; + if (const char* tz = cmSystemTools::GetEnv("TZ")) + { + tz_old += tz; + } + + // The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC. + // It seems that "TZ=" does NOT work, at least under Windows + // with neither MSVC nor MinGW, so let's use explicit "TZ=UTC" + + cmSystemTools::PutEnv("TZ=UTC"); + + tzset(); + + time_t result = mktime(&tm); + + cmSystemTools::PutEnv(tz_old); + + tzset(); + + return result; +#endif +} + +//---------------------------------------------------------------------------- std::string cmTimestamp::AddTimestampComponent( - char flag, struct tm& timeStruct) + char flag, struct tm& timeStruct, const time_t timeT) const { std::string formatString = "%"; formatString += flag; @@ -117,6 +151,26 @@ std::string cmTimestamp::AddTimestampComponent( case 'y': case 'Y': break; + case 's': // Seconds since UNIX epoch (midnight 1-jan-1970) + { + // Build a time_t for UNIX epoch and substract from the input "timeT": + struct tm tmUnixEpoch; + memset(&tmUnixEpoch, 0, sizeof(tmUnixEpoch)); + tmUnixEpoch.tm_mday = 1; + tmUnixEpoch.tm_year = 1970-1900; + + const time_t unixEpoch = this->CreateUtcTimeTFromTm(tmUnixEpoch); + if (unixEpoch == -1) + { + cmSystemTools::Error("Error generating UNIX epoch in " + "STRING(TIMESTAMP ...). Please, file a bug report aginst CMake"); + return std::string(); + } + + std::stringstream ss; + ss << static_cast<long int>(difftime(timeT, unixEpoch)); + return ss.str(); + } default: { return formatString; diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index 24c1869..7c4b216 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -16,7 +16,7 @@ #include <time.h> /** \class cmTimestamp - * \brief Utility class to generate sting representation of a timestamp + * \brief Utility class to generate string representation of a timestamp * */ class cmTimestamp @@ -30,10 +30,13 @@ public: const std::string& formatString, bool utcFlag); private: - std::string CreateTimestampFromTimeT(time_t timeT, - std::string formatString, bool utcFlag); + time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const; - std::string AddTimestampComponent(char flag, struct tm& timeStruct); + std::string CreateTimestampFromTimeT( + time_t timeT, std::string formatString, bool utcFlag) const; + + std::string AddTimestampComponent( + char flag, struct tm& timeStruct, time_t timeT) const; }; diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 12ce015..87fbbdf 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -28,7 +28,7 @@ bool cmTryCompileCommand return false; } - this->TryCompileCode(argv); + this->TryCompileCode(argv, false); // if They specified clean then we clean up what we can if (this->SrcFileSignature) diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index b9ffe5e..d4a36c9 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -135,7 +135,7 @@ bool cmTryRunCommand this->CompileResultVariable = argv[1]; // do the try compile - int res = this->TryCompileCode(tryCompile); + int res = this->TryCompileCode(tryCompile, true); // now try running the command if it compiled if (!res) diff --git a/Source/cmVS14CLFlagTable.h b/Source/cmVS14CLFlagTable.h index 422f47b..173f624 100644 --- a/Source/cmVS14CLFlagTable.h +++ b/Source/cmVS14CLFlagTable.h @@ -28,6 +28,8 @@ static cmVS7FlagTable cmVS14CLFlagTable[] = "Custom", "Custom", 0}, {"Optimization", "Od", "Disabled", "Disabled", 0}, + {"Optimization", "Os", + "Minimize Size", "MinSize", 0}, {"Optimization", "O1", "Minimize Size", "MinSpace", 0}, {"Optimization", "O2", @@ -172,6 +174,24 @@ static cmVS7FlagTable cmVS14CLFlagTable[] = {"CompileAsManaged", "clr:oldSyntax", "Common Language RunTime Support, Old Syntax", "OldSyntax", 0}, + {"CppLanguageStandard", "", + "Default", "Default", 0}, + {"CppLanguageStandard", "std=c++98", + "C++03", "c++98", 0}, + {"CppLanguageStandard", "std=c++11", + "C++11", "c++11", 0}, + {"CppLanguageStandard", "std=c++1y", + "C++14", "c++1y", 0 }, + {"CppLanguageStandard", "std=c++14", + "C++14", "c++1y", 0 }, + {"CppLanguageStandard", "std=gnu++98", + "C++03 (GNU Dialect)", "gnu++98", 0}, + {"CppLanguageStandard", "std=gnu++11", + "C++11 (GNU Dialect)", "gnu++11", 0}, + {"CppLanguageStandard", "std=gnu++1y", + "C++14 (GNU Dialect)", "gnu++1y", 0}, + {"CppLanguageStandard", "std=gnu++14", + "C++14 (GNU Dialect)", "gnu++1y", 0}, //Bool Properties {"CompileAsWinRT", "ZW", "", "true", 0}, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index da950be..31873b5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -696,43 +696,51 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() i->c_str(), 1, " Label=\"Configuration\"", "\n"); std::string configType = "<ConfigurationType>"; - switch(this->GeneratorTarget->GetType()) - { - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - configType += "DynamicLibrary"; - break; - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: - configType += "StaticLibrary"; - break; - case cmState::EXECUTABLE: - if(this->NsightTegra && - !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) - { - // Android executables are .so too. + if (const char* vsConfigurationType = + this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) + { + configType += cmVS10EscapeXML(vsConfigurationType); + } + else + { + switch(this->GeneratorTarget->GetType()) + { + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: configType += "DynamicLibrary"; - } - else - { - configType += "Application"; - } - break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - if(this->NsightTegra) - { - // Tegra-Android platform does not understand "Utility". + break; + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: configType += "StaticLibrary"; - } - else - { - configType += "Utility"; - } - break; - case cmState::UNKNOWN_LIBRARY: - case cmState::INTERFACE_LIBRARY: - break; + break; + case cmState::EXECUTABLE: + if(this->NsightTegra && + !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) + { + // Android executables are .so too. + configType += "DynamicLibrary"; + } + else + { + configType += "Application"; + } + break; + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: + if(this->NsightTegra) + { + // Tegra-Android platform does not understand "Utility". + configType += "StaticLibrary"; + } + else + { + configType += "Utility"; + } + break; + case cmState::UNKNOWN_LIBRARY: + case cmState::INTERFACE_LIBRARY: + break; + } } configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); @@ -2070,7 +2078,18 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( if(this->MSTools) { - this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); + cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*"); + const char* toolset = this->GlobalGenerator->GetPlatformToolset(); + if (toolset && clangToolset.find(toolset)) + { + this->WriteString("<ObjectFileName>" + "$(IntDir)%(filename).obj" + "</ObjectFileName>\n", 3); + } + else + { + this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); + } // If not in debug mode, write the DebugInformationFormat field // without value so PDBs don't get generated uselessly. diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 5bc34c1..911e154 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -111,102 +111,102 @@ void cmXCodeObject::Print(std::ostream& out) for(i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end(); ++i) { - cmXCodeObject* object = i->second; - if(i->first != "isa") - { - cmXCodeObject::Indent(3*indentFactor, out); - } - else - { + if(i->first == "isa") continue; - } - if(object->TypeValue == OBJECT_LIST) - { - out << i->first << " = (" << separator; - for(unsigned int k = 0; k < i->second->List.size(); k++) - { - cmXCodeObject::Indent(4*indentFactor, out); - out << i->second->List[k]->Id; - i->second->List[k]->PrintComment(out); - out << "," << separator; - } - cmXCodeObject::Indent(3*indentFactor, out); - out << ");" << separator; - } - else if(object->TypeValue == ATTRIBUTE_GROUP) + + PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this); + } + cmXCodeObject::Indent(2*indentFactor, out); + out << "};\n"; +} + +void cmXCodeObject::PrintAttribute(std::ostream& out, const int level, + const std::string separator, + const int factor, const std::string& name, + const cmXCodeObject* object, + const cmXCodeObject* parent) +{ + cmXCodeObject::Indent(level * factor, out); + switch(object->TypeValue) + { + case OBJECT_LIST: { - std::map<std::string, cmXCodeObject*>::iterator j; - out << i->first << " = {"; - if(separator == "\n") + out << name << " = ("; + if(parent->TypeValue != ATTRIBUTE_GROUP) { out << separator; } - for(j = object->ObjectAttributes.begin(); j != - object->ObjectAttributes.end(); ++j) + for(unsigned int i = 0; i < object->List.size(); ++i) { - cmXCodeObject::Indent(4 *indentFactor, out); - - if(j->second->TypeValue == STRING) - { - cmXCodeObject::PrintString(out,j->first); - out << " = "; - j->second->PrintString(out); - out << ";"; - } - else if(j->second->TypeValue == OBJECT_LIST) + if(object->List[i]->TypeValue == STRING) { - cmXCodeObject::PrintString(out,j->first); - out << " = ("; - for(unsigned int k = 0; k < j->second->List.size(); k++) + object->List[i]->PrintString(out); + if(i+1 < object->List.size()) { - if(j->second->List[k]->TypeValue == STRING) - { - j->second->List[k]->PrintString(out); - out << ", "; - } - else - { - out << "List_" << k << "_TypeValue_IS_NOT_STRING, "; - } + out << ","; } - out << ");"; } else { - cmXCodeObject::PrintString(out,j->first); - out << " = error_unexpected_TypeValue_" << - j->second->TypeValue << ";"; + cmXCodeObject::Indent((level + 1) * factor, out); + out << object->List[i]->Id; + object->List[i]->PrintComment(out); + out << "," << separator; } + } + if(parent->TypeValue != ATTRIBUTE_GROUP) + { + cmXCodeObject::Indent(level * factor, out); + } + out << ");" << separator; + } + break; + case ATTRIBUTE_GROUP: + { + out << name << " = {"; + if(separator == "\n") + { out << separator; } - cmXCodeObject::Indent(3 *indentFactor, out); + std::map<std::string, cmXCodeObject*>::const_iterator i; + for(i = object->ObjectAttributes.begin(); + i != object->ObjectAttributes.end(); ++i) + { + PrintAttribute(out, (level + 1) * factor, separator, factor, + i->first, i->second, object); + } + cmXCodeObject::Indent(level * factor, out); out << "};" << separator; } - else if(object->TypeValue == OBJECT_REF) + break; + + case OBJECT_REF: { - cmXCodeObject::PrintString(out,i->first); + cmXCodeObject::PrintString(out, name); out << " = " << object->Object->Id; - if(object->Object->HasComment() && i->first != "remoteGlobalIDString") + if(object->Object->HasComment() && name != "remoteGlobalIDString") { object->Object->PrintComment(out); } out << ";" << separator; } - else if(object->TypeValue == STRING) + break; + + case STRING: { - cmXCodeObject::PrintString(out,i->first); + cmXCodeObject::PrintString(out, name); out << " = "; object->PrintString(out); out << ";" << separator; } - else + break; + + default: { - out << "what is this?? " << i->first << "\n"; + break; } } - cmXCodeObject::Indent(2*indentFactor, out); - out << "};\n"; } //---------------------------------------------------------------------------- diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index bd0f43f..2d876da 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -75,6 +75,10 @@ public: } static void Indent(int level, std::ostream& out); void Print(std::ostream& out); + void PrintAttribute(std::ostream& out, const int level, + const std::string separator, const int factor, + const std::string& name, const cmXCodeObject* object, + const cmXCodeObject* parent); virtual void PrintComment(std::ostream&) {} static void PrintList(std::vector<cmXCodeObject*> const&, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8f6b952..dcc95af 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -51,8 +51,6 @@ // include the generator #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) -# include "cmGlobalVisualStudio6Generator.h" -# include "cmGlobalVisualStudio7Generator.h" # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" # include "cmGlobalVisualStudio9Generator.h" @@ -1429,8 +1427,6 @@ int cmake::ActualConfigure() const char* GeneratorName; }; VSRegistryEntryName version[] = { - {"6.0", "Visual Studio 6"}, - {"7.0", "Visual Studio 7"}, {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, {"9.0", "Visual Studio 9 2008"}, @@ -1837,10 +1833,6 @@ void cmake::AddDefaultGenerators() this->Generators.push_back( cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio7Generator::NewFactory()); - this->Generators.push_back( - cmGlobalVisualStudio6Generator::NewFactory()); - this->Generators.push_back( cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back( cmGlobalNMakeMakefileGenerator::NewFactory()); @@ -2417,8 +2409,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // we have to find the module directory, so we can copy the files this->AddCMakePaths(); - std::string modulesPath = - this->State->GetInitializedCacheValue("CMAKE_ROOT"); + std::string modulesPath = cmSystemTools::GetCMakeRoot(); modulesPath += "/Modules"; std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a06b26f..600cc1a 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -60,6 +60,7 @@ static const char * cmDocumentationUsageNote[][2] = #define CMAKE_BUILD_OPTIONS \ " <dir> = Project binary directory to be built.\n" \ " --target <tgt> = Build <tgt> instead of default targets.\n" \ + " May only be specified once.\n" \ " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \ " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ @@ -386,6 +387,7 @@ static int do_build(int ac, char const* const* av) std::string dir; std::vector<std::string> nativeOptions; bool clean = false; + bool hasTarget = false; enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative}; Doing doing = DoingDir; @@ -397,7 +399,17 @@ static int do_build(int ac, char const* const* av) } else if(strcmp(av[i], "--target") == 0) { - doing = DoingTarget; + if (!hasTarget) + { + doing = DoingTarget; + hasTarget = true; + } + else + { + std::cerr << "'--target' may not be specified more than once.\n\n"; + dir = ""; + break; + } } else if(strcmp(av[i], "--config") == 0) { @@ -449,13 +461,6 @@ static int do_build(int ac, char const* const* av) return 1; } - // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value: - // - if (cmSystemTools::StringStartsWith(config.c_str(), ".\\")) - { - config = config.substr(2); - } - cmake cm; return cm.Build(dir, target, config, nativeOptions, clean); #endif diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 3636836..f713294 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -20,6 +20,7 @@ #if 0 # include "CommandLineArguments.hxx.in" # include "Configure.hxx.in" +# include "String.hxx.in" #endif #include <vector> diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c index b9d25a8..b75acb2 100644 --- a/Source/kwsys/MD5.c +++ b/Source/kwsys/MD5.c @@ -254,7 +254,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ #define F(x, y, z) (((x) & (y)) | (~(x) & (z))) #define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ + t = a + F(b,c,d) + X[k] + (Ti);\ a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ SET(a, b, c, d, 0, 7, T1); @@ -280,7 +280,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ #define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) #define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ + t = a + G(b,c,d) + X[k] + (Ti);\ a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ SET(a, b, c, d, 1, 5, T17); @@ -306,7 +306,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ #define H(x, y, z) ((x) ^ (y) ^ (z)) #define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ + t = a + H(b,c,d) + X[k] + (Ti);\ a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ SET(a, b, c, d, 5, 4, T33); @@ -332,7 +332,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ #define I(x, y, z) ((y) ^ ((x) | ~(z))) #define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ + t = a + I(b,c,d) + X[k] + (Ti);\ a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ SET(a, b, c, d, 0, 6, T49); diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in index c5ebc97..96563a2 100644 --- a/Source/kwsys/Process.h.in +++ b/Source/kwsys/Process.h.in @@ -77,6 +77,7 @@ # define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit) # define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt) # define kwsysProcess_Kill kwsys_ns(Process_Kill) +# define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime) #endif #if defined(__cplusplus) @@ -392,6 +393,11 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp); */ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); +/** + * Reset the start time of the child process to the current time. + */ +kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp); + #if defined(__cplusplus) } /* extern "C" */ #endif @@ -456,6 +462,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); # undef kwsysProcess_WaitForExit # undef kwsysProcess_Interrupt # undef kwsysProcess_Kill +# undef kwsysProcess_ResetStartTime # endif #endif diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 07c644b..b577982 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.tv_sec = -1; } /*--------------------------------------------------------------------------*/ @@ -3056,3 +3058,14 @@ static void kwsysProcessesSignalHandler(int signum errno = old_errno; } + +/*--------------------------------------------------------------------------*/ +void kwsysProcess_ResetStartTime(kwsysProcess* cp) +{ + if(!cp) + { + return; + } + /* Reset start time. */ + cp->StartTime = kwsysProcessTimeGetCurrent(); +} diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 1f8749f..2b93e69 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -17,7 +17,7 @@ duplicate the above list of headers. */ #if 0 # include "Process.h.in" -# include "Encoding_c.h.in" +# include "Encoding.h.in" #endif /* @@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.QuadPart = -1; } /*--------------------------------------------------------------------------*/ @@ -3015,3 +3017,14 @@ static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType) /* Continue on to default Ctrl handler (which calls ExitProcess). */ return FALSE; } + +/*--------------------------------------------------------------------------*/ +void kwsysProcess_ResetStartTime(kwsysProcess* cp) +{ + if(!cp) + { + return; + } + /* Reset start time. */ + cp->StartTime = kwsysProcessTimeGetCurrent(); +} diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index cddcc8d..512d5fb 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -43,7 +43,6 @@ #if 0 # include "SystemInformation.hxx.in" # include "Process.h.in" -# include "Configure.hxx.in" #endif #include <iostream> @@ -177,13 +176,13 @@ typedef struct rlimit ResourceLimitType; # if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG) # define iostreamLongLong(x) (x) # else -# define iostreamLongLong(x) ((long)x) +# define iostreamLongLong(x) ((long)(x)) # endif #elif defined(KWSYS_USE___INT64) # if defined(KWSYS_IOS_HAS_OSTREAM___INT64) # define iostreamLongLong(x) (x) # else -# define iostreamLongLong(x) ((long)x) +# define iostreamLongLong(x) ((long)(x)) # endif #else # error "No Long Long" @@ -201,13 +200,13 @@ typedef struct rlimit ResourceLimitType; # endif #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) +#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && !defined(__clang__) #define USE_ASM_INSTRUCTIONS 1 #else #define USE_ASM_INSTRUCTIONS 0 #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__) #include <intrin.h> #define USE_CPUID_INTRINSICS 1 #else @@ -861,7 +860,7 @@ void SystemInformation::RunMemoryCheck() // -------------------------------------------------------------- // SystemInformationImplementation starts here -#define STORE_TLBCACHE_INFO(x,y) x = (x < y) ? y : x +#define STORE_TLBCACHE_INFO(x,y) x = (x < (y)) ? (y) : x #define TLBCACHE_INFO_UNITS (15) #define CLASSICAL_CPU_FREQ_LOOP 10000000 #define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31 @@ -3570,33 +3569,44 @@ SystemInformationImplementation::GetHostMemoryUsed() return (statex.ullTotalPhys - statex.ullAvailPhys)/1024; # endif #elif defined(__linux) - const char *names[3]={"MemTotal:","MemFree:",NULL}; - SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; - int ierr=GetFieldsFromFile("/proc/meminfo",names,values); + // First try to use MemAvailable, but it only works on newer kernels + const char *names2[3]={"MemTotal:","MemAvailable:",NULL}; + SystemInformation::LongLong values2[2]={SystemInformation::LongLong(0)}; + int ierr=GetFieldsFromFile("/proc/meminfo",names2,values2); if (ierr) { - return ierr; - } - SystemInformation::LongLong &memTotal=values[0]; - SystemInformation::LongLong &memFree=values[1]; - return memTotal - memFree; + const char *names4[5]={"MemTotal:","MemFree:","Buffers:","Cached:",NULL}; + SystemInformation::LongLong values4[4]={SystemInformation::LongLong(0)}; + ierr=GetFieldsFromFile("/proc/meminfo",names4,values4); + if(ierr) + { + return ierr; + } + SystemInformation::LongLong &memTotal=values4[0]; + SystemInformation::LongLong &memFree=values4[1]; + SystemInformation::LongLong &memBuffers=values4[2]; + SystemInformation::LongLong &memCached=values4[3]; + return memTotal - memFree - memBuffers - memCached; + } + SystemInformation::LongLong &memTotal=values2[0]; + SystemInformation::LongLong &memAvail=values2[1]; + return memTotal - memAvail; #elif defined(__APPLE__) SystemInformation::LongLong psz=getpagesize(); if (psz<1) { return -1; } - const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL}; - SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)}; + const char *names[3]={"Pages wired down:","Pages active:",NULL}; + SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; int ierr=GetFieldsFromCommand("vm_stat", names, values); if (ierr) { return -1; } - SystemInformation::LongLong &vmActive=values[0]; - SystemInformation::LongLong &vmInactive=values[1]; - SystemInformation::LongLong &vmWired=values[2]; - return ((vmActive+vmInactive+vmWired)*psz)/1024; + SystemInformation::LongLong &vmWired=values[0]; + SystemInformation::LongLong &vmActive=values[1]; + return ((vmActive+vmWired)*psz)/1024; #else return 0; #endif @@ -4622,7 +4632,7 @@ std::string SystemInformationImplementation::RunProcess(std::vector<const char*> double timeout = 255; int pipe; // pipe id as returned by kwsysProcess_WaitForData() - while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout), + while( ( static_cast<void>(pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout)), (pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s { buffer.append(data, length); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index e3428f8..0c7f419 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -35,10 +35,12 @@ #include <fstream> #include <sstream> #include <set> +#include <vector> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 +# include "RegularExpression.hxx.in" # include "SystemTools.hxx.in" # include "Directory.hxx.in" # include "FStream.hxx.in" @@ -87,6 +89,7 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# include <winioctl.h> # ifndef INVALID_FILE_ATTRIBUTES # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) # endif @@ -2754,6 +2757,106 @@ std::string SystemTools::GetLastSystemError() return strerror(e); } +#ifdef _WIN32 + +static bool IsJunction(const std::wstring& source) +{ +#ifdef FSCTL_GET_REPARSE_POINT + const DWORD JUNCTION_ATTRS = FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_REPARSE_POINT; + DWORD attrs = GetFileAttributesW(source.c_str()); + if (attrs == INVALID_FILE_ATTRIBUTES) + { + return false; + } + if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS) + { + return false; + } + + // Adjust privileges so that we can succefully open junction points. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Query whether this is a reparse point or not. + BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) buffer; + DWORD sentinel; + + BOOL success = DeviceIoControl( + dir, FSCTL_GET_REPARSE_POINT, + NULL, 0, + reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, + &sentinel, NULL); + + CloseHandle(dir); + + return (success && (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)); +#else + return false; +#endif +} + +static bool DeleteJunction(const std::wstring& source) +{ +#ifdef FSCTL_DELETE_REPARSE_POINT + // Adjust privileges so that we can succefully open junction points as + // read/write. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Set up the structure so that we can delete the junction. + std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0); + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) &buffer[0]; + DWORD sentinel; + + reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; + + BOOL success = DeviceIoControl( + dir, FSCTL_DELETE_REPARSE_POINT, + reparse_buffer, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, + NULL, 0, + &sentinel, NULL); + + CloseHandle(dir); + + return !!success; +#else + return false; +#endif +} +#endif + bool SystemTools::RemoveFile(const std::string& source) { #ifdef _WIN32 @@ -2781,6 +2884,10 @@ bool SystemTools::RemoveFile(const std::string& source) SetLastError(err); return false; } + if (IsJunction(ws) && !DeleteJunction(ws)) + { + return false; + } if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND) @@ -4651,8 +4758,9 @@ bool SystemTools::GetLineFromStream(std::istream& is, // been reached. Clear the fail bit just before reading. while(!haveNewline && leftToRead != 0 && - (is.clear(is.rdstate() & ~std::ios::failbit), - is.getline(buffer, bufferSize), is.gcount() > 0)) + (static_cast<void>(is.clear(is.rdstate() & ~std::ios::failbit)), + static_cast<void>(is.getline(buffer, bufferSize)), + is.gcount() > 0)) { // We have read at least one byte. haveData = true; diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx index 695a134..7c58769 100644 --- a/Source/kwsys/testDynamicLoader.cxx +++ b/Source/kwsys/testDynamicLoader.cxx @@ -53,7 +53,7 @@ static std::string GetLibName(const char* lname) * r2: should GetSymbolAddress succeed ? * r3: should CloseLibrary succeed ? */ -int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3) +static int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3) { std::cerr << "Testing: " << libname << std::endl; kwsys::DynamicLoader::LibraryHandle l diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx index ab1f83e..ae66ceb 100644 --- a/Source/kwsys/testHashSTL.cxx +++ b/Source/kwsys/testHashSTL.cxx @@ -18,7 +18,6 @@ #if 0 # include "hash_map.hxx.in" # include "hash_set.hxx.in" -# include "hashtable.hxx.in" #endif #include <iostream> diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx index 396a09d..5ff7955 100644 --- a/Source/kwsys/testIOS.cxx +++ b/Source/kwsys/testIOS.cxx @@ -18,6 +18,12 @@ #include <vector> #include <string.h> /* strlen */ +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Configure.hxx.in" +#endif + int testIOS(int, char*[]) { std::ostringstream ostr; |