From 106f7937e6bc223fe5b6d01b60f7dcc3c2cfd434 Mon Sep 17 00:00:00 2001 From: Miuna Date: Sun, 18 Jun 2023 13:04:50 -0400 Subject: [PATCH] feat: add DPP_USE_PCH CMake option to use precompiled headers (off by default) --- CMakeLists.txt | 1 + library/CMakeLists.txt | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aabbc42a25..c1798137ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ option(DPP_BUILD_TEST "Build the test program" ON) option(DPP_NO_VCPKG "No VCPKG" OFF) option(DPP_CORO "Experimental support for C++20 coroutines" OFF) option(DPP_USE_EXTERNAL_JSON "Use an external installation of nlohmann::json" OFF) +option(DPP_USE_PCH "Use precompiled headers to speed up compilation" OFF) include(CheckCXXSymbolExists) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4a8624cab9..310ce0cb9a 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -230,6 +230,15 @@ foreach (fullmodname ${subdirlist}) $ ) + if (DPP_USE_PCH) + target_precompile_headers(${modname} PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/cluster.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/json.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/utility.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp/restresults.h" + ) + endif() + if (WIN32 AND NOT MINGW) if (NOT WINDOWS_32_BIT) target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib"