<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>I haven't tried it out but I'm not exactly surprised it wouldn't work with Visual Studio 2017.</div><div><br></div><div>It seems to be similar to the issue mentioned here:<br></div><div><a href="https://stackoverflow.com/q/54557801/1028434">https://stackoverflow.com/q/54557801/1028434</a></div><div><br></div><div>The problem I noticed in the case of the StackOverflow question, "add_custom_target(testcmake2 ALL)" doesn't have a "command" so it doesn't generate an output.</div><div><br></div></div><div>When performing a build Visual Studio prints a message like "all outputs up to date" and skips over it.  So any associated custom commands with the target are never run.</div><div>Adding a "command" that is even an echo, like add_custom_target(testcmake1 COMMAND ${CMAKE_COMMAND} -E echo "Running testcmake1 step 1"), and the problem goes away.</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 8, 2019 at 6:08 PM Timothy Wrona <<a href="mailto:tjwrona1992@gmail.com">tjwrona1992@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>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.</div><div><br></div><div>The source code for these example can be found here: <a href="https://github.com/dev-cafe/cmake-cookbook" target="_blank">https://github.com/dev-cafe/cmake-cookbook</a></div><div><br></div><div>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.</div><div><br></div><div>For specific instructions to reproduce the issue, see this bug report I opened for the example in the book: <a href="https://github.com/dev-cafe/cmake-cookbook/issues/506" target="_blank">https://github.com/dev-cafe/cmake-cookbook/issues/506</a></div><div><br></div><div>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.</div><div><br></div><div>System info:</div><div>CMake version 3.13.3</div><div>Windows 10</div><div>Visual Studio 2017</div></div></div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake-developers" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake-developers</a><br>
</blockquote></div>