Hi,

In our CMake setup, we currently have a dependency on a static library that is 
also part of the solution, but only when NOT building in Release. For clarity, 
let's call the application Foo, and the static lib Bar.

As such, we have defined EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1 on Bar cmake 
target properties. This work when using the solution from Visual Studio, we see 
that Bar is not selected for build in the properties of the solution in Release 
configuration. We also removed the link to Bar in the Foo cmake file, using 
generator expression target_link_library(Foo $<$<NOT:$<CONFIG:RELEASE>>:Bar>).

All seems to work from within Visual Studio, when we launch a Release build the 
Bar project is not built. However, when we launch a build from the command-line 
it does not work; it builds the Bar project. At first we thought it might be a 
cmake bug, but we can reproduce it using msbuild.exe command-line tool: It 
turns out this happens if we specify the target project to be built instead of 
the solution. In our case, we set the target project to be INSTALL.vcxproj 
generated by cmake.

We see that the dependency on Bar is still there when looking at the 
dependencies of Foo, which is ok because we need it in Debug, and that Visual 
Studio doesn't seems to support dependencies by configuration. When building 
from the command-line using msbuild.exe, if we tell it to build the solution 
instead of a specific project, it works as it should.

So now, my question is, has anyone experienced that before, and is there a 
work-around to this fail case? It seems to be a limitation of Visual Studio so 
I'm not sure what are my options.

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

It seems the only way to skip building Bar is to tell msbuild to build the 
solution instead of the specific project, but we NEED to build INSTALL in this 
case.
Any ideas?

-Robert Goulet
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to