From a5b57bb9cd1500a6e0a3c800b35c1984211dff1d Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Mon, 21 Nov 2022 22:45:11 -0500 Subject: [PATCH] CMake: Add option to use precompiled headers --- CMakeLists.txt | 1 + src/dynarmic/CMakeLists.txt | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac142d12..cf3e69a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ option(DYNARMIC_IGNORE_ASSERTS "Ignore asserts" OFF) option(DYNARMIC_TESTS "Build tests" ${MASTER_PROJECT}) option(DYNARMIC_TESTS_USE_UNICORN "Enable fuzzing tests against unicorn" OFF) option(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF) +option(DYNARMIC_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) option(DYNARMIC_WARNINGS_AS_ERRORS "Warnings as errors" ${MASTER_PROJECT}) if (NOT DEFINED DYNARMIC_FRONTENDS) set(DYNARMIC_FRONTENDS "A32;A64" CACHE STRING "Selects which frontends to enable") diff --git a/src/dynarmic/CMakeLists.txt b/src/dynarmic/CMakeLists.txt index 8ae02cf3..75c24feb 100644 --- a/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/CMakeLists.txt @@ -454,3 +454,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") target_compile_definitions(dynarmic PRIVATE FMT_USE_WINDOWS_H=0) endif() target_compile_definitions(dynarmic PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) + +if (DYNARMIC_USE_PRECOMPILED_HEADERS) + set(PRECOMPILED_HEADERS "$<$:${CMAKE_CURRENT_SOURCE_DIR}/ir/ir_emitter.h>") + if (ARCHITECTURE STREQUAL "x86_64") + list(PREPEND PRECOMPILED_HEADERS "$<$:>") + endif() + target_precompile_headers(dynarmic PRIVATE ${PRECOMPILED_HEADERS}) + set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON) +endif()