mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 05:01:41 +00:00
- enable use of precompiled headers for MSVC. Thanks to a small CMake script I recently found this could be done non-invasively.
Due to the VC++ 2015 headers being rather bloated (the average include size per source is 400-500kb) this provides a noticable compile speedup, although right now this only covers the game code, so there should be more room for improvement.
This commit is contained in:
parent
12129b0f07
commit
9cc873ecdd
2 changed files with 71 additions and 29 deletions
34
precompiled_headers.cmake
Normal file
34
precompiled_headers.cmake
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#
|
||||||
|
# Christoph Heindl 2010
|
||||||
|
# Precompiled Headers Demo
|
||||||
|
# http://cheind.wordpress.com
|
||||||
|
#
|
||||||
|
|
||||||
|
# Instructs the MSVC toolset to use the precompiled header PRECOMPILED_HEADER
|
||||||
|
# for each source file given in the collection named by SOURCE_VARIABLE_NAME.
|
||||||
|
function(enable_precompiled_headers PRECOMPILED_HEADER SOURCE_VARIABLE_NAME)
|
||||||
|
if(MSVC)
|
||||||
|
set(files ${${SOURCE_VARIABLE_NAME}})
|
||||||
|
|
||||||
|
# Generate precompiled header translation unit
|
||||||
|
get_filename_component(pch_basename ${PRECOMPILED_HEADER} NAME_WE)
|
||||||
|
set(pch_abs ${CMAKE_CURRENT_SOURCE_DIR}/${PRECOMPILED_HEADER})
|
||||||
|
set(pch_unity ${CMAKE_CURRENT_BINARY_DIR}/${pch_basename}.cpp)
|
||||||
|
FILE(WRITE ${pch_unity} "// Precompiled header unity generated by CMake\n")
|
||||||
|
FILE(APPEND ${pch_unity} "#include <${pch_abs}>\n")
|
||||||
|
set_source_files_properties(${pch_unity} PROPERTIES COMPILE_FLAGS "/Yc\"${pch_abs}\"")
|
||||||
|
|
||||||
|
# Update properties of source files to use the precompiled header.
|
||||||
|
# Additionally, force the inclusion of the precompiled header at beginning of each source file.
|
||||||
|
foreach(source_file ${files} )
|
||||||
|
set_source_files_properties(
|
||||||
|
${source_file}
|
||||||
|
PROPERTIES COMPILE_FLAGS
|
||||||
|
"/Yu\"${pch_abs}\" /FI\"${pch_abs}\""
|
||||||
|
)
|
||||||
|
endforeach(source_file)
|
||||||
|
|
||||||
|
# Finally, update the source file collection to contain the precompiled header translation unit
|
||||||
|
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${pch_unity} PARENT_SCOPE)
|
||||||
|
endif(MSVC)
|
||||||
|
endfunction(enable_precompiled_headers)
|
|
@ -1,5 +1,7 @@
|
||||||
cmake_minimum_required( VERSION 2.8.7 )
|
cmake_minimum_required( VERSION 2.8.7 )
|
||||||
|
|
||||||
|
include(../precompiled_headers.cmake)
|
||||||
|
|
||||||
if( COMMAND cmake_policy )
|
if( COMMAND cmake_policy )
|
||||||
cmake_policy( SET CMP0003 NEW )
|
cmake_policy( SET CMP0003 NEW )
|
||||||
endif()
|
endif()
|
||||||
|
@ -959,15 +961,8 @@ set( FASTMATH_SOURCES
|
||||||
r_data/colormaps.cpp
|
r_data/colormaps.cpp
|
||||||
r_data/r_translate.cpp
|
r_data/r_translate.cpp
|
||||||
)
|
)
|
||||||
add_executable( zdoom WIN32 MACOSX_BUNDLE
|
|
||||||
${HEADER_FILES}
|
set (PCH_SOURCES
|
||||||
${NOT_COMPILED_SOURCE_FILES}
|
|
||||||
__autostart.cpp
|
|
||||||
${ASM_SOURCES}
|
|
||||||
${SYSTEM_SOURCES}
|
|
||||||
${X86_SOURCES}
|
|
||||||
${FASTMATH_SOURCES}
|
|
||||||
x86.cpp
|
|
||||||
actorptrselect.cpp
|
actorptrselect.cpp
|
||||||
am_map.cpp
|
am_map.cpp
|
||||||
b_bot.cpp
|
b_bot.cpp
|
||||||
|
@ -1028,7 +1023,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
m_misc.cpp
|
m_misc.cpp
|
||||||
m_png.cpp
|
m_png.cpp
|
||||||
m_random.cpp
|
m_random.cpp
|
||||||
m_specialpaths.cpp
|
|
||||||
memarena.cpp
|
memarena.cpp
|
||||||
md5.cpp
|
md5.cpp
|
||||||
name.cpp
|
name.cpp
|
||||||
|
@ -1090,7 +1084,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
statistics.cpp
|
statistics.cpp
|
||||||
stats.cpp
|
stats.cpp
|
||||||
stringtable.cpp
|
stringtable.cpp
|
||||||
strnatcmp.c
|
|
||||||
tables.cpp
|
tables.cpp
|
||||||
teaminfo.cpp
|
teaminfo.cpp
|
||||||
tempfiles.cpp
|
tempfiles.cpp
|
||||||
|
@ -1105,7 +1098,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
w_wad.cpp
|
w_wad.cpp
|
||||||
wi_stuff.cpp
|
wi_stuff.cpp
|
||||||
zstrformat.cpp
|
zstrformat.cpp
|
||||||
zstring.cpp
|
|
||||||
g_doom/a_doommisc.cpp
|
g_doom/a_doommisc.cpp
|
||||||
g_heretic/a_hereticmisc.cpp
|
g_heretic/a_hereticmisc.cpp
|
||||||
g_hexen/a_hexenmisc.cpp
|
g_hexen/a_hexenmisc.cpp
|
||||||
|
@ -1149,22 +1141,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
g_shared/sbar_mugshot.cpp
|
g_shared/sbar_mugshot.cpp
|
||||||
g_shared/shared_hud.cpp
|
g_shared/shared_hud.cpp
|
||||||
g_shared/shared_sbar.cpp
|
g_shared/shared_sbar.cpp
|
||||||
math/asin.c
|
|
||||||
math/atan.c
|
|
||||||
math/const.c
|
|
||||||
math/cosh.c
|
|
||||||
math/exp.c
|
|
||||||
math/isnan.c
|
|
||||||
math/log.c
|
|
||||||
math/log10.c
|
|
||||||
math/mtherr.c
|
|
||||||
math/polevl.c
|
|
||||||
math/sin.c
|
|
||||||
math/sinh.c
|
|
||||||
math/sqrt.c
|
|
||||||
math/tan.c
|
|
||||||
math/tanh.c
|
|
||||||
math/fastsin.cpp
|
|
||||||
resourcefiles/ancientzip.cpp
|
resourcefiles/ancientzip.cpp
|
||||||
resourcefiles/file_7z.cpp
|
resourcefiles/file_7z.cpp
|
||||||
resourcefiles/file_grp.cpp
|
resourcefiles/file_grp.cpp
|
||||||
|
@ -1175,7 +1151,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
resourcefiles/file_pak.cpp
|
resourcefiles/file_pak.cpp
|
||||||
resourcefiles/file_directory.cpp
|
resourcefiles/file_directory.cpp
|
||||||
resourcefiles/resourcefile.cpp
|
resourcefiles/resourcefile.cpp
|
||||||
sfmt/SFMT.cpp
|
|
||||||
textures/animations.cpp
|
textures/animations.cpp
|
||||||
textures/anim_switches.cpp
|
textures/anim_switches.cpp
|
||||||
textures/automaptexture.cpp
|
textures/automaptexture.cpp
|
||||||
|
@ -1228,6 +1203,39 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
zscript/zcc_compile.cpp
|
zscript/zcc_compile.cpp
|
||||||
zscript/zcc_expr.cpp
|
zscript/zcc_expr.cpp
|
||||||
zscript/zcc_parser.cpp
|
zscript/zcc_parser.cpp
|
||||||
|
)
|
||||||
|
enable_precompiled_headers( g_pch.h PCH_SOURCES )
|
||||||
|
|
||||||
|
add_executable( zdoom WIN32 MACOSX_BUNDLE
|
||||||
|
${HEADER_FILES}
|
||||||
|
${NOT_COMPILED_SOURCE_FILES}
|
||||||
|
__autostart.cpp
|
||||||
|
${ASM_SOURCES}
|
||||||
|
${SYSTEM_SOURCES}
|
||||||
|
${X86_SOURCES}
|
||||||
|
${FASTMATH_SOURCES}
|
||||||
|
${PCH_SOURCES}
|
||||||
|
x86.cpp
|
||||||
|
m_specialpaths.cpp
|
||||||
|
strnatcmp.c
|
||||||
|
zstring.cpp
|
||||||
|
math/asin.c
|
||||||
|
math/atan.c
|
||||||
|
math/const.c
|
||||||
|
math/cosh.c
|
||||||
|
math/exp.c
|
||||||
|
math/isnan.c
|
||||||
|
math/log.c
|
||||||
|
math/log10.c
|
||||||
|
math/mtherr.c
|
||||||
|
math/polevl.c
|
||||||
|
math/sin.c
|
||||||
|
math/sinh.c
|
||||||
|
math/sqrt.c
|
||||||
|
math/tan.c
|
||||||
|
math/tanh.c
|
||||||
|
math/fastsin.cpp
|
||||||
|
sfmt/SFMT.cpp
|
||||||
zzautozend.cpp
|
zzautozend.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue