I am written some custom scripts that are invoked in custom commands for CMake targets. I want the targets to be rebuilt if any of the scripts are updated (e.g. touch script.sh
). I have tried several variations using the DEPENDS argument, but nothing I have tried works.
Here is a simplified version what I have:
function(run_my_special_rule target)
set (script_to_run ${CMAKE_SOURCE_DIR}/scripts/script.sh)
add_custom_command(
TARGET ${target} PRE_BUILD
COMMAND find ${CMAKE_CURRENT_SOURCE_DIR} -name "*.hpp" -exec ${script_to_run} {} +
DEPENDS ${script_to_run}
)
endfunction()