[CMake] getting a build parameter from a file
Dave Yost
Dave at Yost.com
Tue Jun 9 01:05:53 EDT 2015
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 <http://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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150608/c57583ca/attachment-0001.html>
More information about the CMake
mailing list