1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

Replace cotire with CMake builtin precompiled headers support (Requires CMake version >= 3.16)

This commit is contained in:
Soar Qin 2022-06-17 04:02:36 +08:00 committed by Andrii Danylchenko
parent 2521e7bac9
commit 188607b05f
16 changed files with 23 additions and 4125 deletions

2
.gitignore vendored
View File

@ -26,8 +26,6 @@ CMakeFiles
Makefile Makefile
cmake_install.cmake cmake_install.cmake
install_manifest.txt install_manifest.txt
*_cotire.cmake
cotire
moc_*.cpp moc_*.cpp
qrc_*.cpp qrc_*.cpp
ui_*.h ui_*.h

View File

@ -36,8 +36,6 @@ target_include_directories(BattleAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(BattleAI PRIVATE vcmi) target_link_libraries(BattleAI PRIVATE vcmi)
vcmi_set_output_dir(BattleAI "AI") vcmi_set_output_dir(BattleAI "AI")
enable_pch(BattleAI)
set_target_properties(BattleAI PROPERTIES ${PCH_PROPERTIES})
cotire(BattleAI)
install(TARGETS BattleAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) install(TARGETS BattleAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@ -18,7 +18,6 @@ target_include_directories(EmptyAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(EmptyAI PRIVATE vcmi) target_link_libraries(EmptyAI PRIVATE vcmi)
vcmi_set_output_dir(EmptyAI "AI") vcmi_set_output_dir(EmptyAI "AI")
enable_pch(EmptyAI)
set_target_properties(EmptyAI PROPERTIES ${PCH_PROPERTIES})
install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@ -135,8 +135,6 @@ target_link_libraries(Nullkiller PRIVATE vcmi fuzzylite::fuzzylite)
target_link_libraries(Nullkiller PRIVATE TBB::tbb) target_link_libraries(Nullkiller PRIVATE TBB::tbb)
vcmi_set_output_dir(Nullkiller "AI") vcmi_set_output_dir(Nullkiller "AI")
enable_pch(Nullkiller)
set_target_properties(Nullkiller PROPERTIES ${PCH_PROPERTIES})
cotire(Nullkiller)
install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@ -18,8 +18,6 @@ target_link_libraries(StupidAI PRIVATE vcmi)
target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
vcmi_set_output_dir(StupidAI "AI") vcmi_set_output_dir(StupidAI "AI")
enable_pch(StupidAI)
set_target_properties(StupidAI PROPERTIES ${PCH_PROPERTIES})
cotire(StupidAI)
install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@ -114,8 +114,6 @@ target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(VCAI PRIVATE vcmi fuzzylite::fuzzylite) target_link_libraries(VCAI PRIVATE vcmi fuzzylite::fuzzylite)
vcmi_set_output_dir(VCAI "AI") vcmi_set_output_dir(VCAI "AI")
enable_pch(VCAI)
set_target_properties(VCAI PROPERTIES ${PCH_PROPERTIES})
cotire(VCAI)
install(TARGETS VCAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) install(TARGETS VCAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@ -48,7 +48,9 @@ option(ENABLE_ERM "Enable compilation of ERM scripting module" ON)
option(ENABLE_LUA "Enable compilation of LUA scripting module" ON) option(ENABLE_LUA "Enable compilation of LUA scripting module" ON)
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON) option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
option(ENABLE_TEST "Enable compilation of unit tests" ON) option(ENABLE_TEST "Enable compilation of unit tests" ON)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
option(ENABLE_PCH "Enable compilation using precompiled headers" ON) option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
endif(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON) option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON) option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON) option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
@ -95,18 +97,14 @@ else()
endif(ENABLE_GITVERSION) endif(ENABLE_GITVERSION)
# Precompiled header configuration # Precompiled header configuration
if(ENABLE_PCH) if(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
include(cotire) macro(enable_pch name)
set(PCH_PROPERTIES target_precompile_headers(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:<StdInc.h$<ANGLE-R>>)
COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH} endmacro(enable_pch)
COTIRE_ADD_UNITY_BUILD FALSE else(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h" macro(enable_pch ignore)
) endmacro(enable_pch)
else() endif(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
set(PCH_PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
macro(cotire ignore)
endmacro(cotire)
endif(ENABLE_PCH)
############################################ ############################################
# Documentation section # # Documentation section #

View File

@ -186,9 +186,7 @@ target_include_directories(vcmiclient
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
vcmi_set_output_dir(vcmiclient "") vcmi_set_output_dir(vcmiclient "")
enable_pch(vcmiclient)
set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiclient)
install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) install(TARGETS vcmiclient DESTINATION ${BIN_DIR})

View File

@ -1,22 +0,0 @@
Copyright (c) 2012-2014 Sascha Kratky
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -101,10 +101,7 @@ target_include_directories(vcmilauncher
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
) )
vcmi_set_output_dir(vcmilauncher "") vcmi_set_output_dir(vcmilauncher "")
enable_pch(vcmilauncher)
# temporary(?) disabled - generation of PCH takes too much time since cotire is trying to collect all Qt headers
#set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES})
#cotire(vcmilauncher)
# Copy to build directory for easier debugging # Copy to build directory for easier debugging
add_custom_command(TARGET vcmilauncher POST_BUILD add_custom_command(TARGET vcmilauncher POST_BUILD

View File

@ -420,8 +420,7 @@ endif()
vcmi_set_output_dir(vcmi "") vcmi_set_output_dir(vcmi "")
set_target_properties(vcmi PROPERTIES ${PCH_PROPERTIES}) enable_pch(vcmi)
cotire(vcmi)
# We want to deploy assets into build directory for easier debugging without install # We want to deploy assets into build directory for easier debugging without install
add_custom_command(TARGET vcmi POST_BUILD add_custom_command(TARGET vcmi POST_BUILD

View File

@ -18,8 +18,6 @@ add_library(vcmiERM SHARED ${lib_SRCS} ${lib_HDRS})
target_link_libraries(vcmiERM Boost::boost vcmi) target_link_libraries(vcmiERM Boost::boost vcmi)
vcmi_set_output_dir(vcmiERM "scripting") vcmi_set_output_dir(vcmiERM "scripting")
enable_pch(vcmiERM)
set_target_properties(vcmiERM PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiERM)
install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR}) install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR})

View File

@ -43,9 +43,7 @@ add_library(vcmiLua SHARED ${lib_SRCS})
target_link_libraries(vcmiLua Boost::boost luajit::luajit vcmi) target_link_libraries(vcmiLua Boost::boost luajit::luajit vcmi)
vcmi_set_output_dir(vcmiLua "scripting") vcmi_set_output_dir(vcmiLua "scripting")
enable_pch(vcmiLua)
set_target_properties(vcmiLua PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiLua)
install(TARGETS vcmiLua DESTINATION ${SCRIPTING_LIB_DIR}) install(TARGETS vcmiLua DESTINATION ${SCRIPTING_LIB_DIR})

View File

@ -43,8 +43,6 @@ if(WIN32)
endif() endif()
vcmi_set_output_dir(vcmiserver "") vcmi_set_output_dir(vcmiserver "")
enable_pch(vcmiserver)
set_target_properties(vcmiserver PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiserver)
install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) install(TARGETS vcmiserver DESTINATION ${BIN_DIR})

View File

@ -177,8 +177,7 @@ endif()
vcmi_set_output_dir(vcmitest "") vcmi_set_output_dir(vcmitest "")
set_target_properties(vcmitest PROPERTIES ${PCH_PROPERTIES}) enable_pch(vcmitest)
cotire(vcmitest)
file (GLOB_RECURSE testdata "testdata/*.*") file (GLOB_RECURSE testdata "testdata/*.*")
foreach(resource ${testdata}) foreach(resource ${testdata})