[cmake-developers] Possible Bug With "add_custom_command()" and the Visual Studio Generator for CMake

Timothy Wrona tjwrona1992 at gmail.com
Fri Feb 8 18:08:10 EST 2019


I have been following the examples in the "CMake Cookbook" by Radovan Bast
and Roberto Di Remigio and came across one example that doesn't appear to
work right on Windows.

The source code for these example can be found here:
https://github.com/dev-cafe/cmake-cookbook

Chapter-06/Recipe-07 is supposed to update the Git commit hash referenced
by the version header file every time the project is built. According to
the book, "add_custom_command()" is supposed to execute on every build
regardless of whether any files are changed. This example seems to work
correctly in a Linux environment, but not in Windows with the Visual Studio
Generator. When a new commit is created (an empty commit created with "git
commit --allow-empty") the custom command is never called and the commit
hash is not updated correctly.

For specific instructions to reproduce the issue, see this bug report I
opened for the example in the book:
https://github.com/dev-cafe/cmake-cookbook/issues/506

I assumed this was an issue with the example, but it looks like the Visual
Studio Generator may not be handling "add_custom_command()" correctly and
may be the source of the problem.

System info:
CMake version 3.13.3
Windows 10
Visual Studio 2017
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20190208/2d8fc3ec/attachment.html>


More information about the cmake-developers mailing list