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
cmake_install.cmake
install_manifest.txt
*_cotire.cmake
cotire
moc_*.cpp
qrc_*.cpp
ui_*.h

View File

@ -36,8 +36,6 @@ target_include_directories(BattleAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(BattleAI PRIVATE vcmi)
vcmi_set_output_dir(BattleAI "AI")
set_target_properties(BattleAI PROPERTIES ${PCH_PROPERTIES})
cotire(BattleAI)
enable_pch(BattleAI)
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)
vcmi_set_output_dir(EmptyAI "AI")
set_target_properties(EmptyAI PROPERTIES ${PCH_PROPERTIES})
enable_pch(EmptyAI)
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)
vcmi_set_output_dir(Nullkiller "AI")
set_target_properties(Nullkiller PROPERTIES ${PCH_PROPERTIES})
cotire(Nullkiller)
enable_pch(Nullkiller)
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})
vcmi_set_output_dir(StupidAI "AI")
set_target_properties(StupidAI PROPERTIES ${PCH_PROPERTIES})
cotire(StupidAI)
enable_pch(StupidAI)
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)
vcmi_set_output_dir(VCAI "AI")
set_target_properties(VCAI PROPERTIES ${PCH_PROPERTIES})
cotire(VCAI)
enable_pch(VCAI)
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_LAUNCHER "Enable compilation of launcher" ON)
option(ENABLE_TEST "Enable compilation of unit tests" ON)
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
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_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
@ -95,18 +97,14 @@ else()
endif(ENABLE_GITVERSION)
# Precompiled header configuration
if(ENABLE_PCH)
include(cotire)
set(PCH_PROPERTIES
COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH}
COTIRE_ADD_UNITY_BUILD FALSE
COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h"
)
else()
set(PCH_PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
macro(cotire ignore)
endmacro(cotire)
endif(ENABLE_PCH)
if(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
macro(enable_pch name)
target_precompile_headers(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:<StdInc.h$<ANGLE-R>>)
endmacro(enable_pch)
else(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
macro(enable_pch ignore)
endmacro(enable_pch)
endif(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
############################################
# Documentation section #

View File

@ -186,9 +186,7 @@ target_include_directories(vcmiclient
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
vcmi_set_output_dir(vcmiclient "")
set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiclient)
enable_pch(vcmiclient)
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}
)
vcmi_set_output_dir(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)
enable_pch(vcmilauncher)
# Copy to build directory for easier debugging
add_custom_command(TARGET vcmilauncher POST_BUILD

View File

@ -420,8 +420,7 @@ endif()
vcmi_set_output_dir(vcmi "")
set_target_properties(vcmi PROPERTIES ${PCH_PROPERTIES})
cotire(vcmi)
enable_pch(vcmi)
# We want to deploy assets into build directory for easier debugging without install
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)
vcmi_set_output_dir(vcmiERM "scripting")
set_target_properties(vcmiERM PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiERM)
enable_pch(vcmiERM)
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)
vcmi_set_output_dir(vcmiLua "scripting")
set_target_properties(vcmiLua PROPERTIES ${PCH_PROPERTIES})
cotire(vcmiLua)
enable_pch(vcmiLua)
install(TARGETS vcmiLua DESTINATION ${SCRIPTING_LIB_DIR})

View File

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

View File

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