Skip to content

Commit 4fb6b4a

Browse files
committed
Finally fix spurious recompilations of KDChart-based apps
ninja was seeing KDChart.tmp as a dependency of KDChart, so the timestamp modification of KDChart.tmp (on each cmake run) would still lead to a full rebuild of everything using the KDChart header. Fixed by using file(GENERATE) which is the proper CMake API for this.
1 parent 73620df commit 4fb6b4a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,24 @@ ecm_generate_headers(
148148
)
149149
# Combine required headers into 1 big convenience header
150150
set(COMMON_HEADER ${CMAKE_CURRENT_BINARY_DIR}/KDChart/KDChart)
151-
# (use a tmp file and configure_file to avoid touching the header unnecessarily)
152-
set(COMMON_HEADER_TMP ${COMMON_HEADER}.tmp)
153-
file(WRITE ${COMMON_HEADER_TMP} "// convenience header\n")
151+
152+
set(GENERATED_CONTENT "// convenience header\n")
154153
foreach(_header ${kdchart_HEADERS})
155154
get_filename_component(_base ${_header} NAME)
156-
file(APPEND ${COMMON_HEADER_TMP} "#include \"${_base}\"\n")
155+
string(APPEND GENERATED_CONTENT "#include \"${_base}\"\n")
157156
endforeach()
158-
configure_file("${COMMON_HEADER_TMP}" "${COMMON_HEADER}" COPYONLY)
157+
158+
file(
159+
GENERATE
160+
OUTPUT "${COMMON_HEADER}"
161+
CONTENT "${GENERATED_CONTENT}"
162+
)
159163
list(APPEND kdchart_HEADERS "${COMMON_HEADER}")
160-
configure_file("${COMMON_HEADER}" "${COMMON_HEADER}.h" COPYONLY)
164+
file(
165+
GENERATE
166+
OUTPUT "${COMMON_HEADER}.h"
167+
CONTENT "${GENERATED_CONTENT}"
168+
)
161169
list(APPEND kdchart_HEADERS "${COMMON_HEADER}.h")
162170

163171
ecm_generate_headers(

0 commit comments

Comments
 (0)