summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-04-27 18:13:02 (GMT)
committerBrad King <brad.king@kitware.com>2012-04-27 18:14:36 (GMT)
commitd931ce9fe0c26cfddb766901cfd1ccbc9def71c7 (patch)
treee4644987b19c1ff0061dff199e2525268b81be91 /Source/cmVisualStudio10TargetGenerator.cxx
parentb2e7c7aef0375d5d676632d8cc3a7c2d96d6a8fa (diff)
downloadCMake-d931ce9fe0c26cfddb766901cfd1ccbc9def71c7.zip
CMake-d931ce9fe0c26cfddb766901cfd1ccbc9def71c7.tar.gz
CMake-d931ce9fe0c26cfddb766901cfd1ccbc9def71c7.tar.bz2
VS10: Generate relative source paths when possible (#12570)
Since commit ed0075bd (Use relative paths for custom command inputs, 2011-06-22) CMake generates full paths to source files in VS 10 project files to avoid trouble with deep source/build tree paths. However, the VS 10 IDE will not populate the source file property dialog for a file referenced by full path. Instead use a relative path when possible. When not possible produce a detailed warning explaining the problem and suggesting use of shorter directory paths.
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f8e4c30..9a97ab0 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -765,12 +765,23 @@ void cmVisualStudio10TargetGenerator::WriteSource(
// 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())
+ // relative path but to allow deeper build trees CMake 2.8.[5678] used a
+ // full path except for custom commands. Custom commands do not work
+ // without a relative path, but they do not seem to be involved in tools
+ // with the above behavior. For other sources we now use a relative path
+ // when the combined path will not be too long so property pages appear.
+ std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true);
+ size_t const maxLen = 250;
+ if(sf->GetCustomCommand() ||
+ ((strlen(this->Makefile->GetCurrentOutputDirectory()) + 1 +
+ sourceRel.length()) <= maxLen))
{
forceRelative = true;
- sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative);
+ sourceFile = sourceRel;
+ }
+ else
+ {
+ this->GlobalGenerator->PathTooLong(this->Target, sf, sourceRel);
}
}
this->ConvertToWindowsSlash(sourceFile);