[cmake-developers] Bug in Visual Studio generators

Josh Green inbilla at gmail.com
Thu Apr 10 20:23:00 EDT 2014


Hi Brad,

Thanks for your explanations, they're interesting. I appreciate this
is a complex system :)

Regarding:
> The current logic (produced by commit range a7d0fb14..d931ce9f) is:
>
>  http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmVisualStudio10TargetGenerator.cxx;hb=v3.0.0-rc3#l939
>
> and does use full paths when necessary to fit under the character
> limit, but only as part of the VS 10 special case.  Perhaps we need
> a code path there for other VS versions to check the character limit
> too.

I don't think that is quite correct.
Looking at the link you sent, perhaps you meant to supply a different
one, but the code there isn't about solving this problem for Vs10, it
is about solving a different problem.
The special case for Vs10 there is about detecting if we are under
Vs10, and the current file is currently represented by an absolute
path (which it won't be in this case) then under Vs10 we attempt to
create a relative path for all cases where it would be achievable
under the 260 character limit. This attempts to get around a problem
with property sheets not working (because in vs10 property sheets
don't work if you use absolute paths, so if you can use them, you
should - and that is what that code attempts to do, assuming the line
above it generates an absolute path).

My understanding of the code there is that under the situation of
build tree inside source tree, even under VS10, the path generated by
the first active line of that code:
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
will still always generate a relative path (and hence cause issues for
the 260 character limit).

I think the solution here may actually be to change that line to:
std::string sourceFile = sf->GetFullPath();

This means that outputing source files for visual studio would be
absolute paths, unless they are able to be modified by that Vs10
special case to relative (to fix a completely different issue with
VS).
If you want to make all visual studio generators output relative paths
when possible (under the 260 limit) then you could simply remove the
vs10 special case from the following if statement. Infact, you could
remove the if entirely, because the other check to see if it is a full
path will always be true then.

The GlobalGenerator->PathTooLong call would then need to be protected
by the vs10 guard, because that only needs to show up in vs10
(currently it shows up whenever a path can't be made relative in
vs10).

What do you think?

Thanks

Josh



More information about the cmake-developers mailing list