​After much deliberation, I was never successful in getting a synthetic target to work as expected. The dilemma is that `add_custom_command` cannot specify both `TARGET` and `OUTPUT`, the work flow was something like
add_custom_target(resource-dependency) add_custom_command(TARGET resource-dependency ... PRE_BUILD) add_custom_command(OUTPUT <files that are generated> DEPENDS resource-dependency) ... add_library(actual-obj-library OBJECt <files that are generated> ... others ...) add_dependencies(actual-obj-library resource-dependency) I'm sure that's a flawed approach, but in the end I realized I can actually generate these files at *configure* time <3 The add_custom_command was just a call to ${CMAKE_COMMAND} ... resources/bin2c.cmake. So in the end, it's actually a lot cleaner for us to just include(resources/bin2c.cmake). I doubt this solution will be widely applicable to many projects, but if you ever find yourself in a situation where you are doing add_custom_command, where the custom command is calling ${CMAKE_COMMAND}, don't rely on PRE_BUILD because it's not a guarantee. If you can, just execute the script at configure time via an include(...) call.
-- 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: https://cmake.org/mailman/listinfo/cmake