diff options
author | Brad King <brad.king@kitware.com> | 2012-04-27 14:42:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-04-27 15:53:40 (GMT) |
commit | 4248132e59a8401a96d9c20ef155d80e439e7346 (patch) | |
tree | 50d91ee01d0fa69753c7b424dcb6a65bfdd7a97c /Source | |
parent | c2ba6ba4fc0d807f36a6a9fcb1c166b776750dae (diff) | |
download | CMake-4248132e59a8401a96d9c20ef155d80e439e7346.zip CMake-4248132e59a8401a96d9c20ef155d80e439e7346.tar.gz CMake-4248132e59a8401a96d9c20ef155d80e439e7346.tar.bz2 |
VS10: Convert paths normally unless forced to relative
Most CMake generators produce relative paths within the build tree and
full paths to files outside the build tree. Make VS 10 and VS 11
project files consistent with this approach except for paths forced to
be relative to work around a VS 10 bug.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 39 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 1 |
2 files changed, 21 insertions, 19 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index c4d5415..7c38d4b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -536,6 +536,18 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, this->WriteString("</CustomBuild>\n", 2); } +std::string +cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path, + bool forceRelative) +{ + return forceRelative + ? cmSystemTools::RelativePath( + this->Makefile->GetCurrentOutputDirectory(), path.c_str()) + : this->LocalGenerator->Convert(path.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED); +} + void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s) { // first convert all of the slashes @@ -716,10 +728,7 @@ WriteGroupSources(const char* name, this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); const char* filter = sourceGroup.GetFullName(); this->WriteString("<", 2); - std::string path = s->RelativePath? - cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - source.c_str()) : source; + std::string path = this->ConvertPath(source, s->RelativePath); this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << name << " Include=\"" << path; @@ -743,25 +752,17 @@ void cmVisualStudio10TargetGenerator::WriteSource( const char* tool, cmSourceFile* sf, const char* end) { std::string sourceFile = sf->GetFullPath(); - bool relative = sf->GetCustomCommand()? true:false; - if(relative) - { - // 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. - } + // do not use a relative path here because it means that you + // can not use as long a path to the file. + // custom command sources must use relative paths or they will + // not show up in the GUI. + bool forceRelative = sf->GetCustomCommand()? true:false; + sourceFile = this->ConvertPath(sourceFile, forceRelative); this->ConvertToWindowsSlash(sourceFile); this->WriteString("<", 2); (*this->BuildFileStream ) << tool << " Include=\"" << sourceFile << "\"" << (end? end : " />\n"); - ToolSource toolSource = {sf, relative}; + ToolSource toolSource = {sf, forceRelative}; this->Tools[tool].push_back(toolSource); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c00d328..2d5ec2a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -50,6 +50,7 @@ private: }; struct ToolSources: public std::vector<ToolSource> {}; + std::string ConvertPath(std::string const& path, bool forceRelative); void ConvertToWindowsSlash(std::string& s); void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); |