From fe35971d2f240898e01a38752c14398ebee2ac7a Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 11 Feb 2022 22:23:42 +0100 Subject: Build: Instantiate templates during PCH generation with clang 11+ (this should make PCH more effective in reducing compile times, closer to MSVC) --- cmake/compiler/clang/settings.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmake') 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() -- cgit v1.2.3