Skip to content

Commit

Permalink
feat: add DPP_USE_PCH CMake option to use precompiled headers (off by…
Browse files Browse the repository at this point in the history
… default)
  • Loading branch information
Mishura4 committed Aug 22, 2023
1 parent 8985170 commit 106f793
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ foreach (fullmodname ${subdirlist})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include/dpp>
)

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"
Expand Down

0 comments on commit 106f793

Please sign in to comment.