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}") katie_warning("All-in-one build not yet support for: ${FORTARGET}")
set(${FORTARGET}_SOURCES ${resourcesdep} ${ARGN} PARENT_SCOPE) set(${FORTARGET}_SOURCES ${resourcesdep} ${ARGN} PARENT_SCOPE)
else() 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(allinonesource "${CMAKE_CURRENT_BINARY_DIR}/${FORTARGET}_allinone.cpp")
set(allinonedata) set(allinonedata)
foreach(srcstring ${ARGN}) foreach(srcstring ${ARGN})
@ -199,7 +202,8 @@ function(KATIE_SETUP_TARGET FORTARGET)
set(allinonedata "${allinonedata}#include \"${srcstring}\"\n") set(allinonedata "${allinonedata}#include \"${srcstring}\"\n")
endif() endif()
endforeach() endforeach()
file(WRITE ${allinonesource} "${allinonedata}") file(WRITE "${allinonetemp}" "${allinonedata}")
configure_file("${allinonetemp}" "${allinonesource}")
set(${FORTARGET}_SOURCES ${resourcesdep} ${allinonesource} PARENT_SCOPE) set(${FORTARGET}_SOURCES ${resourcesdep} ${allinonesource} PARENT_SCOPE)
endif() endif()
endfunction() endfunction()