Skip to content

Commit

Permalink
cmake: Generate obj/build.h header
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Nov 16, 2023
1 parent 4291baa commit 5c2c0f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,6 +51,7 @@ target_compile_definitions(bitcoin_util
target_link_libraries(bitcoin_util
PRIVATE
core
bitcoin_clientversion
bitcoin_crypto
Threads::Threads
$<$<BOOL:${MINGW}>:ws2_32>
Expand Down

0 comments on commit 5c2c0f3

Please sign in to comment.