VS11: Do not use source path conversion workaround specific to VS 10

CMake <= 2.8.4 generated VS 10 project files with a relative path to
source files.  Then commit ed0075bd (Use relative paths for custom command
inputs, 2011-06-22) switched to using relative paths only for source files
holding custom commands and full paths for other sources.  This behavior
was inhereted by the VS 11 generator but is not needed so use the
workaround only for exactly VS 10.  Explain the behavior in comments.
This commit is contained in:
Brad King 2012-04-27 11:00:22 -04:00
parent 4248132e59
commit b2e7c7aef0
1 changed files with 22 additions and 7 deletions

View File

@ -751,13 +751,28 @@ WriteGroupSources(const char* name,
void cmVisualStudio10TargetGenerator::WriteSource(
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.
// 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);
// Visual Studio tools append relative paths to the current dir, as in:
//
// c:\path\to\current\dir\..\..\..\relative\path\to\source.c
//
// and fail if this exceeds the maximum allowed path length. Our path
// conversion uses full paths outside the build tree to allow deeper trees.
bool forceRelative = false;
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10
&& cmSystemTools::FileIsFullPath(sourceFile.c_str()))
{
// Normal path conversion resulted in a full path. VS 10 (but not 11)
// refuses to show the property page in the IDE for a source file with a
// full path (not starting in a '.' or '/' AFAICT). CMake <= 2.8.4 used a
// relative path but to allow deeper build trees now CMake uses a full
// path except for custom commands which work only as relative paths.
if(sf->GetCustomCommand())
{
forceRelative = true;
sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative);
}
}
this->ConvertToWindowsSlash(sourceFile);
this->WriteString("<", 2);
(*this->BuildFileStream ) << tool <<