FOREACH(_unity_prefix ${_unity_prefixes})
SET(_unity_file_name "${CMAKE_CURRENT_BINARY_DIR}/${_unity_prefix}.cc")
+ SET(_tmp_unity_file_name "${CMAKE_CURRENT_BINARY_DIR}/${_unity_prefix}_tmp.cc")
+
#
# Note the CMake weirdness: _output_src is actually a string containing the
# variable name since we are in a macro...
${${_output_src}}
${_unity_file_name}
)
- FILE(WRITE "${_unity_file_name}"
+ FILE(WRITE "${_tmp_unity_file_name}"
"// This file was automatically generated by the deal.II CMake configuration as
// part of the unity build subsystem. Please do not edit this file directly;
// instead, make appropriate changes to the relevant CMakeLists.txt file.\n\n"
)
FOREACH(_unity_file ${${_unity_prefix}})
- FILE(APPEND "${_unity_file_name}" "#include \"${_unity_file}\"\n")
+ FILE(APPEND "${_tmp_unity_file_name}" "#include \"${_unity_file}\"\n")
ENDFOREACH()
+
+ #
+ # CMake regenerates all unity files as part of the configuration process,
+ # even though they usually have not changed. Avoid some recompilation by
+ # using the CONFIGURE_FILE command, which won't update the time stamp unless
+ # the content has changed.
+ #
+ CONFIGURE_FILE(${_tmp_unity_file_name} ${_unity_file_name} COPYONLY)
ENDFOREACH()
ENDMACRO()