diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3caa2c2d25e1a..2ce9c81257020 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,25 @@ configure_file(${CMAKE_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-conf add_compile_definitions(HAVE_CONFIG_H) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +# After the transition from Autotools to CMake, the obj/ subdirectory +# could be dropped as its only purpose was to separate a generated header +# from source files. +add_custom_target(generate_build_info + BYPRODUCTS ${PROJECT_BINARY_DIR}/src/obj/build.h + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/src/obj + COMMAND ${PROJECT_SOURCE_DIR}/share/genbuild.sh ${PROJECT_BINARY_DIR}/src/obj/build.h ${PROJECT_SOURCE_DIR} + COMMENT "Generating obj/build.h" + VERBATIM +) +add_library(bitcoin_clientversion OBJECT EXCLUDE_FROM_ALL + clientversion.cpp +) +target_compile_definitions(bitcoin_clientversion + PRIVATE + HAVE_BUILD_INFO +) +add_dependencies(bitcoin_clientversion generate_build_info) + add_subdirectory(crypto) add_subdirectory(univalue) add_subdirectory(util) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index dc7eec69a6f43..ed1cac7044b1e 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -33,7 +33,6 @@ add_library(bitcoin_util STATIC EXCLUDE_FROM_ALL time.cpp tokenpipe.cpp ../chainparamsbase.cpp - ../clientversion.cpp ../logging.cpp ../random.cpp ../randomenv.cpp @@ -52,6 +51,7 @@ target_compile_definitions(bitcoin_util target_link_libraries(bitcoin_util PRIVATE core + bitcoin_clientversion bitcoin_crypto Threads::Threads $<$:ws2_32>