summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.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/cmGlobalVisualStudio10Generator.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/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 28d738a..18a786d 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -13,6 +13,7 @@
#include "cmGlobalVisualStudio10Generator.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
+#include "cmSourceFile.h"
#include "cmake.h"
@@ -51,6 +52,38 @@ cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
}
//----------------------------------------------------------------------------
+void cmGlobalVisualStudio10Generator::Generate()
+{
+ this->LongestSource = LongestSourcePath();
+ this->cmGlobalVisualStudio8Generator::Generate();
+ if(this->LongestSource.Length > 0)
+ {
+ cmMakefile* mf = this->LongestSource.Target->GetMakefile();
+ cmOStringStream e;
+ e <<
+ "The binary and/or source directory paths may be too long to generate "
+ "Visual Studio 10 files for this project. "
+ "Consider choosing shorter directory names to build this project with "
+ "Visual Studio 10. "
+ "A more detailed explanation follows."
+ "\n"
+ "There is a bug in the VS 10 IDE that renders property dialog fields "
+ "blank for files referenced by full path in the project file. "
+ "However, CMake must reference at least one file by full path:\n"
+ " " << this->LongestSource.SourceFile->GetFullPath() << "\n"
+ "This is because some Visual Studio tools would append the relative "
+ "path to the end of the referencing directory path, as in:\n"
+ " " << mf->GetCurrentOutputDirectory() << "/"
+ << this->LongestSource.SourceRel << "\n"
+ "and then incorrectly complain that the file does not exist because "
+ "the path length is too long for some internal buffer or API. "
+ "To avoid this problem CMake must use a full path for this file "
+ "which then triggers the VS 10 property dialog bug.";
+ mf->IssueMessage(cmake::WARNING, e.str().c_str());
+ }
+}
+
+//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator
::GetDocumentation(cmDocumentationEntry& entry) const
{
@@ -230,3 +263,18 @@ cmGlobalVisualStudio10Generator
ruleFile += ".rule";
return ruleFile;
}
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio10Generator::PathTooLong(
+ cmTarget* target, cmSourceFile* sf, std::string const& sfRel)
+{
+ size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) +
+ 1 + sfRel.length());
+ if(len > this->LongestSource.Length)
+ {
+ this->LongestSource.Length = len;
+ this->LongestSource.Target = target;
+ this->LongestSource.SourceFile = sf;
+ this->LongestSource.SourceRel = sfRel;
+ }
+}