summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-01-29 16:23:31 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-01-29 18:34:04 (GMT)
commit7bf490e9bb6128082aa178f28691b3fc418322fe (patch)
treea8f701d2db9a3960cceb1596705906c19ba42df4 /Source
parentf6b16d4b0642d26111cddff714b464e22b715482 (diff)
downloadCMake-7bf490e9bb6128082aa178f28691b3fc418322fe.zip
CMake-7bf490e9bb6128082aa178f28691b3fc418322fe.tar.gz
CMake-7bf490e9bb6128082aa178f28691b3fc418322fe.tar.bz2
Make subclasses responsible for joining content.
This way we can add handling of relative/absolute paths and of -D in compile definitions.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx27
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.h4
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx36
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h4
-rw-r--r--Source/cmTargetPropCommandBase.cxx13
-rw-r--r--Source/cmTargetPropCommandBase.h10
6 files changed, 76 insertions, 18 deletions
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index 312d625..7645833 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -37,9 +37,32 @@ void cmTargetCompileDefinitionsCommand
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
+//----------------------------------------------------------------------------
+std::string cmTargetCompileDefinitionsCommand
+::Join(const std::vector<std::string> &content)
+{
+ std::string defs;
+ std::string sep;
+ for(std::vector<std::string>::const_iterator it = content.begin();
+ it != content.end(); ++it)
+ {
+ if (strncmp(it->c_str(), "-D", 2) == 0)
+ {
+ defs += sep + it->substr(2);
+ }
+ else
+ {
+ defs += sep + *it;
+ }
+ sep = ";";
+ }
+ return defs;
+}
+
+//----------------------------------------------------------------------------
void cmTargetCompileDefinitionsCommand
-::HandleDirectContent(cmTarget *tgt, const std::string &content,
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool)
{
- tgt->AppendProperty("COMPILE_DEFINITIONS", content.c_str());
+ tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
}
diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h
index 6e8fc84..3b43820 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -81,8 +81,10 @@ private:
virtual void HandleImportedTarget(const std::string &tgt);
virtual void HandleMissingTarget(const std::string &name);
- virtual void HandleDirectContent(cmTarget *tgt, const std::string &content,
+ virtual void HandleDirectContent(cmTarget *tgt,
+ const std::vector<std::string> &content,
bool prepend);
+ virtual std::string Join(const std::vector<std::string> &content);
};
#endif
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index 51a2b6b..eaacfa9 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -41,12 +41,44 @@ void cmTargetIncludeDirectoriesCommand
}
//----------------------------------------------------------------------------
+static bool isGeneratorExpression(const std::string &lib)
+{
+ const std::string::size_type openpos = lib.find("$<");
+ return (openpos != std::string::npos)
+ && (lib.find(">", openpos) != std::string::npos);
+}
+
+//----------------------------------------------------------------------------
+std::string cmTargetIncludeDirectoriesCommand
+::Join(const std::vector<std::string> &content)
+{
+ std::string dirs;
+ std::string sep;
+ std::string prefix = this->Makefile->GetStartDirectory() + std::string("/");
+ for(std::vector<std::string>::const_iterator it = content.begin();
+ it != content.end(); ++it)
+ {
+ if (cmSystemTools::FileIsFullPath(it->c_str())
+ || isGeneratorExpression(*it))
+ {
+ dirs += sep + *it;
+ }
+ else
+ {
+ dirs += sep + prefix + *it;
+ }
+ sep = ";";
+ }
+ return dirs;
+}
+
+//----------------------------------------------------------------------------
void cmTargetIncludeDirectoriesCommand
-::HandleDirectContent(cmTarget *tgt, const std::string &content,
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool prepend)
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
- cmMakefileIncludeDirectoriesEntry entry(content, lfbt);
+ cmMakefileIncludeDirectoriesEntry entry(this->Join(content), lfbt);
tgt->InsertInclude(entry, prepend);
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index a254878..d02cb4a 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -85,8 +85,10 @@ private:
virtual void HandleImportedTarget(const std::string &tgt);
virtual void HandleMissingTarget(const std::string &name);
- virtual void HandleDirectContent(cmTarget *tgt, const std::string &content,
+ virtual void HandleDirectContent(cmTarget *tgt,
+ const std::vector<std::string> &content,
bool prepend);
+ virtual std::string Join(const std::vector<std::string> &content);
};
#endif
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index ef40438..18a1d2a 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -88,9 +88,8 @@ bool cmTargetPropCommandBase
++argIndex;
- std::string content;
+ std::vector<std::string> content;
- std::string sep;
for(unsigned int i=argIndex; i < args.size(); ++i, ++argIndex)
{
if(args[i] == "PUBLIC"
@@ -100,8 +99,7 @@ bool cmTargetPropCommandBase
this->PopulateTargetProperies(scope, content, prepend);
return true;
}
- content += sep + args[i];
- sep = ";";
+ content.push_back(args[i]);
}
this->PopulateTargetProperies(scope, content, prepend);
return true;
@@ -110,7 +108,8 @@ bool cmTargetPropCommandBase
//----------------------------------------------------------------------------
void cmTargetPropCommandBase
::PopulateTargetProperies(const std::string &scope,
- const std::string &content, bool prepend)
+ const std::vector<std::string> &content,
+ bool prepend)
{
if (scope == "PRIVATE" || scope == "PUBLIC")
{
@@ -122,7 +121,7 @@ void cmTargetPropCommandBase
{
const std::string propName = std::string("INTERFACE_") + this->Property;
const char *propValue = this->Target->GetProperty(propName.c_str());
- const std::string totalContent = content + (propValue
+ const std::string totalContent = this->Join(content) + (propValue
? std::string(";") + propValue
: std::string());
this->Target->SetProperty(propName.c_str(), totalContent.c_str());
@@ -130,7 +129,7 @@ void cmTargetPropCommandBase
else
{
this->Target->AppendProperty(("INTERFACE_" + this->Property).c_str(),
- content.c_str());
+ this->Join(content).c_str());
}
}
}
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index cc9897d..a5b4ff8 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -33,22 +33,22 @@ public:
protected:
std::string Property;
+ cmTarget *Target;
private:
virtual void HandleImportedTarget(const std::string &tgt) = 0;
virtual void HandleMissingTarget(const std::string &name) = 0;
virtual void HandleDirectContent(cmTarget *tgt,
- const std::string &content,
+ const std::vector<std::string> &content,
bool prepend) = 0;
+ virtual std::string Join(const std::vector<std::string> &content) = 0;
bool ProcessContentArgs(std::vector<std::string> const& args,
unsigned int &argIndex, bool prepend);
void PopulateTargetProperies(const std::string &scope,
- const std::string &content, bool prepend);
-
-private:
- cmTarget *Target;
+ const std::vector<std::string> &content,
+ bool prepend);
};
#endif