avoid unneccessary rebuild of all-in-one targets upon project re-configuration

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2017-05-09 07:46:51 +00:00
parent 692bdb0788
commit 99ab64cf7f

View file

@ -191,6 +191,9 @@ function(KATIE_SETUP_TARGET FORTARGET)
katie_warning("All-in-one build not yet support for: ${FORTARGET}")
set(${FORTARGET}_SOURCES ${resourcesdep} ${ARGN} PARENT_SCOPE)
else()
# use temporary file, then configure_file() to avoid all-in-one target rebuilds when the
# project is reconfigured
set(allinonetemp "${CMAKE_CURRENT_BINARY_DIR}/allinone_temporary.cpp")
set(allinonesource "${CMAKE_CURRENT_BINARY_DIR}/${FORTARGET}_allinone.cpp")
set(allinonedata)
foreach(srcstring ${ARGN})
@ -199,7 +202,8 @@ function(KATIE_SETUP_TARGET FORTARGET)
set(allinonedata "${allinonedata}#include \"${srcstring}\"\n")
endif()
endforeach()
file(WRITE ${allinonesource} "${allinonedata}")
file(WRITE "${allinonetemp}" "${allinonedata}")
configure_file("${allinonetemp}" "${allinonesource}")
set(${FORTARGET}_SOURCES ${resourcesdep} ${allinonesource} PARENT_SCOPE)
endif()
endfunction()