summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt3
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx2
-rw-r--r--Source/QtDialog/AddCacheEntry.cxx12
-rw-r--r--Source/QtDialog/AddCacheEntry.h3
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx27
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h10
-rw-r--r--Source/QtDialog/README3
-rw-r--r--Source/cmCTest.cxx8
-rw-r--r--Source/cmComputeLinkDepends.cxx3
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmConfigureFileCommand.cxx15
-rw-r--r--Source/cmConfigureFileCommand.h11
-rw-r--r--Source/cmDocumentLocationUndefined.h24
-rw-r--r--Source/cmDocumentVariables.cxx14
-rw-r--r--Source/cmExportCommand.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx3
-rw-r--r--Source/cmLocalGenerator.cxx146
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx10
-rw-r--r--Source/cmMakefile.cxx18
-rw-r--r--Source/cmMakefile.h5
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx14
-rw-r--r--Source/cmNewLineStyle.cxx95
-rw-r--r--Source/cmNewLineStyle.h46
-rw-r--r--Source/cmQtAutomoc.cxx401
-rw-r--r--Source/cmQtAutomoc.h12
-rw-r--r--Source/cmStandardIncludes.h5
-rw-r--r--Source/cmTarget.cxx113
-rw-r--r--Source/cmTarget.h7
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx57
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h1
-rw-r--r--Source/kwsys/SystemTools.cxx2
-rw-r--r--Source/kwsys/kwsysDateStamp.cmake4
32 files changed, 849 insertions, 231 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/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 86bd85d..34a3e60 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -57,7 +57,7 @@ static const char* cmCTestErrorMatches[] = {
"^ild:([ \\t])*\\(undefined symbol\\)",
"([^ :]+) : (error|fatal error|catastrophic error)",
"([^:]+): (Error:|error|undefined reference|multiply defined)",
- "([^:]+)\\(([^\\)]+)\\) : (error|fatal error|catastrophic error)",
+ "([^:]+)\\(([^\\)]+)\\) ?: (error|fatal error|catastrophic error)",
"^fatal error C[0-9]+:",
": syntax error ",
"^collect2: ld returned 1 exit status",
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..338eaff 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -26,6 +26,7 @@
#include <QMimeData>
#include <QUrl>
#include <QShortcut>
+#include <QKeySequence>
#include <QMacInstallDialog.h>
#include "QCMake.h"
@@ -68,6 +69,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);
@@ -96,6 +100,7 @@ CMakeSetupDialog::CMakeSetupDialog()
QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)),
this, SLOT(doDeleteCache()));
this->ExitAction = FileMenu->addAction(tr("E&xit"));
+ this->ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
QObject::connect(this->ExitAction, SIGNAL(triggered(bool)),
this, SLOT(close()));
@@ -1008,7 +1013,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 +1026,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/QtDialog/README b/Source/QtDialog/README
deleted file mode 100644
index 0701a2b..0000000
--- a/Source/QtDialog/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This is the Qt interface to CMake. It has a BSD license compatible with the
-Qt license exception. Only developers with a paid QT license are permitted
-to make changes to this code. Small patches and bug fixes can
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 14055a4..3f7fdc7 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -440,8 +440,12 @@ std::string cmCTest::GetCDashVersion()
std::string cdashUri = this->GetCTestConfiguration("DropLocation");
cdashUri = cdashUri.substr(0, cdashUri.find("/submit.php"));
- url += cdashUri + "/api/getversion.php";
- int res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3);
+ int res = 1;
+ if ( ! cdashUri.empty() )
+ {
+ url += cdashUri + "/api/getversion.php";
+ res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3);
+ }
return res ? this->GetCTestConfiguration("CDashVersion") : response;
#else
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 1021bf2..802cfcf 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -429,7 +429,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
if(cmTarget::LinkInterface const* iface =
entry.Target->GetLinkInterface(this->Config))
{
- // We use just the shared dependencies, not the interface.
+ // Follow public and private dependencies transitively.
+ this->QueueSharedDependencies(index, iface->Libraries);
this->QueueSharedDependencies(index, iface->SharedDeps);
}
}
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index f8ab686..edf6c35 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -161,7 +161,9 @@ listed on the command line.
- On Windows, DLLs are not directly linked, and the import libraries
have no transitive dependencies.
- - On Mac, we need to actually list the transitive dependencies.
+ - On Mac OS X 10.5 and above transitive dependencies are not needed.
+
+ - On Mac OS X 10.4 and below we need to actually list the dependencies.
Otherwise when using -isysroot for universal binaries it cannot
find the dependent libraries. Listing them on the command line
tells the linker where to find them, but unfortunately also links
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/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index c8c83b9..a0632a2 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -508,6 +508,20 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Variables That Change Behavior");
cm->DefineProperty
+ ("CMAKE_AUTOMOC_STRICT_MODE", cmProperty::VARIABLE,
+ "Switch between strict and relaxed automoc mode.",
+ "When TRUE, automoc behaves exactly as described in the documentation "
+ "of the AUTOMOC target property. "
+ "When set to FALSE, it accepts more input and tries to find the correct "
+ "input file for moc even if it differs from the documented behaviour. "
+ "In this mode it e.g. also checks whether a header file is intended to "
+ "be processed by moc when a \"foo.moc\" file has been included.\n"
+ "When using Qt4, CMAKE_AUTOMOC_STRICT_MODE is initialized to FALSE. "
+ "It also has to be set to FALSE for KDE4 compatibility.",
+ false,
+ "Variables That Change Behavior");
+
+ cm->DefineProperty
("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE,
"Prefixes to prepend when looking for libraries.",
"This specifies what prefixes to add to library names when "
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/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 32eaef8..859503f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -458,8 +458,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
std::vector<std::string>::iterator new_end =
std::unique(lfiles.begin(), lfiles.end());
lfiles.erase(new_end, lfiles.end());
- std::string dir = mf->GetHomeOutputDirectory();
- this->CurrentReRunCMakeMakefile = dir;
+ this->CurrentReRunCMakeMakefile = mf->GetStartOutputDirectory();
this->CurrentReRunCMakeMakefile += "/CMakeScripts";
cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str());
this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
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/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 8185b95..11a0387 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -223,6 +223,14 @@ void cmLocalVisualStudio7Generator
this->FortranProject =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetIsFortranOnly(target);
+
+ // Intel Fortran for VS10 uses VS9 format ".vfproj" files.
+ VSVersion realVersion = this->Version;
+ if(this->FortranProject && this->Version >= VS10)
+ {
+ this->Version = VS9;
+ }
+
// add to the list of projects
std::string pname = lname;
target.SetProperty("GENERATOR_FILE_NAME",lname);
@@ -250,6 +258,8 @@ void cmLocalVisualStudio7Generator
{
this->GlobalGenerator->FileReplacedDuringGenerate(fname);
}
+
+ this->Version = realVersion;
}
//----------------------------------------------------------------------------
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/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index f52f7ab..a82c503 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -34,6 +34,20 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
*this->BuildFileStream
<< "# Utility rule file for " << this->Target->GetName() << ".\n\n";
+ if(!this->NoRuleMessages)
+ {
+ const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")?
+ "$(CMAKE_BINARY_DIR)/" : "");
+ // Include the progress variables for the target.
+ *this->BuildFileStream
+ << "# Include the progress variables for this target.\n"
+ << this->LocalGenerator->IncludeDirective << " " << root
+ << this->Convert(this->ProgressFileNameFull.c_str(),
+ cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKEFILE)
+ << "\n\n";
+ }
+
// write the custom commands for this target
this->WriteTargetBuildRules();
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..65c7952 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -17,11 +17,70 @@
#include "cmSourceFile.h"
#include "cmSystemTools.h"
-# include <cmsys/Terminal.h>
+#include <cmsys/Terminal.h>
+
+#include <string.h>
#include "cmQtAutomoc.h"
+static bool containsQ_OBJECT(const std::string& text)
+{
+ // this simple check is much much faster than the regexp
+ if (strstr(text.c_str(), "Q_OBJECT") == NULL)
+ {
+ return false;
+ }
+
+ cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+ return qObjectRegExp.find(text);
+}
+
+
+static std::string findMatchingHeader(const std::string& absPath,
+ const std::string& mocSubDir,
+ const std::string& basename,
+ const std::list<std::string>& headerExtensions)
+{
+ std::string header;
+ for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
+ ext != headerExtensions.end();
+ ++ext)
+ {
+ std::string sourceFilePath = absPath + basename + (*ext);
+ if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+ {
+ header = sourceFilePath;
+ break;
+ }
+ if (!mocSubDir.empty())
+ {
+ sourceFilePath = mocSubDir + basename + (*ext);
+ if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+ {
+ header = sourceFilePath;
+ break;
+ }
+ }
+ }
+
+ return header;
+}
+
+
+static std::string extractSubDir(const std::string& absPath,
+ const std::string& currentMoc)
+{
+ std::string subDir;
+ if (currentMoc.find_first_of('/') != std::string::npos)
+ {
+ subDir = absPath
+ + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+ }
+ return subDir;
+}
+
+
cmQtAutomoc::cmQtAutomoc()
:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
,ColorOutput(true)
@@ -49,17 +108,23 @@ 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")
{
return;
}
+ bool strictMode = (qtMajorVersion == "5");
+ if (makefile->IsDefinitionSet("CMAKE_AUTOMOC_STRICT_MODE"))
+ {
+ strictMode = makefile->IsOn("CMAKE_AUTOMOC_STRICT_MODE");
+ }
+
// create a custom target for running automoc at buildtime:
std::string automocTargetName = targetName;
automocTargetName += "_automoc";
@@ -148,6 +213,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
makefile->AddDefinition("_moc_options", _moc_options.c_str());
makefile->AddDefinition("_moc_files", _moc_files.c_str());
makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
+ makefile->AddDefinition("_moc_strict_mode", strictMode ? "TRUE" : "FALSE");
const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
std::string inputFile = cmakeRoot;
@@ -229,7 +295,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");
@@ -247,6 +313,8 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
+ this->StrictMode = makefile->IsOn("AM_STRICT_MODE");
+
return true;
}
@@ -415,6 +483,23 @@ bool cmQtAutomoc::RunAutomoc()
std::vector<std::string> sourceFiles;
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
+ std::list<std::string> headerExtensions;
+ headerExtensions.push_back(".h");
+ headerExtensions.push_back(".hpp");
+ headerExtensions.push_back(".hxx");
+#if defined(_WIN32)
+ // not case sensitive, don't add ".H"
+#elif defined(__APPLE__)
+ // detect case-sensitive filesystem
+ long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
+ if (caseSensitive == 1)
+ {
+ headerExtensions.push_back(".H");
+ }
+#else
+ headerExtensions.push_back(".H");
+#endif
+
for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
it != sourceFiles.end();
++it)
@@ -424,7 +509,15 @@ bool cmQtAutomoc::RunAutomoc()
{
std::cout << "AUTOMOC: Checking " << absFilename << std::endl;
}
- this->ParseCppFile(absFilename, includedMocs, headerFiles);
+ if (this->StrictMode == false)
+ {
+ this->ParseCppFile(absFilename, headerExtensions, includedMocs);
+ }
+ else
+ {
+ this->StrictParseCppFile(absFilename, headerExtensions, includedMocs);
+ }
+ this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
}
std::vector<std::string> headerFilesVec;
@@ -505,40 +598,37 @@ bool cmQtAutomoc::RunAutomoc()
void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
- std::map<std::string, std::string>& includedMocs,
- std::set<std::string>& absHeaders)
+ const std::list<std::string>& headerExtensions,
+ std::map<std::string, std::string>& includedMocs)
{
cmsys::RegularExpression mocIncludeRegExp(
"[\n][ \t]*#[ \t]*include[ \t]+"
"[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
- std::list<std::string> headerExtensions;
- headerExtensions.push_back(".h");
- headerExtensions.push_back(".hpp");
- headerExtensions.push_back(".hxx");
-#if defined(_WIN32)
- // not case sensitive, don't add ".H"
-#elif defined(__APPLE__)
- // detect case-sensitive filesystem
- long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
- if (caseSensitive == 1)
- {
- headerExtensions.push_back(".H");
- }
-#else
- headerExtensions.push_back(".H");
-#endif
const std::string contentsString = this->ReadAll(absFilename);
if (contentsString.empty())
{
- std::cerr << "AUTOMOC: empty source file: " << absFilename << std::endl;
+ std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n"
+ << std::endl;
return;
}
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ const std::string scannedFileBasename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFilename);
+ const bool cppContainsQ_OBJECT = containsQ_OBJECT(contentsString);
+ bool dotMocIncluded = false;
+ bool mocUnderscoreIncluded = false;
+ std::string ownMocUnderscoreFile;
+ std::string ownDotMocFile;
+ std::string ownMocHeaderFile;
std::string::size_type matchOffset = 0;
- if (mocIncludeRegExp.find(contentsString.c_str()))
+ // first a simply string check for "moc" is *much* faster than the regexp,
+ // and if the string search already fails, we don't have to try the
+ // expensive regexp
+ if ((strstr(contentsString.c_str(), "moc") != NULL)
+ && (mocIncludeRegExp.find(contentsString)))
{
// for every moc include in the file
do
@@ -561,78 +651,248 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
// basename should be the part of the moc filename used for
// finding the correct header, so we need to remove the moc_ part
basename = basename.substr(4);
+ std::string mocSubDir = extractSubDir(absPath, currentMoc);
+ std::string headerToMoc = findMatchingHeader(
+ absPath, mocSubDir, basename, headerExtensions);
- bool headerFound = false;
- for(std::list<std::string>::const_iterator ext =
- headerExtensions.begin();
- ext != headerExtensions.end();
- ++ext)
+ if (!headerToMoc.empty())
+ {
+ includedMocs[headerToMoc] = currentMoc;
+ if (basename == scannedFileBasename)
+ {
+ mocUnderscoreIncluded = true;
+ ownMocUnderscoreFile = currentMoc;
+ ownMocHeaderFile = headerToMoc;
+ }
+ }
+ else
{
- const std::string &sourceFilePath = absPath + basename + (*ext);
- if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+ std::cerr << "AUTOMOC: error: " << absFilename << " The file "
+ << "includes the moc file \"" << currentMoc << "\", "
+ << "but could not find header \"" << basename
+ << '{' << this->Join(headerExtensions, ',') << "}\" ";
+ if (mocSubDir.empty())
+ {
+ std::cerr << "in " << absPath << "\n" << std::endl;
+ }
+ else
{
- headerFound = true;
- includedMocs[sourceFilePath] = currentMoc;
- break;
+ std::cerr << "neither in " << absPath
+ << " nor in " << mocSubDir << "\n" << std::endl;
}
+
+ ::exit(EXIT_FAILURE);
}
- if (!headerFound)
+ }
+ else
+ {
+ std::string fileToMoc = absFilename;
+ if ((basename != scannedFileBasename) || (cppContainsQ_OBJECT==false))
{
- // the moc file is in a subdir => look for the header in the
- // same subdir
- if (currentMoc.find_first_of('/') != std::string::npos)
+ std::string mocSubDir = extractSubDir(absPath, currentMoc);
+ std::string headerToMoc = findMatchingHeader(
+ absPath, mocSubDir, basename, headerExtensions);
+ if (!headerToMoc.empty())
{
- const std::string &filepath = absPath
- + cmsys::SystemTools::GetFilenamePath(currentMoc)
- + '/' + basename;
-
- for(std::list<std::string>::const_iterator ext =
- headerExtensions.begin();
- ext != headerExtensions.end();
- ++ext)
+ // this is for KDE4 compatibility:
+ fileToMoc = headerToMoc;
+ if ((cppContainsQ_OBJECT==false) &&(basename==scannedFileBasename))
{
- const std::string &sourceFilePath = filepath + (*ext);
- if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
- {
- headerFound = true;
- includedMocs[sourceFilePath] = currentMoc;
- break;
- }
+ std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+ "includes the moc file \"" << currentMoc <<
+ "\", but does not contain a Q_OBJECT macro. "
+ "Running moc on "
+ << "\"" << headerToMoc << "\" ! Better include \"moc_"
+ << basename << ".cpp\" for a robust build.\n"
+ << std::endl;
}
- if (!headerFound)
+ else
{
- std::cerr << "AUTOMOC: The file \"" << absFilename
- << "\" includes the moc file \"" << currentMoc
- << "\", but neither \"" << absPath << basename
- << '{' << this->Join(headerExtensions, ',')
- << "}\" nor \"" << filepath << '{'
- << this->Join(headerExtensions, ',') << '}'
- << "\" exist." << std::endl;
- ::exit(EXIT_FAILURE);
+ std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+ "includes the moc file \"" << currentMoc <<
+ "\" instead of \"moc_" << basename << ".cpp\". "
+ "Running moc on "
+ << "\"" << headerToMoc << "\" ! Better include \"moc_"
+ << basename << ".cpp\" for a robust build.\n"
+ << std::endl;
}
}
else
{
- std::cerr << "AUTOMOC: The file \"" << absFilename
- << "\" includes the moc file \"" << currentMoc
- << "\", but \"" << absPath << basename << '{'
- << this->Join(headerExtensions, ',') << '}'
- << "\" does not exist." << std::endl;
+ std::cerr <<"AUTOMOC: error: " << absFilename << ": The file "
+ "includes the moc file \"" << currentMoc <<
+ "\", which seems to be the moc file from a different "
+ "source file. CMake also could not find a matching "
+ "header.\n" << std::endl;
::exit(EXIT_FAILURE);
}
}
+ else
+ {
+ dotMocIncluded = true;
+ ownDotMocFile = currentMoc;
+ }
+ includedMocs[fileToMoc] = currentMoc;
+ }
+ matchOffset += mocIncludeRegExp.end();
+ } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
+ }
+
+ // In this case, check whether the scanned file itself contains a Q_OBJECT.
+ // If this is the case, the moc_foo.cpp should probably be generated from
+ // foo.cpp instead of foo.h, because otherwise it won't build.
+ // But warn, since this is not how it is supposed to be used.
+ if ((dotMocIncluded == false) && (cppContainsQ_OBJECT == true))
+ {
+ if (mocUnderscoreIncluded == true)
+ {
+ // this is for KDE4 compatibility:
+ std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+ << "contains a Q_OBJECT macro, but does not include "
+ << "\"" << scannedFileBasename << ".moc\", but instead "
+ "includes "
+ << "\"" << ownMocUnderscoreFile << "\". Running moc on "
+ << "\"" << absFilename << "\" ! Better include \""
+ << scannedFileBasename << ".moc\" for a robust build.\n"
+ << std::endl;
+ includedMocs[absFilename] = ownMocUnderscoreFile;
+ includedMocs.erase(ownMocHeaderFile);
+ }
+ else
+ {
+ // otherwise always error out since it will not compile:
+ std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
+ << "contains a Q_OBJECT macro, but does not include "
+ << "\"" << scannedFileBasename << ".moc\" !\n"
+ << std::endl;
+ ::exit(EXIT_FAILURE);
+ }
+ }
+
+}
+
+
+void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename,
+ const std::list<std::string>& headerExtensions,
+ std::map<std::string, std::string>& includedMocs)
+{
+ cmsys::RegularExpression mocIncludeRegExp(
+ "[\n][ \t]*#[ \t]*include[ \t]+"
+ "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
+
+ const std::string contentsString = this->ReadAll(absFilename);
+ if (contentsString.empty())
+ {
+ std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n"
+ << std::endl;
+ return;
+ }
+ const std::string absPath = cmsys::SystemTools::GetFilenamePath(
+ cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ const std::string scannedFileBasename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFilename);
+
+ bool dotMocIncluded = false;
+
+ std::string::size_type matchOffset = 0;
+ // first a simply string check for "moc" is *much* faster than the regexp,
+ // and if the string search already fails, we don't have to try the
+ // expensive regexp
+ if ((strstr(contentsString.c_str(), "moc") != NULL)
+ && (mocIncludeRegExp.find(contentsString)))
+ {
+ // for every moc include in the file
+ do
+ {
+ const std::string currentMoc = mocIncludeRegExp.match(1);
+
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(currentMoc);
+ const bool mocUnderscoreStyle = this->StartsWith(basename, "moc_");
+
+ // If the moc include is of the moc_foo.cpp style we expect
+ // the Q_OBJECT class declaration in a header file.
+ // If the moc include is of the foo.moc style we need to look for
+ // a Q_OBJECT macro in the current source file, if it contains the
+ // macro we generate the moc file from the source file.
+ if (mocUnderscoreStyle)
+ {
+ // basename should be the part of the moc filename used for
+ // finding the correct header, so we need to remove the moc_ part
+ basename = basename.substr(4);
+ std::string mocSubDir = extractSubDir(absPath, currentMoc);
+ std::string headerToMoc = findMatchingHeader(
+ absPath, mocSubDir, basename, headerExtensions);
+
+ if (!headerToMoc.empty())
+ {
+ includedMocs[headerToMoc] = currentMoc;
+ }
+ else
+ {
+ std::cerr << "AUTOMOC: error: " << absFilename << " The file "
+ << "includes the moc file \"" << currentMoc << "\", "
+ << "but could not find header \"" << basename
+ << '{' << this->Join(headerExtensions, ',') << "}\" ";
+ if (mocSubDir.empty())
+ {
+ std::cerr << "in " << absPath << "\n" << std::endl;
+ }
+ else
+ {
+ std::cerr << "neither in " << absPath
+ << " nor in " << mocSubDir << "\n" << std::endl;
+ }
+
+ ::exit(EXIT_FAILURE);
+ }
}
else
{
+ if (basename != scannedFileBasename)
+ {
+ std::cerr <<"AUTOMOC: error: " << absFilename << ": The file "
+ "includes the moc file \"" << currentMoc <<
+ "\", which seems to be the moc file from a different "
+ "source file. This is not supported. "
+ "Include \"" << scannedFileBasename << ".moc\" to run "
+ "moc on this source file.\n" << std::endl;
+ ::exit(EXIT_FAILURE);
+ }
+ dotMocIncluded = true;
includedMocs[absFilename] = currentMoc;
}
matchOffset += mocIncludeRegExp.end();
} while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
}
+ // In this case, check whether the scanned file itself contains a Q_OBJECT.
+ // If this is the case, the moc_foo.cpp should probably be generated from
+ // foo.cpp instead of foo.h, because otherwise it won't build.
+ // But warn, since this is not how it is supposed to be used.
+ if ((dotMocIncluded == false) && (containsQ_OBJECT(contentsString)))
+ {
+ // otherwise always error out since it will not compile:
+ std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
+ << "contains a Q_OBJECT macro, but does not include "
+ << "\"" << scannedFileBasename << ".moc\" !\n"
+ << std::endl;
+ ::exit(EXIT_FAILURE);
+ }
+
+}
+
+
+void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
+ const std::list<std::string>& headerExtensions,
+ std::set<std::string>& absHeaders)
+{
// search for header files and private header files we may need to moc:
const std::string basename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
+ const std::string absPath = cmsys::SystemTools::GetFilenamePath(
+ cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+
for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
ext != headerExtensions.end();
++ext)
@@ -663,7 +923,6 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders,
const std::map<std::string, std::string>& includedMocs,
std::map<std::string, std::string>& notIncludedMocs)
{
- cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
for(std::set<std::string>::const_iterator hIt=absHeaders.begin();
hIt!=absHeaders.end();
++hIt)
@@ -682,7 +941,7 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders,
const std::string currentMoc = "moc_" + basename + ".cpp";
const std::string contents = this->ReadAll(headerName);
- if (qObjectRegExp.find(contents))
+ if (containsQ_OBJECT(contents))
{
//std::cout << "header contains Q_OBJECT macro";
notIncludedMocs[headerName] = currentMoc;
@@ -759,7 +1018,7 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
if (!result || retVal)
{
- std::cerr << "AUTOMOC: process for " << mocFilePath << " failed:\n"
+ std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n"
<< output << std::endl;
this->RunMocFailed = true;
cmSystemTools::RemoveFile(mocFilePath.c_str());
diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h
index f6355de..a31f36a 100644
--- a/Source/cmQtAutomoc.h
+++ b/Source/cmQtAutomoc.h
@@ -39,8 +39,15 @@ private:
bool GenerateMoc(const std::string& sourceFile,
const std::string& mocFileName);
void ParseCppFile(const std::string& absFilename,
- std::map<std::string, std::string>& includedMocs,
- std::set<std::string>& absHeaders);
+ const std::list<std::string>& headerExtensions,
+ std::map<std::string, std::string>& includedMocs);
+ void StrictParseCppFile(const std::string& absFilename,
+ const std::list<std::string>& headerExtensions,
+ std::map<std::string, std::string>& includedMocs);
+ void SearchHeadersForCppFile(const std::string& absFilename,
+ const std::list<std::string>& headerExtensions,
+ std::set<std::string>& absHeaders);
+
void ParseHeaders(const std::set<std::string>& absHeaders,
const std::map<std::string, std::string>& includedMocs,
std::map<std::string, std::string>& notIncludedMocs);
@@ -78,6 +85,7 @@ private:
bool ColorOutput;
bool RunMocFailed;
bool GenerateAll;
+ bool StrictMode;
};
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..fc3c1c9 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>
@@ -131,6 +132,7 @@ cmTarget::cmTarget()
this->LinkLibrariesAnalyzed = false;
this->HaveInstallRule = false;
this->DLLPlatform = false;
+ this->IsApple = false;
this->IsImportedTarget = false;
}
@@ -159,8 +161,10 @@ void cmTarget::DefineProperties(cmake *cm)
"This property is initialized by the value of the variable "
"CMAKE_AUTOMOC if it is set when a target is created.\n"
"Additional command line options for moc can be set via the "
- "AUTOMOC_MOC_OPTIONS property."
- );
+ "AUTOMOC_MOC_OPTIONS property.\n"
+ "By setting the CMAKE_AUTOMOC_STRICT_MODE variable to FALSE the rules "
+ "for searching the files which will be processed by moc can be relaxed. "
+ "See the documentation for this variable for more details.");
cm->DefineProperty
("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET,
@@ -584,15 +588,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 +607,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 +621,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 +1050,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 "
@@ -1201,6 +1219,9 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->Makefile->IsOn("CYGWIN") ||
this->Makefile->IsOn("MINGW"));
+ // Check whether we are targeting an Apple platform.
+ this->IsApple = this->Makefile->IsOn("APPLE");
+
// Setup default property values.
this->SetPropertyDefault("INSTALL_NAME_DIR", "");
this->SetPropertyDefault("INSTALL_RPATH", "");
@@ -3343,7 +3364,11 @@ void cmTarget::GetLibraryNames(std::string& name,
// the library version as the soversion.
soversion = version;
}
- bool isApple = this->Makefile->IsOn("APPLE");
+ if(!version && soversion)
+ {
+ // Use the soversion as the library version.
+ version = soversion;
+ }
// Get the components of the library name.
std::string prefix;
@@ -3355,47 +3380,12 @@ void cmTarget::GetLibraryNames(std::string& name,
name = prefix+base+suffix;
// The library's soname.
- if(isApple)
- {
- soName = prefix+base;
- }
- else
- {
- soName = name;
- }
- if(soversion)
- {
- soName += ".";
- soName += soversion;
- }
- if(isApple)
- {
- soName += suffix;
- }
+ this->ComputeVersionedName(soName, prefix, base, suffix,
+ name, soversion);
// The library's real name on disk.
- if(isApple)
- {
- realName = prefix+base;
- }
- else
- {
- realName = name;
- }
- if(version)
- {
- realName += ".";
- realName += version;
- }
- else if(soversion)
- {
- realName += ".";
- realName += soversion;
- }
- if(isApple)
- {
- realName += suffix;
- }
+ this->ComputeVersionedName(realName, prefix, base, suffix,
+ name, version);
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -3413,6 +3403,23 @@ void cmTarget::GetLibraryNames(std::string& name,
}
//----------------------------------------------------------------------------
+void cmTarget::ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version)
+{
+ vName = this->IsApple? (prefix+base) : name;
+ if(version)
+ {
+ vName += ".";
+ vName += version;
+ }
+ vName += this->IsApple? suffix : std::string();
+}
+
+//----------------------------------------------------------------------------
void cmTarget::GetExecutableNames(std::string& name,
std::string& realName,
std::string& impName,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 09fee6c..59f0184 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -565,6 +565,7 @@ private:
cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;
bool DLLPlatform;
+ bool IsApple;
bool IsImportedTarget;
// Cache target output paths for each configuration.
@@ -603,6 +604,12 @@ private:
cmTargetInternalPointer Internal;
void ConstructSourceFileFlags();
+ void ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version);
};
typedef std::map<cmStdString,cmTarget> cmTargets;
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/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index ed7f62c..4d83293 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -326,7 +326,7 @@ void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char
kwsys_stl::string pathEnv = cpathEnv;
// A hack to make the below algorithm work.
- if(pathEnv[pathEnv.length()-1] != ':')
+ if(!pathEnv.empty() && pathEnv[pathEnv.length()-1] != pathSep[0])
{
pathEnv += pathSep;
}
diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake
index 082aaba..b03f656 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 16)