From b2e7c7aef0375d5d676632d8cc3a7c2d96d6a8fa Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 27 Apr 2012 11:00:22 -0400 Subject: [PATCH] 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. --- Source/cmVisualStudio10TargetGenerator.cxx | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7c38d4b6b..f8e4c30b3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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 <<