Hi, I'm almost certain this is a bug but I thought I'd ask the mailing lists first.
I'm observing a problem with CMake's add_custom_command() when using the TARGET version of the signature. Code demonstrating the issue can be found at [1] In ``test/CMakeLists.txt`` [2] I try using add_custom_command() to build and run an executable every time the ``foolib`` library is rebuilt. The motivation behind doing this is to have some very quick and simple library tests run every time the library is built. This use of add_custom_command() does not seem to work at all. Using CMake 2.8.12.2 the requested command is not invoked when running ``make foolib``. I am aware that the custom command won't run if ``foolib`` has already been made but even if I do a clean build the custom command specified does not run. When using CMake 3.2.3 I get a warning about CMP0040 which complains that the target passed to the TARGET argument in ``add_custom_command()`` doesn't exist. ``` Policy CMP0040 is not set: The target in the TARGET signature of add_custom_command() must exist. Run "cmake --help-policy CMP0040" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The target name "foolib" is unknown in this context. This warning is for project developers. Use -Wno-dev to suppress it ``` This doesn't make sense the target **clearly exists and is in scope** because the ``simple_test`` executable links against it and also it is possible to read properties of the target. Seems like there's some sort of weird scope issue going on here. Thoughts? [1] https://github.com/delcypher/cmake_add_custom_command_bug [2] https://github.com/delcypher/cmake_add_custom_command_bug/blob/master/test/CMakeLists.txt Thanks, Dan Liew -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers