cmake: only update config_headers.h if contents changed.

Generate to a temporary location and avoid touching the original file
if it's unchanged. This way we play nicer with build system that
regenerate objects based on file timestamps.
This commit is contained in:
Gustavo Sverzut Barbieri 2017-01-23 14:33:30 -02:00 committed by Marcel Hollerbach
parent fe7a21170c
commit e36a444c54
1 changed files with 16 additions and 2 deletions

View File

@ -77,5 +77,19 @@ HEADER_CHECK(libunwind.h HAVE_UNWIND)
HEADER_CHECK(mtrace.h HAVE_MTRACE_H)
function(EFL_HEADER_CHECKS_FINALIZE file)
file(WRITE ${file} ${HEADER_FILE_CONTENT})
endfunction()
file(WRITE ${file}.new ${HEADER_FILE_CONTENT})
if (NOT EXISTS ${file})
file(RENAME ${file}.new ${file})
message(STATUS "${file} was generated.")
else()
file(MD5 ${file}.new _new_md5)
file(MD5 ${file} _old_md5)
if(_new_md5 STREQUAL _old_md5)
message(STATUS "${file} is unchanged.")
else()
file(REMOVE ${file})
file(RENAME ${file}.new ${file})
message(STATUS "${file} was updated.")
endif()
endif()
endfunction()