[cmake-developers] Automatic project generation with Visual Studio generators

Yves Frederix yves.frederix+cmake at gmail.com
Wed Sep 14 11:25:52 EDT 2016


Hi all,

At work we recently switched from source globbing to explicit source
listing, which should in theory remove the need for manually having to
run CMake. It turns out, however, that for Visual Studio generators,
this is not really the case.

As far as I understand, the logic behind automatic project
regeneration is controlled by the ZERO_CHECK target on which all other
targets depend and which reruns CMake when necessary. However, this
reconfiguration is triggered from inside a running msbuild, which then
in turn is not stopped or restarted and does not pick up the updated
project files, causing the running build to be out-of-date. This is
known behavior, see, e.g.,
http://cmake.3232098.n2.nabble.com/MSBuild-and-automatic-project-file-regenation-td7166716.html
and arguably a problem with msbuild rather than with CMake.

There are currently two use cases in which one runs into problems:
- When using "cmake --build . ".
- When building from the VS IDE.

I would like to propose a small change that would at least improve
things already for the first use case. The idea is to change the
actual (native) build command (which builds a single target) and
replace it by sequentially running two almost identical msbuild
commands: first targeting ZERO_CHECK and then targeting whatever
target the user requested, picking up any changes to the project
files. I am attaching a patch to illustrate what this could look like.
If there is interest in this patch, I will gladly clean it up a bit.

Thanks.

Regards,
Yves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-When-building-using-cmake-build-which-natively-uses-.patch
Type: application/octet-stream
Size: 9286 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160914/e681182c/attachment-0001.obj>


More information about the cmake-developers mailing list