[cmake-developers] Visual Studio dependencies bug work-around

Robert Goulet Robert.Goulet at autodesk.com
Thu Apr 16 10:00:45 EDT 2015


Ok. We actually wanted to launch our builds using CMake, since that was pretty convenient. I'd like to find a work-around to this... perhaps enabling the INSTALL project in the solution. Would it make sense, in your opinion, to have a cmake variable that once set, will add the INSTALL project in the solution's list of projects to build? That way if I try to call "msbuild solution.sln /t:install" it should work? If you agree then I can do the change in the cmake source. Let me know. Thanks!


-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 
Sent: Wednesday, April 15, 2015 2:05 PM
To: Robert Goulet
Cc: cmake-developers at cmake.org
Subject: Re: [cmake-developers] Visual Studio dependencies bug work-around

On 04/15/2015 12:31 PM, Robert Goulet wrote:
> defined EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1 on Bar
[snip]
> All seems to work from within Visual Studio

Yes, that property is documented to work only for the "Build Solution"
button in the IDE.  The IDE has knowledge of dependencies written in the .sln files.  MSBuild uses the ProjectReferences settings in the individual .vcxproj files if it doesn't load the .sln.

> Visual Studio doesn't seems to support dependencies by configuration.

AFAIK the IDE doesn't.  I just checked and MSBuild does support a Condition="..." attribute on each ProjectReferences element that can be used to make it per-config, but the IDE has no way to set this through its interface.

It is also a CMake limitation in that our target dependency graph is not represented with the configuration as a parameter.  The cmComputeTargetDepends::CollectTargetDepends method computes a union of the dependencies required by each configuration.  It may be non-trivial to add such a parameter and move the union later to generators for build systems that do not support per-config inter-target dependencies.

> msbuild.exe foo.sln /t:INSTALL /p:Configuration=Release ...didn't work 
> because INSTALL is never part of any targets in the solution

Yes, msbuild refuses to recognize targets not marked as part of the default build in the solution.  One has to build INSTALL.vcxproj directory to install with msbuild, and that of course runs into the above problem.

I was able to get a command-line build to work using devenv:

 devenv foo.sln /build Release /project INSTALL

-Brad


More information about the cmake-developers mailing list