Skip to content

Commit

Permalink
build: speedup by simplifying dependency graph
Browse files Browse the repository at this point in the history
Allow the objects of static libs to be built in parallel rather than serially
based on their dependency ordering.

For more detail, see:
https://cmake.org/cmake/help/latest/prop_tgt/OPTIMIZE_DEPENDENCIES.html
  • Loading branch information
theuni committed Sep 17, 2024
1 parent 330d16e commit 42edb2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
CMAKE_CXX_LINK_EXECUTABLE
)

# Flatten static lib dependencies.
# Without this, if libfoo.a depends on libbar.a, libfoo's objects can't begin
# to be compiled until libbar.a has been created.
set(CMAKE_OPTIMIZE_DEPENDENCIES TRUE)

project(BitcoinCore
VERSION ${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD}
DESCRIPTION "Bitcoin client software"
Expand Down
3 changes: 3 additions & 0 deletions cmake/minisketch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ add_library(minisketch STATIC EXCLUDE_FROM_ALL
${PROJECT_SOURCE_DIR}/src/minisketch/src/fields/generic_8bytes.cpp
)

# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/24058
set_target_properties(minisketch PROPERTIES OPTIMIZE_DEPENDENCIES OFF)

target_include_directories(minisketch
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/minisketch/include>
Expand Down
3 changes: 3 additions & 0 deletions src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ add_library(bitcoin_util STATIC EXCLUDE_FROM_ALL
../sync.cpp
)

# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/24058
set_target_properties(bitcoin_util PROPERTIES OPTIMIZE_DEPENDENCIES OFF)

target_link_libraries(bitcoin_util
PRIVATE
core_interface
Expand Down

0 comments on commit 42edb2f

Please sign in to comment.