From f34686f07e97d31846c9cbc7ccb65beff7235ca2 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 24 Dec 2024 19:17:24 +0100 Subject: [PATCH] Avoid touching the "KDChart" forwarding header at every CMake run This led to unnecessary recompilations in projects using KDChart as a submodule. --- src/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9de77583..3da1ead7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,11 +148,14 @@ ecm_generate_headers( ) # Combine required headers into 1 big convenience header set(COMMON_HEADER ${CMAKE_CURRENT_BINARY_DIR}/KDChart/KDChart) -file(WRITE ${COMMON_HEADER} "// convenience header\n") +# (use a tmp file and configure_file to avoid touching the header unnecessarily) +set(COMMON_HEADER_TMP ${COMMON_HEADER}.tmp) +file(WRITE ${COMMON_HEADER_TMP} "// convenience header\n") foreach(_header ${kdchart_HEADERS}) get_filename_component(_base ${_header} NAME) - file(APPEND ${COMMON_HEADER} "#include \"${_base}\"\n") + file(APPEND ${COMMON_HEADER_TMP} "#include \"${_base}\"\n") endforeach() +configure_file("${COMMON_HEADER_TMP}" "${COMMON_HEADER}" COPYONLY) list(APPEND kdchart_HEADERS "${COMMON_HEADER}") configure_file("${COMMON_HEADER}" "${COMMON_HEADER}.h" COPYONLY) list(APPEND kdchart_HEADERS "${COMMON_HEADER}.h")