panda3d/cmake/scripts/MakeComposite.cmake
Sam Edwards d66f5fa8e2 CMake: Kill support for <2.8.12
The rationale for this is in a comment at the top of the main
CMakeLists.txt file. It was getting harder to maintain support for a
version this old, and pretty much no current system has CMake <3.

Good riddance.
2018-02-06 14:47:12 -07:00

29 lines
930 B
CMake

# Filename: MakeComposite.cmake
#
# Description: When run, creates a single C++ file which includes multiple
# other C++ files, to help facilitate unity builds.
# Unity builds provide significantly increased compile speed.
#
# Usage:
# This script is invoked via add_custom_target, like this:
# cmake -P MakeComposite.cmake -D COMPOSITE_FILE="x_composite1.cxx" -D COMPOSITE_SOURCES="a.cxx b.cxx"
#
if(CMAKE_SCRIPT_MODE_FILE)
if(NOT DEFINED COMPOSITE_FILE)
message(FATAL_ERROR "COMPOSITE_FILE should be defined when running MakeComposite.cmake!")
return()
endif()
file(WRITE "${COMPOSITE_FILE}" "/* Generated by CMake. DO NOT EDIT. */\n")
separate_arguments(COMPOSITE_SOURCES)
foreach(source ${COMPOSITE_SOURCES})
file(APPEND "${COMPOSITE_FILE}" "#include \"${source}\"\n")
endforeach()
else()
message(SEND_ERROR "MakeComposite.cmake should not be included but run in script mode.")
endif()