Skip to content

Commit 5f80de5

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 5f80de5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ 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(GENERATE OUTPUT "${COMMON_HEADER}" CONTENT "${GENERATED_CONTENT}")
159159
list(APPEND kdchart_HEADERS "${COMMON_HEADER}")
160-
configure_file("${COMMON_HEADER}" "${COMMON_HEADER}.h" COPYONLY)
160+
file(GENERATE OUTPUT "${COMMON_HEADER}.h" CONTENT "${GENERATED_CONTENT}")
161161
list(APPEND kdchart_HEADERS "${COMMON_HEADER}.h")
162162

163163
ecm_generate_headers(

0 commit comments

Comments
 (0)