[CMake] MSBuild and automatic project file regenation

Michael Hertling mhertling at online.de
Mon Jan 9 21:43:46 EST 2012


On 01/09/2012 07:56 PM, Óscar Fuentes wrote:
> Michael Hertling <mhertling at online.de>
> writes:
> 
>> On 01/09/2012 02:34 PM, David Cole wrote:
>>> No trick, but to avoid this, perhaps we should change the "--build"
>>> handler to run the cmake configure & generate step before calling out
>>> to MSBuild. You can easily do this yourself from the command line by
>>> adopting the pattern:
>>>
>>>   cmake . && cmake --build . --config Release
> 
> Fortunately my cmake scripts are simple enough so the extra invocation
> does not add much to the build.
> 
> Thanks David.
> 
>>> This is a good idea for a feature request. Not sure if we should just
>>> always do that by default and provide a way to turn off with a
>>> "--no-regenerate", or vice-versa with a "--please-generate-first" ...
>>> :-)
> 
> The effect of --no-regenerate would be the same as the current buggy
> behavior (MSBuild.exe uses outdated project files). IMHO the
> --please-generate-first is the right thing.
> 
>> Just out of curiosity: In [1], item (1), I reported on the fact that
>> one can modify a project's CMakeLists.txt, and "cmake --build" will
>> reconfigure/regenerate, but not rebuild. Is this the same issue the
>> OP asks about?
> 
> No.

But aren't the issues related at least? If I understand
correctly, "cmake --build" invokes MSBuild which

- loads the solution file and the project files,
- reinvokes CMake via the ZERO_CHECK project/target
  to regenerate them if CMakeLists.txt has been modified,
- does *not* use the regenerated ones for building, so the
  affected projects/targets are left inherently out-of-date.

Moreover, even an additional subsequent "cmake --build" command doesn't
rebuild; in fact, it does nothing, as though there is no dependency of
a project/target on its own project file. AFAICS for now, it's solely
David's hint, i.e. "cmake . && cmake --build .", that results in the
project being actually rebuilt after CMakeLists.txt has changed,
unless one uses the "--clean-first" option.

>> If so, I would strongly support a feature request in
>> this respect since, IMO, it's actually quite confusing that CMake's
>> "--build" command does anything but rebuilding.
> 
> I agree.

Do you file a feature request / bug report? Personally, I'd like to be
sure that after a "cmake --build" command, everything is up-to-date as
it is with Makefiles, provided it can be realized with MSBuild at all.

>> [1] http://www.mail-archive.com/cmake@cmake.org/msg39596.html
> 
> This returns 404.

Try <http://www.cmake.org/pipermail/cmake/2011-November/047802.html>.

Regards,

Michael


More information about the CMake mailing list