[CMake] Build tool mode with MSBuild not ignoring targets excluded from default

Kim Kryger kimberly.kryger at gmail.com
Thu May 4 19:56:42 EDT 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170504/4cd24119/attachment-0001.html>


More information about the CMake mailing list