Skip to content

Commit 188607b

Browse files
soarqinAndrii Danylchenko
authored and
Andrii Danylchenko
committed
Replace cotire with CMake builtin precompiled headers support (Requires CMake version >= 3.16)
1 parent 2521e7b commit 188607b

File tree

16 files changed

+23
-4125
lines changed

16 files changed

+23
-4125
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ CMakeFiles
2626
Makefile
2727
cmake_install.cmake
2828
install_manifest.txt
29-
*_cotire.cmake
30-
cotire
3129
moc_*.cpp
3230
qrc_*.cpp
3331
ui_*.h

AI/BattleAI/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ target_include_directories(BattleAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3636
target_link_libraries(BattleAI PRIVATE vcmi)
3737

3838
vcmi_set_output_dir(BattleAI "AI")
39-
40-
set_target_properties(BattleAI PROPERTIES ${PCH_PROPERTIES})
41-
cotire(BattleAI)
39+
enable_pch(BattleAI)
4240

4341
install(TARGETS BattleAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

AI/EmptyAI/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ target_include_directories(EmptyAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1818
target_link_libraries(EmptyAI PRIVATE vcmi)
1919

2020
vcmi_set_output_dir(EmptyAI "AI")
21-
22-
set_target_properties(EmptyAI PROPERTIES ${PCH_PROPERTIES})
21+
enable_pch(EmptyAI)
2322

2423
install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

AI/Nullkiller/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ target_link_libraries(Nullkiller PRIVATE vcmi fuzzylite::fuzzylite)
135135
target_link_libraries(Nullkiller PRIVATE TBB::tbb)
136136

137137
vcmi_set_output_dir(Nullkiller "AI")
138-
139-
set_target_properties(Nullkiller PROPERTIES ${PCH_PROPERTIES})
140-
cotire(Nullkiller)
138+
enable_pch(Nullkiller)
141139

142140
install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

AI/StupidAI/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ target_link_libraries(StupidAI PRIVATE vcmi)
1818
target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1919

2020
vcmi_set_output_dir(StupidAI "AI")
21-
22-
set_target_properties(StupidAI PROPERTIES ${PCH_PROPERTIES})
23-
cotire(StupidAI)
21+
enable_pch(StupidAI)
2422

2523
install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

AI/VCAI/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
114114
target_link_libraries(VCAI PRIVATE vcmi fuzzylite::fuzzylite)
115115

116116
vcmi_set_output_dir(VCAI "AI")
117-
118-
set_target_properties(VCAI PROPERTIES ${PCH_PROPERTIES})
119-
cotire(VCAI)
117+
enable_pch(VCAI)
120118

121119
install(TARGETS VCAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

CMakeLists.txt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ option(ENABLE_ERM "Enable compilation of ERM scripting module" ON)
4848
option(ENABLE_LUA "Enable compilation of LUA scripting module" ON)
4949
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
5050
option(ENABLE_TEST "Enable compilation of unit tests" ON)
51-
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
51+
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
52+
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
53+
endif(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
5254
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
5355
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
5456
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
@@ -95,18 +97,14 @@ else()
9597
endif(ENABLE_GITVERSION)
9698

9799
# Precompiled header configuration
98-
if(ENABLE_PCH)
99-
include(cotire)
100-
set(PCH_PROPERTIES
101-
COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH}
102-
COTIRE_ADD_UNITY_BUILD FALSE
103-
COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h"
104-
)
105-
else()
106-
set(PCH_PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
107-
macro(cotire ignore)
108-
endmacro(cotire)
109-
endif(ENABLE_PCH)
100+
if(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
101+
macro(enable_pch name)
102+
target_precompile_headers(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:<StdInc.h$<ANGLE-R>>)
103+
endmacro(enable_pch)
104+
else(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
105+
macro(enable_pch ignore)
106+
endmacro(enable_pch)
107+
endif(ENABLE_PCH AND NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
110108

111109
############################################
112110
# Documentation section #

client/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ target_include_directories(vcmiclient
186186
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
187187

188188
vcmi_set_output_dir(vcmiclient "")
189-
190-
set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES})
191-
cotire(vcmiclient)
189+
enable_pch(vcmiclient)
192190

193191
install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
194192

cmake_modules/cotire license.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)