summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorAndy Clayton <q3aiml@gmail.com>2020-03-31 19:41:50 -0500
committerMartin Michlmayr <tbm@cyrius.com>2020-04-02 08:31:33 +0800
commit0703956e78d1d0352e69273295a0301586f86ca8 (patch)
tree1ed6c2e1275ee0ff4a13baed7411ec51355361f4 /src/CMakeLists.txt
parent0e613c67356f3aa75dab109552c9b2dfbd83a1e4 (diff)
downloadfork-ledger-0703956e78d1d0352e69273295a0301586f86ca8.tar.gz
fork-ledger-0703956e78d1d0352e69273295a0301586f86ca8.tar.bz2
fork-ledger-0703956e78d1d0352e69273295a0301586f86ca8.zip
use built-in cmake precompiled header support when available
Ledger supports precompiling headers as a build speed optimization. This is provided via a custom add_pch_rule macro. Similar functionality is now built-in to CMake starting with the 3.16 release in November 2019. Let's use this when available to fix #1774 and start towards not needing to maintain our own implementation. I originally considered removing the macro fallback but in my tests it saves enough build time that I think it is worth keeping for now. Fixes #1774
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5eddd5ac..167f5515 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -265,7 +265,8 @@ else()
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
endif()
-if(PRECOMPILE_SYSTEM_HH)
+if(PRECOMPILE_SYSTEM_HH AND NOT (COMMAND target_precompile_headers))
+ # enable fallback for CMake versions older than 3.16 without target_precompile_headers
add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES LEDGER_CLI_SOURCES)
endif()
@@ -294,6 +295,15 @@ else()
add_ledger_library_dependencies(ledger)
endif()
+if (PRECOMPILE_SYSTEM_HH AND (COMMAND target_precompile_headers) AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
+ if (BUILD_LIBRARY)
+ target_precompile_headers(libledger PRIVATE ${PROJECT_BINARY_DIR}/system.hh)
+ target_precompile_headers(ledger REUSE_FROM libledger)
+ else()
+ target_precompile_headers(ledger PRIVATE ${PROJECT_BINARY_DIR}/system.hh)
+ endif()
+endif()
+
if (USE_PYTHON)
if (Python_SITEARCH)
if (WIN32 AND NOT CYGWIN)