Skip to content

Commit

Permalink
Avoid touching the "KDChart" forwarding header at every CMake run
Browse files Browse the repository at this point in the history
This led to unnecessary recompilations in projects using
KDChart as a submodule.
  • Loading branch information
dfaure-kdab committed Dec 24, 2024
1 parent d8274f6 commit f34686f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f34686f

Please sign in to comment.