aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-02-11 22:23:42 +0100
committerShauren <shauren.trinity@gmail.com>2022-02-11 22:23:42 +0100
commitfe35971d2f240898e01a38752c14398ebee2ac7a (patch)
tree76622559c3d4f9a2b8eee729bfa9b52adbd77ac9 /cmake/compiler
parentdf48af798b9e2d86d8b34052c348e3831d28c444 (diff)
Build: Instantiate templates during PCH generation with clang 11+ (this should make PCH more effective in reducing compile times, closer to MSVC)
Diffstat (limited to 'cmake/compiler')
-rw-r--r--cmake/compiler/clang/settings.cmake10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake
index 1fe89542a84..2b6e998d854 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -150,3 +150,13 @@ if(BUILD_SHARED_LIBS)
message(STATUS "Clang: Disallow undefined symbols")
endif()
+
+# speedup PCH builds by forcing template instantiations during PCH generation
+set(CMAKE_REQUIRED_FLAGS "-fpch-instantiate-templates")
+check_cxx_source_compiles("int main() { return 0; }" CLANG_HAS_PCH_INSTANTIATE_TEMPLATES)
+unset(CMAKE_REQUIRED_FLAGS)
+if(CLANG_HAS_PCH_INSTANTIATE_TEMPLATES)
+ target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ -fpch-instantiate-templates)
+endif()