Why not just use configure_file to write ${metals} into the file...
configure_file only actually touches/writes-to/updates the file if the
contents are different...Then you can just depend on that file and you don't need a separate timestamp file. HTH, David C. On Tue, Jun 9, 2015 at 1:05 AM, Dave Yost <[email protected]> wrote: > > > First, my cmake code does this: > > sets ${metals} from a cmake command-line argument > compares the contents of ${metals} against the contents of a file to note > whether the variable is being changed since the last run of cmake > writes the new value to that file for next time > call an add_timestamp_file_target function. which touches the file > metalsTimestamp if the variable is being changed or if the file doesn’t > exist. > > Then comes this: > > set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMETALS=\"\\\"${metals}\\\"\"") > add_executable (metals metals.cc) > add_dependencies (metals metalsTimestamp) > > > My add_timestamp_file_target function has to use one of > add_custom_target > add_custom_command > to make metalsTimestamp visible to the add_dependencies function. > > Problem is, it seems that those commands have to touch the file every time > cmake runs, but I want to touch it only when necessary. > > Is there a way to make this work? > > > -- > > 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 -- 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
