add_custom_target(target ALL) set_target_properties(target PROPERTIES COMPILE_DEFINITIONS "touched" COMPILE_OPTIONS "${CMAKE_BINARY_DIR}/wdir") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/wdir") add_custom_command( TARGET target POST_BUILD COMMAND ${CMAKE_COMMAND} -E touch $ WORKING_DIRECTORY $ )