From 3fd64efb437e10194ffd0e6d9b6b4664bcf1a0de Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:29:18 +0000 Subject: [PATCH] cmake: Avoid using `OBJECT` libraries `OBJECT` libraries have historically exhibited poor support for various features, both in the past and now. For example, see one of the latest issues: - https://gitlab.kitware.com/cmake/cmake/-/issues/24058 Furthermore, CMake maintainers have acknowledged: > In general, however, where there is a choice, static libraries will > typically be the more convenient choice in CMake projects. This change: 1. Converts the `bitcoin_clientversion` library from an `OBJECT` library to a `STATIC` library. 2. Removes an obsolete workaround. --- src/CMakeLists.txt | 2 +- src/util/CMakeLists.txt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b762b03880d..5aad75b4615 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,7 @@ add_custom_target(generate_build_info COMMENT "Generating bitcoin-build-info.h" VERBATIM ) -add_library(bitcoin_clientversion OBJECT EXCLUDE_FROM_ALL +add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL clientversion.cpp ) target_link_libraries(bitcoin_clientversion diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 9ca26a9e27b..4999dbf13f0 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -36,9 +36,6 @@ 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