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.
This commit is contained in:
parent
c2ba6ba4fc
commit
4248132e59
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue