[CMake] write file if different?
Matthew Woehlke
matthew.woehlke at kitware.com
Mon Jun 3 17:39:54 EDT 2013
On 2013-05-28 16:07, Matthew Woehlke wrote:
> Is there a built-in way to write a string to a file (a la FILE(WRITE))
> that will only write the file if the content would be different? (Or
> does FILE(WRITE) already work this way despite no obvious hint in the
> documentation that it does?)
>
> Right now I am writing to a temporary file and running cmake -E
> copy_if_different, then removing the temporary file, but this seems
> inelegant and I am wondering if there is a better solution.
Not strictly "built-in", but it looks like the best way is:
set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CONTENT}")
configure_file(
"${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
"${PATH}" @ONLY
)
--
Matthew
More information about the CMake
mailing list