summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtPlugins.cmake.in22
1 files changed, 15 insertions, 7 deletions
diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in
index d6d5c829b2..c901f8c47d 100644
--- a/cmake/QtPlugins.cmake.in
+++ b/cmake/QtPlugins.cmake.in
@@ -119,15 +119,23 @@ if(NOT @BUILD_SHARED_LIBS@)
set(_generated_qt_plugin_file_name
"${CMAKE_CURRENT_BINARY_DIR}/qt_@QT_MODULE@_${target}.cpp")
- set(_generated_qt_plugin_file_name_template "${_generated_qt_plugin_file_name}.in")
set(_generated_qt_plugin_file_content "#include <QtPlugin>\nQ_IMPORT_PLUGIN(${_classname})")
- # Generate a source file to import that plug-in. Has to be done with configure_file,
- # because file(GENERATE) and target_sources has issues with scopes.
- file(WRITE "${_generated_qt_plugin_file_name_template}"
- "${_generated_qt_plugin_file_content}")
- configure_file("${_generated_qt_plugin_file_name_template}"
- "${_generated_qt_plugin_file_name}")
+ # Generate a source file to import that plug-in. Be careful not to
+ # update the timestamp of the generated file if we are not going to
+ # change anything. Otherwise we will trigger CMake's autogen to re-run
+ # and executables will then need to at least relink.
+ set(need_write TRUE)
+ if(EXISTS ${_generated_qt_plugin_file_name})
+ file(READ ${_generated_qt_plugin_file_name} old_contents)
+ if(old_contents STREQUAL "${_generated_qt_plugin_file_content}")
+ set(need_write FALSE)
+ endif()
+ endif()
+ if(need_write)
+ file(WRITE "${_generated_qt_plugin_file_name}"
+ "${_generated_qt_plugin_file_content}")
+ endif()
target_sources(${_module_target} INTERFACE
"$<${_plugin_condition}:${_generated_qt_plugin_file_name}>")