diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/QtDialog/AddCacheEntry.cxx | 12 | ||||
-rw-r--r-- | Source/QtDialog/AddCacheEntry.h | 3 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 25 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 10 | ||||
-rw-r--r-- | Source/cmConfigureFileCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmConfigureFileCommand.h | 11 | ||||
-rw-r--r-- | Source/cmDocumentLocationUndefined.h | 24 | ||||
-rw-r--r-- | Source/cmExportCommand.h | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 146 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 18 | ||||
-rw-r--r-- | Source/cmMakefile.h | 5 | ||||
-rw-r--r-- | Source/cmNewLineStyle.cxx | 95 | ||||
-rw-r--r-- | Source/cmNewLineStyle.h | 46 | ||||
-rw-r--r-- | Source/cmQtAutomoc.cxx | 6 | ||||
-rw-r--r-- | Source/cmStandardIncludes.h | 5 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 37 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 57 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/kwsys/kwsysDateStamp.cmake | 4 |
20 files changed, 417 insertions, 108 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 5205738..b5115b7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -162,6 +162,7 @@ SET(SRCS cmDocumentationSection.cxx cmDocumentCompileDefinitions.h cmDocumentGeneratorExpressions.h + cmDocumentLocationUndefined.h cmDocumentVariables.cxx cmDynamicLoader.cxx cmDynamicLoader.h @@ -216,6 +217,8 @@ SET(SRCS cmMakefileExecutableTargetGenerator.cxx cmMakefileLibraryTargetGenerator.cxx cmMakefileUtilityTargetGenerator.cxx + cmNewLineStyle.h + cmNewLineStyle.cxx cmOrderDirectories.cxx cmOrderDirectories.h cmPolicies.h diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index b4d9191..00aaf69 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -12,15 +12,16 @@ #include "AddCacheEntry.h" #include <QMetaProperty> +#include <QCompleter> static const int NumTypes = 4; -static const QString TypeStrings[NumTypes] = +static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeProperty::PropertyType Types[NumTypes] = - { QCMakeProperty::BOOL, QCMakeProperty::PATH, - QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) : QWidget(p) { this->setupUi(this); @@ -42,6 +43,7 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); + this->Name->setCompleter(new QCompleter(completions, this)); } QString AddCacheEntry::name() const diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index db6baf9..e219d4e 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -15,6 +15,7 @@ #include <QWidget> #include <QCheckBox> +#include <QStringList> #include "QCMake.h" #include "ui_AddCacheEntry.h" @@ -23,7 +24,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p); + AddCacheEntry(QWidget* p, const QStringList& completions); QString name() const; QVariant value() const; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index c8c4bfa..1c058d3 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -68,6 +68,9 @@ CMakeSetupDialog::CMakeSetupDialog() int w = settings.value("Width", 700).toInt(); this->resize(w, h); + this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 3); @@ -1008,7 +1011,7 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1021,6 +1024,26 @@ void CMakeSetupDialog::addCacheEntry() { QCMakeCacheModel* m = this->CacheValues->cacheModel(); m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); + + // only add variable names to the completion which are new + if (!this->AddVariableCompletions.contains(w->name())) + { + this->AddVariableCompletions << w->name(); + // limit to at most 100 completion items + if (this->AddVariableCompletions.size() > 100) + { + this->AddVariableCompletions.removeFirst(); + } + // make sure CMAKE_INSTALL_PREFIX is always there + if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + { + this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + } + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AddVariableCompletionEntries", + this->AddVariableCompletions); + } } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 5121759..2599675 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -36,7 +36,7 @@ public slots: void setBinaryDirectory(const QString& dir); void setSourceDirectory(const QString& dir); -protected slots: +protected slots: void initialize(); void doConfigure(); void doGenerate(); @@ -46,7 +46,7 @@ protected slots: void doInterrupt(); void error(const QString& message); void message(const QString& message); - + void doSourceBrowse(); void doBinaryBrowse(); void doReloadCache(); @@ -105,6 +105,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; + QStringList AddVariableCompletions; + QEventLoop LocalLoop; float ProgressOffset; @@ -118,8 +120,8 @@ class QCMakeThread : public QThread public: QCMakeThread(QObject* p); QCMake* cmakeInstance() const; - -signals: + +signals: void cmakeInitialized(); protected: diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index c1327fb..ea98326 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -65,6 +65,12 @@ bool cmConfigureFileCommand cmSystemTools::SetFatalErrorOccured(); return false; } + std::string errorMessage; + if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) + { + this->SetError(errorMessage.c_str()); + return false; + } this->CopyOnly = false; this->EscapeQuotes = false; @@ -78,6 +84,12 @@ bool cmConfigureFileCommand if(args[i] == "COPYONLY") { this->CopyOnly = true; + if (this->NewLineStyle.IsValid()) + { + this->SetError("COPYONLY could not be used in combination " + "with NEWLINE_STYLE"); + return false; + } } else if(args[i] == "ESCAPE_QUOTES") { @@ -122,7 +134,8 @@ int cmConfigureFileCommand::ConfigureFile() this->OutputFile.c_str(), this->CopyOnly, this->AtOnly, - this->EscapeQuotes); + this->EscapeQuotes, + this->NewLineStyle); } diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 844a23c..be33569 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -56,7 +56,8 @@ public: { return " configure_file(<input> <output>\n" - " [COPYONLY] [ESCAPE_QUOTES] [@ONLY])\n" + " [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n" + " [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n" "Copies a file <input> to file <output> and substitutes variable " "values referenced in the file content. " "If <input> is a relative path it is evaluated with respect to " @@ -81,14 +82,20 @@ public: "either #define VAR or /* #undef VAR */ depending on " "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake"; + "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "With NEWLINE_STYLE the line ending could be adjusted: \n" + " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" + "COPYONLY must not be used with NEWLINE_STYLE.\n"; } virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->Immediate; } + private: int ConfigureFile(); + cmNewLineStyle NewLineStyle; + std::string InputFile; std::string OutputFile; bool CopyOnly; diff --git a/Source/cmDocumentLocationUndefined.h b/Source/cmDocumentLocationUndefined.h new file mode 100644 index 0000000..d1be77a --- /dev/null +++ b/Source/cmDocumentLocationUndefined.h @@ -0,0 +1,24 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 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 cmDocumentLocationUndefined_h +#define cmDocumentLocationUndefined_h + +#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \ + "\n" \ + "Do not set properties that affect the location of a target after " \ + action ". These include properties whose names match " \ + "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \ + "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ + "Failure to follow this rule is not diagnosed and leaves the location " \ + "of the target undefined." + +#endif diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index f33e9e2..eb19d2e 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -13,6 +13,7 @@ #define cmExportCommand_h #include "cmCommand.h" +#include "cmDocumentLocationUndefined.h" class cmExportBuildFileGenerator; @@ -80,6 +81,7 @@ public: "should never be installed. " "See the install(EXPORT) command to export targets from an " "installation tree." + CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command") "\n" " export(PACKAGE <name>)\n" "Store the current build directory in the CMake user package registry " diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65d6fa6..ffbeb48 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -96,14 +96,14 @@ void cmLocalGenerator::Configure() std::string filesDir = this->Makefile->GetStartOutputDirectory(); filesDir += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(filesDir.c_str()); - + // find & read the list file this->ReadInputFile(); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories std::vector<cmLocalGenerator *> subdirs = this->GetChildren(); - + // for each subdir recurse std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) @@ -112,7 +112,7 @@ void cmLocalGenerator::Configure() { this->Makefile->ConfigureSubDirectory(*sdi); } - } + } // Check whether relative paths should be used for optionally // relative paths. @@ -212,10 +212,10 @@ void cmLocalGenerator::ReadInputFile() } void cmLocalGenerator::SetupPathConversions() -{ +{ // Setup the current output directory components for use by // Convert - std::string outdir; + std::string outdir; outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); @@ -225,12 +225,12 @@ void cmLocalGenerator::SetupPathConversions() outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetStartOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents); } @@ -289,17 +289,17 @@ void cmLocalGenerator::GenerateTestFiles() fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl - << "# Source directory: " + << "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl - << "# Build directory: " + << "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << "# " << std::endl << "# This file includes the relevent testing commands " << "required for " << std::endl << "# testing this directory and lists subdirectories to " << "be tested as well." << std::endl; - - const char* testIncludeFile = + + const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { @@ -320,7 +320,7 @@ void cmLocalGenerator::GenerateTestFiles() for(i = 0; i < this->Children.size(); ++i) { fout << "SUBDIRS("; - std::string outP = + std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); fout << this->Convert(outP.c_str(),START_OUTPUT); fout << ")" << std::endl; @@ -472,7 +472,7 @@ void cmLocalGenerator::GenerateInstallRules() // Ask each install generator to write its code. std::vector<cmInstallGenerator*> const& installers = this->Makefile->GetInstallGenerators(); - for(std::vector<cmInstallGenerator*>::const_iterator + for(std::vector<cmInstallGenerator*>::const_iterator gi = installers.begin(); gi != installers.end(); ++gi) { @@ -553,15 +553,15 @@ void cmLocalGenerator::GenerateTargetManifest() } } -void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, +void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& ) -{ +{ std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); - std::string sourceFile = + std::string sourceFile = this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; @@ -655,7 +655,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) ofname += "/"; ofname += obj; objVector.push_back(ofname); - this->AddCustomCommandToCreateObject(ofname.c_str(), + this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); objs += " "; @@ -672,7 +672,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) // Shared Module: std::string linkLibs; // should be set std::string flags; // should be set - std::string linkFlags; // should be set + std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; @@ -682,17 +682,17 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); - + std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); this->AddArchitectureFlags(langFlags, &target, llang, 0); vars.LanguageCompileFlags = langFlags.c_str(); - + cmCustomCommandLines commandLines; std::vector<std::string> rules; rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); std::vector<std::string> commands; - cmSystemTools::ExpandList(rules, commands); + cmSystemTools::ExpandList(rules, commands); for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { @@ -728,21 +728,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) (this->Makefile->GetSource(targetFullPath.c_str())); } - + void cmLocalGenerator ::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) -{ +{ cmTargets &tgts = this->Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; switch(target.GetType()) - { + { case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: + case cmTarget::EXECUTABLE: { const char* llang = target.GetLinkerLanguage(); if(!llang) @@ -759,7 +759,7 @@ void cmLocalGenerator this->AddBuildTargetRule(llang, target); } } - break; + break; default: break; } @@ -769,14 +769,14 @@ void cmLocalGenerator // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form <var> with GetSafeDefinition(var). -// ${LANG} is replaced in the variable first with all enabled +// ${LANG} is replaced in the variable first with all enabled // languages. static const char* ruleReplaceVars[] = { "CMAKE_${LANG}_COMPILER", "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS", "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS", - "CMAKE_SHARED_MODULE_${LANG}_FLAGS", + "CMAKE_SHARED_MODULE_${LANG}_FLAGS", "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS", "CMAKE_${LANG}_LINK_FLAGS", "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG", @@ -807,7 +807,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.Flags; } } - + if(replaceValues.Source) { if(variable == "SOURCE") @@ -870,7 +870,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(replaceValues.Target) - { + { if(variable == "TARGET_QUOTED") { std::string targetQuoted = replaceValues.Target; @@ -1018,13 +1018,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, int pos = 0; while(ruleReplaceVars[pos]) { - for(std::vector<std::string>::iterator i = enabledLanguages.begin(); - i != enabledLanguages.end(); ++i) - { + for(std::vector<std::string>::iterator i = enabledLanguages.begin(); + i != enabledLanguages.end(); ++i) + { const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable - // _COMPILER_ARG1 which must be the first argument to the compiler + // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { @@ -1038,7 +1038,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(actualReplace == variable) { - std::string replace = + std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) @@ -1062,7 +1062,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } -void +void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { @@ -1213,7 +1213,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; - const char* includeFlag = + const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; @@ -1223,7 +1223,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, { quotePaths = true; } - bool repeatFlag = true; + bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB if(!sep) { @@ -1354,15 +1354,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, this->Makefile->GetDefinition("VTK_SOURCE_DIR"); if(vtkSourceDir) { - const char* vtk_major = + const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = + const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); vtk_major = vtk_major? vtk_major : "4"; vtk_minor = vtk_minor? vtk_minor : "4"; int vmajor = 0; int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && + if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) { includeSourceDir = true; @@ -1403,7 +1403,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } // Get the project-specified include directories. - std::vector<std::string>& includes = + std::vector<std::string>& includes = this->Makefile->GetIncludeDirectories(); // Support putting all the in-project include directories first if @@ -1446,17 +1446,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& linkFlags, cmTarget& target) { - std::string buildType = + std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - const char* libraryLinkVariable = + buildType = cmSystemTools::UpperCase(buildType); + const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library - + switch(target.GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmTarget::STATIC_LIBRARY: { - const char* targetLinkFlags = + const char* targetLinkFlags = target.GetProperty("STATIC_LIBRARY_FLAGS"); if(targetLinkFlags) { @@ -1475,11 +1475,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } } - break; + break; case cmTarget::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; case cmTarget::SHARED_LIBRARY: - { + { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; if(!buildType.empty()) @@ -1489,8 +1489,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } - if(this->Makefile->IsOn("WIN32") && + } + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { const std::vector<cmSourceFile*>& sources = target.GetSourceFiles(); @@ -1500,14 +1500,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, cmSourceFile* sf = *i; if(sf->GetExtension() == "def") { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert(sf->GetFullPath().c_str(), START_OUTPUT, SHELL); linkFlags += " "; } } - } + } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { @@ -1520,11 +1520,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } - } + } cmOStringStream linklibsStr; this->OutputLinkLibraries(linklibsStr, target, false); linkLibs = linklibsStr.str(); @@ -1532,7 +1532,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, break; case cmTarget::EXECUTABLE: { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if(!buildType.empty()) @@ -1541,7 +1541,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } + } const char* linkLanguage = target.GetLinkerLanguage(); if(!linkLanguage) { @@ -1566,7 +1566,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; @@ -1579,7 +1579,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } else { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } @@ -1595,13 +1595,13 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } } } - break; + break; default: break; } @@ -1661,9 +1661,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, const char* linkLanguage = cli.GetLinkLanguage(); - std::string libPathFlag = + std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = + std::string libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. @@ -1786,11 +1786,11 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, { std::vector<std::string> archs; target->GetAppleArchs(config, archs); - const char* sysroot = + const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); @@ -1876,7 +1876,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, if(cmSystemTools::FileIsFullPath(inName)) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && + if(target->GetType() >= cmTarget::EXECUTABLE && target->GetType() <= cmTarget::MODULE_LIBRARY) { tLocation = target->GetLocation(config); @@ -2904,7 +2904,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, else { cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); - } + } return std::string(&arg[0]); } @@ -2976,9 +2976,9 @@ cmLocalGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- -void +void cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* , - std::vector<std::string>& + std::vector<std::string>& ) { cmSystemTools::Error("GetTargetObjectFileDirectories" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 573c430..7939d73 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3213,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input, } int cmMakefile::ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes) + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& newLine) { int res = 1; if ( !this->CanIWriteThisFile(outfile) ) @@ -3250,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } else { + std::string newLineCharacters; + std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + if (newLine.IsValid()) + { + newLineCharacters = newLine.GetCharacters(); + omode |= std::ios::binary; + } + else + { + newLineCharacters = "\n"; + } std::string tempOutputFile = soutfile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str()); + std::ofstream fout(tempOutputFile.c_str(), omode); if(!fout) { cmSystemTools::Error( @@ -3277,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, { outLine = ""; this->ConfigureString(inLine, outLine, atOnly, escapeQuotes); - fout << outLine.c_str() << "\n"; + fout << outLine.c_str() << newLineCharacters; } // close the files before attempting to copy fin.close(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7c3e4ee..1236787 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -19,6 +19,7 @@ #include "cmPropertyMap.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmNewLineStyle.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -703,7 +704,9 @@ public: * Copy file but change lines acording to ConfigureString */ int ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes); + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& = cmNewLineStyle()); + #if defined(CMAKE_BUILD_WITH_CMAKE) /** diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx new file mode 100644 index 0000000..6f7b6a9 --- /dev/null +++ b/Source/cmNewLineStyle.cxx @@ -0,0 +1,95 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 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 "cmNewLineStyle.h" + + + +cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid) +{ +} + + +bool cmNewLineStyle::IsValid() const +{ + return NewLineStyle != Invalid; +} + + +bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args, + std::string& errorString) +{ + NewLineStyle = Invalid; + + for (size_t i = 0; i< args.size(); i++) + { + if (args[i] == "NEWLINE_STYLE") + { + size_t const styleIndex = i + 1; + if (args.size() > styleIndex) + { + const std::string eol = args[styleIndex]; + if (eol == "LF" || eol == "UNIX") + { + NewLineStyle = LF; + return true; + } + else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") + { + NewLineStyle = CRLF; + return true; + } + else + { + errorString = "NEWLINE_STYLE sets an unknown style, only LF, " + "CRLF, UNIX, DOS, and WIN32 are supported"; + return false; + } + } + else + { + errorString = "NEWLINE_STYLE must set a style: " + "LF, CRLF, UNIX, DOS, or WIN32"; + return false; + } + } + } + return true; +} + + +const std::string cmNewLineStyle::GetCharacters() const +{ + switch (NewLineStyle) + { + case Invalid: + return ""; + case LF: + return "\n"; + case CRLF: + return "\r\n"; + default: + ; + }; + return ""; +} + + +void cmNewLineStyle::SetStyle(Style style) +{ + NewLineStyle = style; +} + + +cmNewLineStyle::Style cmNewLineStyle::GetStyle() const +{ + return NewLineStyle; +} diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h new file mode 100644 index 0000000..cae1106 --- /dev/null +++ b/Source/cmNewLineStyle.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 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 cmNewLineStyle_h +#define cmNewLineStyle_h + +#include "cmStandardIncludes.h" + +class cmNewLineStyle +{ +public: + + cmNewLineStyle(); + + enum Style + { + Invalid, + // LF = '\n', 0x0A, 10 + // CR = '\r', 0x0D, 13 + LF, // Unix + CRLF // Dos + }; + + void SetStyle(Style); + Style GetStyle() const; + + bool IsValid() const; + + bool ReadFromArguments(const std::vector<std::string>& args, + std::string &errorString); + + const std::string GetCharacters() const; + +private: + Style NewLineStyle; +}; + +#endif diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7a80f28..d07f84b 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -49,11 +49,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4 or Qt5SrcTools (which contains moc): + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { - qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); } if (qtMajorVersion != "4" && qtMajorVersion != "5") { @@ -229,7 +229,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, if (this->QtMajorVersion == "") { this->QtMajorVersion = makefile->GetSafeDefinition( - "AM_Qt5SrcTools_VERSION_MAJOR"); + "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index e8decbb..ea299ca 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -161,6 +161,11 @@ extern int putenv (char *__string) __THROW; #define for if(false) {} else for #endif +// Provide std::ios_base on ancient GCC 2.9x +#if defined(__GNUC__) && __GNUC__ < 3 +namespace std { typedef ios ios_base; } +#endif + // check for the 720 compiler on the SGI // which has some strange properties that I don't think are worth // checking for in a general way in configure diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 48368de..87f8c5e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -17,6 +17,7 @@ #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" #include "cmDocumentCompileDefinitions.h" +#include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include <cmsys/RegularExpression.hxx> @@ -584,15 +585,6 @@ void cmTarget::DefineProperties(cmake *cm) "value is the default. " "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables."); -#define CM_LOCATION_UNDEFINED_BEHAVIOR \ - "\n" \ - "Do not set properties that affect the location of the target after " \ - "reading this property. These include properties whose names match " \ - "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \ - "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ - "Failure to follow this rule is not diagnosed and leaves the location " \ - "of the target undefined." - cm->DefineProperty ("LOCATION", cmProperty::TARGET, "Read-only location of a target on disk.", @@ -612,7 +604,7 @@ void cmTarget::DefineProperties(cmake *cm) "In CMake 2.8.4 and above add_custom_command recognizes generator " "expressions to refer to target locations anywhere in the command. " "Therefore this property is not needed for creating custom commands." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LOCATION_<CONFIG>", cmProperty::TARGET, @@ -626,7 +618,7 @@ void cmTarget::DefineProperties(cmake *cm) "arbitrary available configuration. " "Use the MAP_IMPORTED_CONFIG_<CONFIG> property to map imported " "configurations explicitly." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LINK_DEPENDS", cmProperty::TARGET, @@ -1055,6 +1047,29 @@ void cmTarget::DefineProperties(cmake *cm) "Can be set to change the visual studio source code control " "auxpath property."); cm->DefineProperty + ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET, + "Visual Studio project type(s).", + "Can be set to one or more UUIDs recognized by Visual Studio " + "to indicate the type of project. This value is copied " + "verbatim into the generated project file. Example for a " + "managed C++ unit testing project: \"" + "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};" + "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\". UUIDs are " + "semicolon-delimited."); + cm->DefineProperty + ("VS_GLOBAL_KEYWORD", cmProperty::TARGET, + "Visual Studio project keyword.", + "Sets the \"keyword\" attribute for a generated Visual Studio " + "project. Defaults to \"Win32Proj\". You may wish to override " + "this value with \"ManagedCProj\", for example, in a Visual " + "Studio managed C++ unit test project."); + cm->DefineProperty + ("VS_DOTNET_REFERENCES", cmProperty::TARGET, + "Visual Studio managed project .NET references", + "Adds one or more semicolon-delimited .NET references to a " + "generated Visual Studio project. For example, \"System;" + "System.Windows.Forms\"."); + cm->DefineProperty ("VS_GLOBAL_<variable>", cmProperty::TARGET, "Visual Studio project-specific global variable.", "Tell the Visual Studio generator to set the global variable " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index fcb668a..a219ae9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -178,6 +178,15 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<ProjectGUID>", 2); (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n"; + const char* vsProjectTypes = + this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + if(vsProjectTypes) + { + this->WriteString("<ProjectTypes>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) << + "</ProjectTypes>\n"; + } + const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); @@ -203,7 +212,19 @@ void cmVisualStudio10TargetGenerator::Generate() } } - this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); + const char* vsGlobalKeyword = + this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + if(!vsGlobalKeyword) + { + this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); + } + else + { + this->WriteString("<Keyword>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) << + "</Keyword>\n"; + } + this->WriteString("<Platform>", 2); (*this->BuildFileStream) << this->Platform << "</Platform>\n"; const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); @@ -233,6 +254,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(); this->WriteObjSources(); this->WriteCLSources(); + this->WriteDotNetReferences(); this->WriteProjectReferences(); this->WriteString( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"" @@ -244,6 +266,39 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteGroups(); } +void cmVisualStudio10TargetGenerator::WriteDotNetReferences() +{ + const char* vsDotNetReferences + = this->Target->GetProperty("VS_DOTNET_REFERENCES"); + if(vsDotNetReferences) + { + std::string references(vsDotNetReferences); + std::string::size_type position = 0; + + this->WriteString("<ItemGroup>\n", 1); + while(references.length() > 0) + { + if((position = references.find(";")) == std::string::npos) + { + position = references.length() + 1; + } + + this->WriteString("<Reference Include=\"", 2); + (*this->BuildFileStream) << + cmVS10EscapeXML(references.substr(0, position)) << "\">\n"; + this->WriteString("<CopyLocalSatelliteAssemblies>true" + "</CopyLocalSatelliteAssemblies>\n", 3); + this->WriteString("<ReferenceOutputAssembly>true" + "</ReferenceOutputAssembly>\n", 3); + this->WriteString("</Reference>\n", 2); + + references.erase(0, position + 1); + } + + this->WriteString("</ItemGroup>\n", 1); + } +} + // ConfigurationType Application, Utility StaticLibrary DynamicLibrary void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c3c27f4..6702509 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -47,6 +47,7 @@ private: void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); void WriteCLSources(); + void WriteDotNetReferences(); void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 082aaba..280d3f3 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 11) +SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 06) |