From e36a444c541d5dd47857321dd55bae5e1bdf51c9 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Mon, 23 Jan 2017 14:33:30 -0200 Subject: [PATCH] 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. --- cmake/helpers/CommonHeaderChecks.cmake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmake/helpers/CommonHeaderChecks.cmake b/cmake/helpers/CommonHeaderChecks.cmake index ac7dba8dff..a92dabd9b7 100644 --- a/cmake/helpers/CommonHeaderChecks.cmake +++ b/cmake/helpers/CommonHeaderChecks.cmake @@ -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() \ No newline at end of file + 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()