Use relative paths for custom command inputs.

For source files we use full paths.  This allows for longer directory
names with VS2010. However, the use of full paths causes the GUI
to not display the custom commands.
This commit is contained in:
Bill Hoffman 2011-06-22 11:52:15 -04:00
parent 38368d52f3
commit ed0075bdb7
1 changed files with 15 additions and 10 deletions

View File

@ -367,10 +367,11 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations(); (this->GlobalGenerator)->GetConfigurations();
this->WriteString("<CustomBuild Include=\"", 2); this->WriteString("<CustomBuild Include=\"", 2);
std::string path = // custom command have to use relative paths or they do not
cmSystemTools::RelativePath( // show up in the GUI
this->Makefile->GetCurrentOutputDirectory(), std::string path = cmSystemTools::RelativePath(
sourcePath.c_str()); this->Makefile->GetCurrentOutputDirectory(),
sourcePath.c_str());
this->ConvertToWindowsSlash(path); this->ConvertToWindowsSlash(path);
(*this->BuildFileStream ) << path << "\">\n"; (*this->BuildFileStream ) << path << "\">\n";
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
@ -611,9 +612,14 @@ WriteGroupSources(const char* name,
const char* filter = sourceGroup.GetFullName(); const char* filter = sourceGroup.GetFullName();
this->WriteString("<", 2); this->WriteString("<", 2);
std::string path = source; std::string path = source;
path = cmSystemTools::RelativePath( // custom command sources must use relative paths or they will
this->Makefile->GetCurrentOutputDirectory(), // not show up in the GUI.
source.c_str()); if(sf->GetCustomCommand())
{
path = cmSystemTools::RelativePath(
this->Makefile->GetCurrentOutputDirectory(),
source.c_str());
}
this->ConvertToWindowsSlash(path); this->ConvertToWindowsSlash(path);
(*this->BuildFileStream) << name << " Include=\"" (*this->BuildFileStream) << name << " Include=\""
<< path; << path;
@ -701,9 +707,8 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
bool rc = lang && (strcmp(lang, "RC") == 0); bool rc = lang && (strcmp(lang, "RC") == 0);
bool idl = ext == "idl"; bool idl = ext == "idl";
std::string sourceFile = (*source)->GetFullPath(); std::string sourceFile = (*source)->GetFullPath();
sourceFile = cmSystemTools::RelativePath( // do not use a relative path here because it means that you
this->Makefile->GetCurrentOutputDirectory(), // can not use as long a path to the file.
sourceFile.c_str());
this->ConvertToWindowsSlash(sourceFile); this->ConvertToWindowsSlash(sourceFile);
// output the source file // output the source file
if(header) if(header)