mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Make use of precompiled header configureable
This commit is contained in:
parent
a7c6f4973b
commit
cf6bb39e11
2 changed files with 99 additions and 78 deletions
|
@ -8,6 +8,9 @@ option(USE_MFC_TOOLS
|
|||
|
||||
option(MONOLITH
|
||||
"Embed game logic into main executable" ON)
|
||||
|
||||
option(USE_PRECOMPILED_HEADERS
|
||||
"Use precompiled headers during build" ON)
|
||||
|
||||
option(SDL2
|
||||
"Use SDL2 instead of SDL1.2" ON)
|
||||
|
@ -1347,33 +1350,35 @@ if(MSVC)
|
|||
|
||||
list(REMOVE_DUPLICATES RBDOOM3_SOURCES)
|
||||
|
||||
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/dynamicshadowvolume/DynamicShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/prelightshadowvolume/PreLightShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/staticshadowvolume/StaticShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/ShadowShared.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/RenderLog.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/framework/precompiled.cpp)
|
||||
|
||||
if(USE_PRECOMPILED_HEADERS)
|
||||
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/dynamicshadowvolume/DynamicShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/prelightshadowvolume/PreLightShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/staticshadowvolume/StaticShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/ShadowShared.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/RenderLog.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/framework/precompiled.cpp)
|
||||
|
||||
set_source_files_properties(
|
||||
${RBDOOM3_PRECOMPILED_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Yuprecompiled.h"
|
||||
OBJECT_DEPENDS "precompiled.pch"
|
||||
|
||||
)
|
||||
|
||||
set_source_files_properties(framework/precompiled.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Ycprecompiled.h"
|
||||
OBJECT_OUTPUTS "precompiled.pch"
|
||||
)
|
||||
set_source_files_properties(
|
||||
${RBDOOM3_PRECOMPILED_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Yuprecompiled.h"
|
||||
OBJECT_DEPENDS "precompiled.pch"
|
||||
|
||||
)
|
||||
|
||||
set_source_files_properties(framework/precompiled.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Ycprecompiled.h"
|
||||
OBJECT_OUTPUTS "precompiled.pch"
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND RBDOOM3_SOURCES ${WIN32_RESOURCES})
|
||||
|
||||
|
@ -1479,73 +1484,81 @@ else()
|
|||
|
||||
list(REMOVE_DUPLICATES RBDOOM3_SOURCES)
|
||||
|
||||
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/dynamicshadowvolume/DynamicShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/prelightshadowvolume/PreLightShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/staticshadowvolume/StaticShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/ShadowShared.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/RenderLog.cpp)
|
||||
if(USE_PRECOMPILED_HEADERS)
|
||||
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/dynamicshadowvolume/DynamicShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/prelightshadowvolume/PreLightShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/staticshadowvolume/StaticShadowVolume.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/jobs/ShadowShared.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/RenderLog.cpp)
|
||||
|
||||
foreach( src_file ${RBDOOM3_PRECOMPILED_SOURCES} )
|
||||
#message(STATUS "-include precompiled.h for ${src_file}")
|
||||
set_source_files_properties(
|
||||
${src_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-include ${CMAKE_CURRENT_SOURCE_DIR}/idlib/precompiled.h"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# precompiled magic for GCC/clang, adapted from https://gist.github.com/573926
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(_compiler_FLAGS ${${_flags_var_name}})
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES)
|
||||
FOREACH(item ${_directory_flags})
|
||||
LIST(APPEND _compiler_FLAGS " -I${item}")
|
||||
ENDFOREACH(item)
|
||||
foreach( src_file ${RBDOOM3_PRECOMPILED_SOURCES} )
|
||||
#message(STATUS "-include precompiled.h for ${src_file}")
|
||||
set_source_files_properties(
|
||||
${src_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-include ${CMAKE_CURRENT_SOURCE_DIR}/idlib/precompiled.h"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# precompiled magic for GCC/clang, adapted from https://gist.github.com/573926
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(_compiler_FLAGS ${${_flags_var_name}})
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES)
|
||||
FOREACH(item ${_directory_flags})
|
||||
LIST(APPEND _compiler_FLAGS " -I${item}")
|
||||
ENDFOREACH(item)
|
||||
endif()
|
||||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
LIST(APPEND _compiler_FLAGS ${_directory_flags})
|
||||
SEPARATE_ARGUMENTS(_compiler_FLAGS)
|
||||
|
||||
# we need to recreate the precompiled header for RBDoom3BFG
|
||||
# (i.e. can't use the one created for idlib before)
|
||||
# because some definitions (e.g. -D__IDLIB__ -D__DOOM_DLL__) differ
|
||||
add_custom_target(precomp_header_rbdoom3bfg ALL
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${_compiler_FLAGS} -x c++-header idlib/precompiled.h -o idlib/precompiled.h.gch
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Creating idlib/precompiled.h.gch for RBDoom3BFG"
|
||||
)
|
||||
if(USE_PRECOMPILED_HEADERS)
|
||||
# we need to recreate the precompiled header for RBDoom3BFG
|
||||
# (i.e. can't use the one created for idlib before)
|
||||
# because some definitions (e.g. -D__IDLIB__ -D__DOOM_DLL__) differ
|
||||
add_custom_target(precomp_header_rbdoom3bfg ALL
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${_compiler_FLAGS} -x c++-header idlib/precompiled.h -o idlib/precompiled.h.gch
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Creating idlib/precompiled.h.gch for RBDoom3BFG"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(remove_command "del")
|
||||
else()
|
||||
set(remove_command "rm")
|
||||
endif()
|
||||
# it's ugly enough that the precompiled header binary needs to be in the
|
||||
# source directory (instead of the build directory), so let's at least
|
||||
# delete it after build.
|
||||
add_custom_target(rm_precomp_header ALL
|
||||
COMMAND ${remove_command} "idlib/precompiled.h.gch"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "remove idlib/precompiled.h.gch"
|
||||
)
|
||||
|
||||
# make sure this is run after creating idlib
|
||||
add_dependencies(precomp_header_rbdoom3bfg idlib)
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
# it's ugly enough that the precompiled header binary needs to be in the
|
||||
# source directory (instead of the build directory), so let's at least
|
||||
# delete it after build.
|
||||
add_custom_target(rm_precomp_header ALL
|
||||
COMMAND ${remove_command} "idlib/precompiled.h.gch"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "remove idlib/precompiled.h.gch"
|
||||
)
|
||||
|
||||
# make sure this is run after creating idlib
|
||||
add_dependencies(precomp_header_rbdoom3bfg idlib)
|
||||
endif()
|
||||
|
||||
add_executable(RBDoom3BFG WIN32 ${RBDOOM3_SOURCES})
|
||||
|
||||
# make sure precompiled header is created before executable is compiled
|
||||
add_dependencies(RBDoom3BFG precomp_header_rbdoom3bfg)
|
||||
|
||||
# make sure precompiled header is deleted after executable is compiled
|
||||
add_dependencies(rm_precomp_header RBDoom3BFG)
|
||||
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
# make sure precompiled header is created before executable is compiled
|
||||
add_dependencies(RBDoom3BFG precomp_header_rbdoom3bfg)
|
||||
|
||||
# make sure precompiled header is deleted after executable is compiled
|
||||
add_dependencies(rm_precomp_header RBDoom3BFG)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT "${CMAKE_SYSTEM}" MATCHES "Darwin")
|
||||
|
|
|
@ -101,6 +101,7 @@ if(MSVC)
|
|||
|
||||
add_library(idlib ${ID_SOURCES_ALL} ${ID_INCLUDES_ALL})
|
||||
else()
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
foreach( src_file ${ID_PRECOMPILED_SOURCES} )
|
||||
#message(STATUS "-include precompiled.h for ${src_file}")
|
||||
set_source_files_properties(
|
||||
|
@ -109,9 +110,11 @@ else()
|
|||
COMPILE_FLAGS "-include ${CMAKE_CURRENT_SOURCE_DIR}/precompiled.h"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
||||
include_directories(.)
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
# precompiled magic for GCC/clang, adapted from https://gist.github.com/573926
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(_compiler_FLAGS ${${_flags_var_name}})
|
||||
|
@ -119,20 +122,25 @@ else()
|
|||
FOREACH(item ${_directory_flags})
|
||||
LIST(APPEND _compiler_FLAGS " -I${item}")
|
||||
ENDFOREACH(item)
|
||||
endif()
|
||||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
LIST(APPEND _compiler_FLAGS ${_directory_flags})
|
||||
|
||||
SEPARATE_ARGUMENTS(_compiler_FLAGS)
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
add_custom_target(precomp_header_idlib ALL
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${_compiler_FLAGS} -x c++-header precompiled.h -o precompiled.h.gch
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Creating idlib/precompiled.h.gch for idlib"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(idlib ${ID_SOURCES_ALL} ${ID_INCLUDES_ALL})
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
add_dependencies(idlib precomp_header_idlib)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in a new issue