summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake6
-rw-r--r--Source/cmAlgorithms.h6
-rw-r--r--Source/cmCacheManager.cxx10
-rw-r--r--Source/cmConditionEvaluator.cxx10
-rw-r--r--Source/cmCurl.cxx5
-rw-r--r--Source/cmExportFileGenerator.cxx21
-rw-r--r--Source/cmExportInstallFileGenerator.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx2
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmGlobalGenerator.cxx90
-rw-r--r--Source/cmGlobalGenerator.h24
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx9
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h2
-rw-r--r--Source/cmInstallCommand.cxx8
-rw-r--r--Source/cmInstallTargetGenerator.cxx16
-rw-r--r--Source/cmLocalGenerator.cxx2
-rw-r--r--Source/cmMacroCommand.cxx16
-rw-r--r--Source/cmMakefile.cxx40
-rw-r--r--Source/cmParseArgumentsCommand.cxx12
-rw-r--r--Source/cmSystemTools.cxx102
-rw-r--r--Source/cmSystemTools.h4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx15
-rw-r--r--Source/cmcmd.cxx17
23 files changed, 242 insertions, 179 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index ea95862..58eb1fc 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 4)
-set(CMake_VERSION_PATCH 20160114)
-#set(CMake_VERSION_RC 1)
+set(CMake_VERSION_MINOR 5)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 2)
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index ef607d2..bb65ea5 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -52,13 +52,13 @@ template<typename T, size_t N>
size_t cmArraySize(const T (&)[N]) { return N; }
template<typename T, size_t N>
-bool cmHasLiteralPrefix(T str1, const char (&str2)[N])
+bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralPrefixImpl(str1, str2, N - 1);
}
template<typename T, size_t N>
-bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
+bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralSuffixImpl(str1, str2, N - 1);
}
@@ -230,7 +230,7 @@ template<typename Range>
std::string cmJoin(Range const& r, std::string delimiter)
{
return cmJoin(r, delimiter.c_str());
-};
+}
template<typename Range>
typename Range::const_iterator cmRemoveN(Range& r, size_t n)
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index ce8af55..7466c29 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -64,12 +64,14 @@ bool cmCacheManager::LoadCache(const std::string& path,
const char *realbuffer;
std::string buffer;
std::string entryKey;
+ unsigned int lineno = 0;
while(fin)
{
// Format is key:type=value
std::string helpString;
CacheEntry e;
cmSystemTools::GetLineFromStream(fin, buffer);
+ lineno++;
realbuffer = buffer.c_str();
while(*realbuffer != '0' &&
(*realbuffer == ' ' ||
@@ -77,6 +79,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
*realbuffer == '\r' ||
*realbuffer == '\n'))
{
+ if (*realbuffer == '\n') lineno++;
realbuffer++;
}
// skip blank lines and comment lines
@@ -96,6 +99,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
helpString += &realbuffer[2];
}
cmSystemTools::GetLineFromStream(fin, buffer);
+ lineno++;
realbuffer = buffer.c_str();
if(!fin)
{
@@ -138,8 +142,10 @@ bool cmCacheManager::LoadCache(const std::string& path,
}
else
{
- cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
- ". Offending entry: ", realbuffer);
+ std::ostringstream error;
+ error << "Parse error in cache file " << cacheFile;
+ error << " on line " << lineno << ". Offending entry: " << realbuffer;
+ cmSystemTools::Error(error.str().c_str());
}
}
this->CacheMajorVersion = 0;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 5330acd..6a0ebec 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -12,6 +12,7 @@
#include "cmConditionEvaluator.h"
#include "cmOutputConverter.h"
+#include "cmAlgorithms.h"
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
const cmListFileContext &context,
@@ -578,6 +579,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
cmake::MessageType &status)
{
int reducible;
+ std::string def_buf;
const char *def;
const char *def2;
do
@@ -594,6 +596,14 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
IsKeyword("MATCHES", *argP1))
{
def = this->GetVariableOrString(*arg);
+ if (def != arg->c_str() // yes, we compare the pointer value
+ && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_"))
+ {
+ // The string to match is owned by our match result variables.
+ // Move it to our own buffer before clearing them.
+ def_buf = def;
+ def = def_buf.c_str();
+ }
const char* rex = argP2->c_str();
this->Makefile.ClearMatches();
cmsys::RegularExpression regEntry;
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index ad0c7d3..4f3d890 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -12,6 +12,11 @@
#include "cmCurl.h"
#include "cmSystemTools.h"
+// curl versions before 7.21.5 did not provide this error code
+#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x071505
+# define CURLE_NOT_BUILT_IN 4
+#endif
+
#define check_curl_result(result, errstr) \
if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN) \
{ \
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index e8a2e6a..c005995 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -772,6 +772,27 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
lastPos = endPos;
}
+ pos = 0;
+ lastPos = pos;
+ while (errorString.empty() &&
+ (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos)
+ {
+ std::string::size_type nameStartPos = pos + sizeof("$<LINK_ONLY:") - 1;
+ std::string::size_type endPos = input.find(">", nameStartPos);
+ if (endPos == input.npos)
+ {
+ errorString = "$<LINK_ONLY:...> expression incomplete";
+ break;
+ }
+ std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
+ if (cmGeneratorExpression::IsValidTargetName(libName) &&
+ this->AddTargetNamespace(libName, target, missingTargets))
+ {
+ input.replace(nameStartPos, endPos - nameStartPos, libName);
+ }
+ lastPos = nameStartPos + libName.size() + 1;
+ }
+
this->ReplaceInstallPrefix(input);
if (!errorString.empty())
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index b695904..71418e8 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -496,7 +496,7 @@ cmExportInstallFileGenerator
bool containsTarget = false;
for(unsigned int i=0; i<targets->size(); i++)
{
- if (name == (*targets)[i]->Target->GetName())
+ if (name == (*targets)[i]->TargetName)
{
containsTarget = true;
break;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index b05fb41..ff12320 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -335,7 +335,7 @@ cmState::TargetType cmGeneratorTarget::GetType() const
}
//----------------------------------------------------------------------------
-std::string cmGeneratorTarget::GetName() const
+const std::string& cmGeneratorTarget::GetName() const
{
return this->Target->GetName();
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index bd23477..d96a32c 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -55,7 +55,7 @@ public:
GetLinkInformation(const std::string& config) const;
cmState::TargetType GetType() const;
- std::string GetName() const;
+ const std::string& GetName() const;
std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2126c71..848028f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -86,6 +86,13 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->TryCompileOuterMakefile = 0;
this->ConfigureDoneCMP0026AndCMP0024 = false;
+
+ cm->GetState()->SetMinGWMake(false);
+ cm->GetState()->SetMSYSShell(false);
+ cm->GetState()->SetNMake(false);
+ cm->GetState()->SetWatcomWMake(false);
+ cm->GetState()->SetWindowsShell(false);
+ cm->GetState()->SetWindowsVSIDE(false);
}
cmGlobalGenerator::~cmGlobalGenerator()
@@ -1649,6 +1656,8 @@ void cmGlobalGenerator::ClearGeneratorMembers()
this->ExportSets.clear();
this->TargetDependencies.clear();
+ this->TargetSearchIndex.clear();
+ this->GeneratorTargetSearchIndex.clear();
this->ProjectMap.clear();
this->RuleHashes.clear();
this->DirectoryContentMap.clear();
@@ -1850,7 +1859,7 @@ int cmGlobalGenerator::Build(
!makeCommand.empty() && cmSystemTools::LowerCase(
cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe")
{
- outputflag = cmSystemTools::OUTPUT_NORMAL;
+ outputflag = cmSystemTools::OUTPUT_FORWARD;
}
// should we do a clean first?
@@ -2177,75 +2186,40 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const
return this->AliasTargets.find(name) != this->AliasTargets.end();
}
-cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
+void cmGlobalGenerator::IndexTarget(cmTarget* t)
{
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+ if (!t->IsImported() || t->IsImportedGloballyVisible())
{
- cmTargets& tgts = this->Makefiles[i]->GetTargets();
- for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it)
- {
- if (it->second.GetName() == name)
- {
- return &it->second;
- }
- }
+ this->TargetSearchIndex[t->GetName()] = t;
}
- return 0;
}
-cmGeneratorTarget*
-cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
+void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
{
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+ if (!gt->IsImported() || gt->IsImportedGloballyVisible())
{
- std::vector<cmGeneratorTarget*> tgts =
- this->LocalGenerators[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
- it != tgts.end(); ++it)
- {
- if ((*it)->GetName() == name)
- {
- return *it;
- }
- }
+ this->GeneratorTargetSearchIndex[gt->GetName()] = gt;
}
- return 0;
}
-cmTarget*
-cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
+cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
{
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+ TargetMap::const_iterator i = this->TargetSearchIndex.find(name);
+ if (i != this->TargetSearchIndex.end())
{
- std::vector<cmTarget*> tgts =
- this->Makefiles[i]->GetOwnedImportedTargets();
- for (std::vector<cmTarget*>::iterator it = tgts.begin();
- it != tgts.end(); ++it)
- {
- if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
- {
- return *it;
- }
- }
+ return i->second;
}
return 0;
}
-cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
- std::string const& name) const
+cmGeneratorTarget*
+cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
{
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+ GeneratorTargetMap::const_iterator i =
+ this->GeneratorTargetSearchIndex.find(name);
+ if (i != this->GeneratorTargetSearchIndex.end())
{
- std::vector<cmGeneratorTarget*> tgts =
- this->LocalGenerators[i]->GetImportedGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
- it != tgts.end(); ++it)
- {
- if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)
- {
- return *it;
- }
- }
+ return i->second;
}
return 0;
}
@@ -2264,11 +2238,7 @@ cmGlobalGenerator::FindTarget(const std::string& name,
return this->FindTargetImpl(ai->second);
}
}
- if (cmTarget* tgt = this->FindTargetImpl(name))
- {
- return tgt;
- }
- return this->FindImportedTargetImpl(name);
+ return this->FindTargetImpl(name);
}
cmGeneratorTarget*
@@ -2280,11 +2250,7 @@ cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
{
return this->FindGeneratorTargetImpl(ai->second);
}
- if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
- {
- return tgt;
- }
- return this->FindImportedGeneratorTargetImpl(name);
+ return this->FindGeneratorTargetImpl(name);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index bc6e17d..48fa704 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -278,6 +278,9 @@ public:
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
+ void IndexTarget(cmTarget* t);
+ void IndexGeneratorTarget(cmGeneratorTarget* gt);
+
static bool IsReservedTarget(std::string const& name);
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
@@ -420,7 +423,6 @@ protected:
std::map<std::string, std::string> AliasTargets;
cmTarget* FindTargetImpl(std::string const& name) const;
- cmTarget* FindImportedTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
cmGeneratorTarget*
@@ -430,6 +432,26 @@ protected:
virtual bool UseFolderProperty();
private:
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, cmTarget*> TargetMap;
+ typedef std::unordered_map<std::string, cmGeneratorTarget*>
+ GeneratorTargetMap;
+# else
+ typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+ typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
+# endif
+#else
+ typedef std::map<std::string,cmTarget *> TargetMap;
+ typedef std::map<std::string,cmGeneratorTarget *> GeneratorTargetMap;
+#endif
+ // Map efficiently from target name to cmTarget instance.
+ // Do not use this structure for looping over all targets.
+ // It contains both normal and globally visible imported targets.
+ TargetMap TargetSearchIndex;
+ GeneratorTargetMap GeneratorTargetSearchIndex;
+
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index f151d80..c058f8c 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -117,7 +117,7 @@ bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
{
if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
{
- return this->SelectWindows10SDK(mf);
+ return this->SelectWindows10SDK(mf, false);
}
return true;
}
@@ -145,17 +145,18 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
}
if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
{
- return this->SelectWindows10SDK(mf);
+ return this->SelectWindows10SDK(mf, true);
}
return true;
}
//----------------------------------------------------------------------------
-bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
+bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
+ bool required)
{
// Find the default version of the Windows 10 SDK.
this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
- if (this->WindowsTargetPlatformVersion.empty())
+ if (required && this->WindowsTargetPlatformVersion.empty())
{
std::ostringstream e;
e << "Could not find an appropriate version of the Windows 10 SDK"
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 76c15d9..57e6284 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -39,7 +39,7 @@ protected:
bool IsWindowsStoreToolsetInstalled() const;
virtual const char* GetIDEVersion() { return "14.0"; }
- virtual bool SelectWindows10SDK(cmMakefile* mf);
+ virtual bool SelectWindows10SDK(cmMakefile* mf, bool required);
// Used to verify that the Desktop toolset for the current generator is
// installed on the machine.
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 15a83ee..2d78a41 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -1374,10 +1374,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tei != exportSet->GetTargetExports()->end(); ++tei)
{
cmTargetExport const* te = *tei;
- cmTarget* tgt = this->Makefile->FindTarget(te->TargetName);
+ cmTarget* tgt =
+ this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
- tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN
- && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+ (tgt &&
+ tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+ tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if(!newCMP0022Behavior)
{
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 1158a27..5e88fa2 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -791,18 +791,10 @@ cmInstallTargetGenerator
}
// Write a rule to run chrpath to set the install-tree RPATH
- if(newRpath.empty())
- {
- os << indent << "file(RPATH_REMOVE\n"
- << indent << " FILE \"" << toDestDirPath << "\")\n";
- }
- else
- {
- os << indent << "file(RPATH_CHANGE\n"
- << indent << " FILE \"" << toDestDirPath << "\"\n"
- << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
- << indent << " NEW_RPATH \"" << newRpath << "\")\n";
- }
+ os << indent << "file(RPATH_CHANGE\n"
+ << indent << " FILE \"" << toDestDirPath << "\"\n"
+ << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
+ << indent << " NEW_RPATH \"" << newRpath << "\")\n";
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1d17032..912be0c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -455,11 +455,13 @@ void cmLocalGenerator::GenerateInstallRules()
void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
{
this->GeneratorTargets.push_back(gt);
+ this->GlobalGenerator->IndexGeneratorTarget(gt);
}
void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
{
this->ImportedGeneratorTargets.push_back(gt);
+ this->GlobalGenerator->IndexGeneratorTarget(gt);
}
void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index e4026b0..71de7a7 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -146,16 +146,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
// replace formal arguments
for (unsigned int j = 0; j < variables.size(); ++j)
{
- cmSystemTools::ReplaceString(arg.Value, variables[j].c_str(),
- expandedArgs[j].c_str());
+ cmSystemTools::ReplaceString(arg.Value, variables[j],
+ expandedArgs[j]);
}
// replace argc
- cmSystemTools::ReplaceString(arg.Value, "${ARGC}",argcDef.c_str());
+ cmSystemTools::ReplaceString(arg.Value, "${ARGC}", argcDef);
- cmSystemTools::ReplaceString(arg.Value, "${ARGN}",
- expandedArgn.c_str());
- cmSystemTools::ReplaceString(arg.Value, "${ARGV}",
- expandedArgv.c_str());
+ cmSystemTools::ReplaceString(arg.Value, "${ARGN}", expandedArgn);
+ cmSystemTools::ReplaceString(arg.Value, "${ARGV}", expandedArgv);
// if the current argument of the current function has ${ARGV in it
// then try replacing ARGV values
@@ -163,8 +161,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
{
- cmSystemTools::ReplaceString(arg.Value, argVs[t].c_str(),
- expandedArgs[t].c_str());
+ cmSystemTools::ReplaceString(arg.Value, argVs[t],
+ expandedArgs[t]);
}
}
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1b0a99a..950b247 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -791,7 +791,24 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
if(issueMessage)
{
- e << "The target name \"" << target << "\" is unknown in this context.";
+ if (cmTarget const* t = this->FindTargetToUse(target))
+ {
+ if (t->IsImported())
+ {
+ e << "TARGET '" << target
+ << "' is IMPORTED and does not build here.";
+ }
+ else
+ {
+ e << "TARGET '" << target
+ << "' was not created in this directory.";
+ }
+ }
+ else
+ {
+ e << "No TARGET '" << target
+ << "' has been created in this directory.";
+ }
IssueMessage(messageType, e.str());
}
@@ -2111,6 +2128,7 @@ cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
cmTarget& target = it->second;
target.SetType(type, name);
target.SetMakefile(this);
+ this->GetGlobalGenerator()->IndexTarget(&it->second);
return &it->second;
}
@@ -2832,10 +2850,9 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
const char* last = in;
std::string result;
result.reserve(source.size());
- std::stack<t_lookup> openstack;
+ std::vector<t_lookup> openstack;
bool error = false;
bool done = false;
- openstack.push(t_lookup());
cmake::MessageType mtype = cmake::LOG;
cmState* state = this->GetCMakeInstance()->GetState();
@@ -2846,10 +2863,10 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
switch(inc)
{
case '}':
- if(openstack.size() > 1)
+ if(!openstack.empty())
{
- t_lookup var = openstack.top();
- openstack.pop();
+ t_lookup var = openstack.back();
+ openstack.pop_back();
result.append(last, in - last);
std::string const& lookup = result.substr(var.loc);
const char* value = NULL;
@@ -2970,7 +2987,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
last = start;
in = start - 1;
lookup.loc = result.size();
- openstack.push(lookup);
+ openstack.push_back(lookup);
}
break;
}
@@ -2997,7 +3014,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
result.append("\r");
last = next + 1;
}
- else if(nextc == ';' && openstack.size() == 1)
+ else if(nextc == ';' && openstack.empty())
{
// Handled in ExpandListArgument; pass the backslash literally.
}
@@ -3065,7 +3082,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
/* FALLTHROUGH */
default:
{
- if(openstack.size() > 1 &&
+ if(!openstack.empty() &&
!(isalnum(inc) || inc == '_' ||
inc == '/' || inc == '.' ||
inc == '+' || inc == '-'))
@@ -3074,7 +3091,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
errorstr += inc;
result.append(last, in - last);
errorstr += "\') in a variable name: "
- "'" + result.substr(openstack.top().loc) + "'";
+ "'" + result.substr(openstack.back().loc) + "'";
mtype = cmake::FATAL_ERROR;
error = true;
}
@@ -3085,7 +3102,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
} while(!error && !done && *++in);
// Check for open variable references yet.
- if(!error && openstack.size() != 1)
+ if(!error && !openstack.empty())
{
// There's an open variable reference waiting. Policy CMP0010 flags
// whether this is an error or not. The new parser now enforces
@@ -4202,6 +4219,7 @@ cmMakefile::AddImportedTarget(const std::string& name,
// Add to the set of available imported targets.
this->ImportedTargets[name] = target.get();
+ this->GetGlobalGenerator()->IndexTarget(target.get());
// Transfer ownership to this cmMakefile object.
this->ImportedTargetsOwned.push_back(target.get());
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index a861965..ca76c88 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -97,10 +97,18 @@ bool cmParseArgumentsCommand
} insideValues = NONE;
std::string currentArgName;
- // now iterate over the remaining arguments
- // and fill in the values where applicable
+ // Flatten ;-lists in the arguments into a single list as was done
+ // by the original function(CMAKE_PARSE_ARGUMENTS).
+ list.clear();
for(; argIter != argEnd; ++argIter)
{
+ cmSystemTools::ExpandListArgument(*argIter, list);
+ }
+
+ // iterate over the arguments list and fill in the values where applicable
+ for (argIter = list.begin(), argEnd = list.end();
+ argIter != argEnd; ++argIter)
+ {
const options_map::iterator optIter = options.find(*argIter);
if (optIter != options.end())
{
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 008272c..3ba7287 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -17,6 +17,7 @@
#include <time.h>
#include <string.h>
#include <stdlib.h>
+#include <assert.h>
#ifdef __QNX__
# include <malloc.h> /* for malloc/free on QNX */
#endif
@@ -660,14 +661,6 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
argv.push_back(a->c_str());
}
argv.push_back(0);
- if ( captureStdOut )
- {
- *captureStdOut = "";
- }
- if (captureStdErr && captureStdErr != captureStdOut)
- {
- *captureStdErr = "";
- }
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, &*argv.begin());
@@ -681,7 +674,16 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
{
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
+ captureStdOut = 0;
+ captureStdErr = 0;
}
+ else if (outputflag == OUTPUT_MERGE ||
+ (captureStdErr && captureStdErr == captureStdOut))
+ {
+ cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
+ captureStdErr = 0;
+ }
+ assert(!captureStdErr || captureStdErr != captureStdOut);
cmsysProcess_SetTimeout(cp, timeout);
cmsysProcess_Execute(cp);
@@ -696,65 +698,50 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
{
while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0)
{
- if(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)
+ // Translate NULL characters in the output into valid text.
+ // Visual Studio 7 puts these characters in the output of its
+ // build process.
+ for(int i=0; i < length; ++i)
{
- // Translate NULL characters in the output into valid text.
- // Visual Studio 7 puts these characters in the output of its
- // build process.
- for(int i=0; i < length; ++i)
+ if(data[i] == '\0')
{
- if(data[i] == '\0')
- {
- data[i] = ' ';
- }
+ data[i] = ' ';
}
}
- if(pipe == cmsysProcess_Pipe_STDOUT ||
- (pipe == cmsysProcess_Pipe_STDERR &&
- captureStdOut == captureStdErr))
+
+ if (pipe == cmsysProcess_Pipe_STDOUT)
{
- if (captureStdOut)
+ if (outputflag != OUTPUT_NONE)
{
- tempStdOut.insert(tempStdOut.end(), data, data+length);
+ cmSystemTools::Stdout(data, length);
}
- }
- else if(pipe == cmsysProcess_Pipe_STDERR)
- {
- if (captureStdErr)
+ if (captureStdOut)
{
- tempStdErr.insert(tempStdErr.end(), data, data+length);
+ tempStdOut.insert(tempStdOut.end(), data, data+length);
}
}
- if(outputflag != OUTPUT_NONE)
+ else if (pipe == cmsysProcess_Pipe_STDERR)
{
- if(outputflag == OUTPUT_MERGE)
+ if (outputflag != OUTPUT_NONE)
{
- cmSystemTools::Stdout(data, length);
+ cmSystemTools::Stderr(data, length);
}
- else
+ if (captureStdErr)
{
- if(pipe == cmsysProcess_Pipe_STDERR)
- {
- cmSystemTools::Stderr(data, length);
- }
- else if(pipe == cmsysProcess_Pipe_STDOUT)
- {
- cmSystemTools::Stdout(data, length);
- }
+ tempStdErr.insert(tempStdErr.end(), data, data+length);
}
}
}
}
cmsysProcess_WaitForExit(cp, 0);
- if ( captureStdOut && tempStdOut.begin() != tempStdOut.end())
+ if (captureStdOut)
{
- captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size());
+ captureStdOut->assign(tempStdOut.begin(), tempStdOut.end());
}
- if ( captureStdErr && captureStdErr != captureStdOut &&
- tempStdErr.begin() != tempStdErr.end())
+ if (captureStdErr)
{
- captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size());
+ captureStdErr->assign(tempStdErr.begin(), tempStdErr.end());
}
bool result = true;
@@ -2565,6 +2552,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
*changed = false;
}
int rp_count = 0;
+ bool remove_rpath = true;
cmSystemToolsRPathInfo rp[2];
{
// Parse the ELF binary.
@@ -2622,6 +2610,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// If it contains the new rpath instead then it is okay.
if(cmSystemToolsFindRPath(se[i]->Value, newRPath) != std::string::npos)
{
+ remove_rpath = false;
continue;
}
if(emsg)
@@ -2642,13 +2631,30 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
rp[rp_count].Size = se[i]->Size;
rp[rp_count].Name = se_name[i];
+ std::string::size_type prefix_len = pos;
+
+ // If oldRPath was at the end of the file's RPath, and newRPath is empty,
+ // we should remove the unnecessary ':' at the end.
+ if (newRPath.empty() &&
+ pos > 0 &&
+ se[i]->Value[pos - 1] == ':' &&
+ pos + oldRPath.length() == se[i]->Value.length())
+ {
+ prefix_len--;
+ }
+
// Construct the new value which preserves the part of the path
// not being changed.
- rp[rp_count].Value = se[i]->Value.substr(0, pos);
+ rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
rp[rp_count].Value += newRPath;
rp[rp_count].Value += se[i]->Value.substr(pos+oldRPath.length(),
oldRPath.npos);
+ if (!rp[rp_count].Value.empty())
+ {
+ remove_rpath = false;
+ }
+
// Make sure there is enough room to store the new rpath and at
// least one null terminator.
if(rp[rp_count].Size < rp[rp_count].Value.length()+1)
@@ -2673,6 +2679,12 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
return true;
}
+ // If the resulting rpath is empty, just remove the entire entry instead.
+ if (remove_rpath)
+ {
+ return cmSystemTools::RemoveRPath(file, emsg, changed);
+ }
+
{
// Open the file for update.
cmsys::ofstream f(file.c_str(),
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 9cafbec..f511ae4 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -203,7 +203,7 @@ public:
* Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no
* user-viewable output from the program being run will be generated.
* OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged
- * into stdout. OUTPUT_NORMAL passes through the output to stdout/stderr as
+ * into stdout. OUTPUT_FORWARD copies the output to stdout/stderr as
* it was received. OUTPUT_PASSTHROUGH passes through the original handles.
*
* If timeout is specified, the command will be terminated after
@@ -223,7 +223,7 @@ public:
{
OUTPUT_NONE = 0,
OUTPUT_MERGE,
- OUTPUT_NORMAL,
+ OUTPUT_FORWARD,
OUTPUT_PASSTHROUGH
};
static bool RunSingleCommand(const char* command,
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 27ae685..09d4a90 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -762,13 +762,16 @@ void cmVisualStudio10TargetGenerator
std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
std::string useOfMfcValue = "false";
- if(mfcFlagValue == "1")
- {
- useOfMfcValue = "Static";
- }
- else if(mfcFlagValue == "2")
+ if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
{
- useOfMfcValue = "Dynamic";
+ if(mfcFlagValue == "1")
+ {
+ useOfMfcValue = "Static";
+ }
+ else if(mfcFlagValue == "2")
+ {
+ useOfMfcValue = "Dynamic";
+ }
}
std::string mfcLine = "<UseOfMfc>";
mfcLine += useOfMfcValue + "</UseOfMfc>\n";
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index fb7b1f5..e9d77b2 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -361,11 +361,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Now run the real compiler command and return its result value.
- if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, &stdErr, &ret, 0,
+ if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, 0, &ret, 0,
cmSystemTools::OUTPUT_PASSTHROUGH))
{
- std::cerr << "Error running '" << orig_cmd[0] << "': "
- << stdErr << "\n";
+ std::cerr << "Error running '" << orig_cmd[0] << "'\n";
return 1;
}
return ret;
@@ -555,7 +554,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Clock command
else if (args[1] == "time" && args.size() > 2)
{
- std::string command = cmJoin(cmMakeRange(args).advance(2), " ");
+ std::vector<std::string> command(args.begin()+2, args.end());
clock_t clock_start, clock_finish;
time_t time_start, time_finish;
@@ -563,7 +562,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
time(&time_start);
clock_start = clock();
int ret =0;
- cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &ret);
+ cmSystemTools::RunSingleCommand(command, 0, 0, &ret);
clock_finish = clock();
time(&time_finish);
@@ -621,7 +620,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
int retval = 0;
int timeout = 0;
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,
- directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) )
+ directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout) )
{
return retval;
}
@@ -814,10 +813,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
cm.SetGlobalGenerator(ggd);
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
- snapshot.GetDirectory().SetCurrentBinary
- (cmSystemTools::GetCurrentWorkingDirectory());
- snapshot.GetDirectory().SetCurrentSource
- (cmSystemTools::GetCurrentWorkingDirectory());
+ snapshot.GetDirectory().SetCurrentBinary(startOutDir);
+ snapshot.GetDirectory().SetCurrentSource(startDir);
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
cmsys::auto_ptr<cmLocalGenerator> lgd(
ggd->CreateLocalGenerator(mf.get()));