Build tool mode with MSBuild not ignoring targets excluded from default

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Build tool mode with MSBuild not ignoring targets excluded from default

Kim Kryger
Hello all,
I am using the Build Tool Mode in CMake 3.7.1 to build INSTALL targets in a MSVC11 build folder. According to the documentation (and the output from MSBuild), it should be building 'default targets' only, but it doesn't specify what that means exactly.

The command I am running:
cmake.exe --build vc110 --target INSTALL --config Release_mdd

This is building every single target in the solution, even if they have been turned off by EXCLUDE_FROM_DEFAULT_BUILD, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>, or even EXCLUDE_FROM_ALL. Seemingly the only way I can prevent the excluded project from being built is to remove the target as a dependency on other targets, or invoke MSBuild with the solution file directly, which isn't very cross-platform friendly, and I'd prefer to utilize CMake's knowledge of the build tools than write my own MSBuild finder. 


More information:
I have a runtime library and a plugin that is loaded in an executable. The runtime library is being built for multiple configurations (Release, Debug, Release_mdd, Debug_md), but the plugin is only supposed to build in Release and Debug. I have excluded the plugin from the default build:
SET( CMAKE_CONFIGURATION_TYPES "Release;Release_mdd;Debug;Debug_md" )
...
SET_TARGET_PROPERTIES( MyPlugin PROPERTIES
    EXCLUDE_FROM_DEFAULT_BUILD_RELEASE_MDD 1
    EXCLUDE_FROM_DEFAULT_BUILD_DEBUG_MD 1
)


I can call MSBuild with the solution file, and it correctly ignores the builds that are marked as excluded, but AFAIK CMake's build tool mode doesn't support this right now, I believe because of the usage of the References in ALL BUILD causes all referenced projects to be built, regardless of the solution configuration ('fixable' by using /p:BuildProjectReferences=false as an option to MSBuild)


Looking through the code (cmGlobalVisualStudio10Generator::GenerateBuildCommand), it seems I can 'spoof' it into using the sln and ignoring the ALL_BUILD vcxproj file completely if I specify 'clean' as the target, and then add /t:Build to the end of the command line. I'd rather not do this, as it doesn't remove the 'clean' option.

I guess my question is if the build tool mode is making assumptions about what file I want it to build with? 

As a workaround, is there an option to force it to use devenv for the time being?

Thanks,
Kim

--

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
Loading...