From 32e3933355e501a75bdc8229503b98f4ecdec2c4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 5 Aug 2020 00:51:08 +0200 Subject: [PATCH] CMake: stop clobbering config files When CMake runs, configure_file() will clobber the config files in the build/ directory, which is annoying during testing: you need to keep making the same edits, or edit the source. - Introduce new behavior: the config file is **not** overwritten unless the source file is newer. This means that edits to config files in the build directory are preserved. - If INSTALL_CONFIG is **on** then the files are clobbered anyway (the source is considered new regardless). --- CMakeModules/CalamaresAddPlugin.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeModules/CalamaresAddPlugin.cmake b/CMakeModules/CalamaresAddPlugin.cmake index 66536eda7..ee3c63acb 100644 --- a/CMakeModules/CalamaresAddPlugin.cmake +++ b/CMakeModules/CalamaresAddPlugin.cmake @@ -187,13 +187,22 @@ function( calamares_add_plugin ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE} DESTINATION ${PLUGIN_DESTINATION} ) + set( _warned_config OFF ) foreach( PLUGIN_CONFIG_FILE ${PLUGIN_CONFIG_FILES} ) - configure_file( ${PLUGIN_CONFIG_FILE} ${PLUGIN_CONFIG_FILE} COPYONLY ) + if( ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_CONFIG_FILE} IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} OR INSTALL_CONFIG ) + configure_file( ${PLUGIN_CONFIG_FILE} ${PLUGIN_CONFIG_FILE} COPYONLY ) + else() + message( " ${BoldYellow}Not updating${ColorReset} ${PLUGIN_CONFIG_FILE}" ) + set( _warned_config ON ) + endif() if ( INSTALL_CONFIG ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} DESTINATION ${PLUGIN_DATA_DESTINATION} ) endif() endforeach() + if ( _warned_config ) + message( "" ) + endif() endif() endfunction()