summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-04-27 12:34:49 (GMT)
committerBrad King <brad.king@kitware.com>2012-04-27 13:15:03 (GMT)
commit4f2d9d2da56b13b5780387492a400baa03d5bf70 (patch)
tree45975504955da28e2b3baedeff37f5651db17dfc /Source
parenta7d0fb1470cc7c900abfff14a87039d353a8c2b3 (diff)
downloadCMake-4f2d9d2da56b13b5780387492a400baa03d5bf70.zip
CMake-4f2d9d2da56b13b5780387492a400baa03d5bf70.tar.gz
CMake-4f2d9d2da56b13b5780387492a400baa03d5bf70.tar.bz2
VS10: Refactor custom commands to use WriteSource
All other source file elements are already written through WriteSource. Refactor custom command source element generation into WriteSource too.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx32
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h2
2 files changed, 20 insertions, 14 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9c25b0c..9a0c5e1 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -491,14 +491,9 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
- this->WriteString("<CustomBuild Include=\"", 2);
- // custom command have to use relative paths or they do not
- // show up in the GUI
- std::string path = cmSystemTools::RelativePath(
- this->Makefile->GetCurrentOutputDirectory(),
- sourcePath.c_str());
- this->ConvertToWindowsSlash(path);
- (*this->BuildFileStream ) << path << "\">\n";
+
+ this->WriteSource("CustomBuild", source, ">\n");
+
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
@@ -796,15 +791,26 @@ WriteGroupSources(const char* name,
}
void cmVisualStudio10TargetGenerator::WriteSource(
- const char* tool, cmSourceFile* sf, bool end)
+ const char* tool, cmSourceFile* sf, const char* end)
{
std::string sourceFile = sf->GetFullPath();
- // do not use a relative path here because it means that you
- // can not use as long a path to the file.
+ if(sf->GetCustomCommand())
+ {
+ // custom command sources must use relative paths or they will
+ // not show up in the GUI.
+ sourceFile = cmSystemTools::RelativePath(
+ this->Makefile->GetCurrentOutputDirectory(),
+ sourceFile.c_str());
+ }
+ else
+ {
+ // do not use a relative path here because it means that you
+ // can not use as long a path to the file.
+ }
this->ConvertToWindowsSlash(sourceFile);
this->WriteString("<", 2);
(*this->BuildFileStream ) << tool <<
- " Include=\"" << sourceFile << (end? "\" />\n" : "\" ");
+ " Include=\"" << sourceFile << "\"" << (end? end : " />\n");
}
void cmVisualStudio10TargetGenerator::WriteSources(
@@ -836,7 +842,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
bool cl = strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0;
bool rc = strcmp(lang, "RC") == 0;
const char* tool = cl? "ClCompile" : (rc? "ResourceCompile" : "None");
- this->WriteSource(tool, *si, false);
+ this->WriteSource(tool, *si, " ");
// ouput any flags specific to this source file
if(cl && this->OutputSourceSpecificFlags(*si))
{
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 20a443b..1e0f9c1 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -47,7 +47,7 @@ private:
void WriteString(const char* line, int indentLevel);
void WriteProjectConfigurations();
void WriteProjectConfigurationValues();
- void WriteSource(const char* tool, cmSourceFile* sf, bool end = true);
+ void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0);
void WriteSources(const char* tool, std::vector<cmSourceFile*> const&);
void WriteAllSources();
void WriteDotNetReferences();