Skip to content

Commit

Permalink
cmake: Implement make install
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Oct 18, 2023
1 parent 7540535 commit 8390dc4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ tristate_option(WITH_USDT

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
option(INSTALL_MAN "Install man pages." ON)

if(CXX20)
set(CMAKE_CXX_STANDARD 20)
Expand Down
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

include(GNUInstallDirs)

configure_file(${CMAKE_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY)
add_compile_definitions(HAVE_CONFIG_H)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -101,6 +103,7 @@ target_link_libraries(bitcoin_common
)


set(installable_targets)
if(ENABLE_WALLET)
add_subdirectory(wallet)

Expand All @@ -117,6 +120,7 @@ if(ENABLE_WALLET)
bitcoin_util
Boost::headers
)
list(APPEND installable_targets bitcoin-wallet)
endif()
endif()

Expand Down Expand Up @@ -246,6 +250,7 @@ if(BUILD_DAEMON)
core
bitcoin_node
)
list(APPEND installable_targets bitcoind)
endif()


Expand All @@ -270,6 +275,7 @@ if(BUILD_CLI)
bitcoin_util
libevent::libevent
)
list(APPEND installable_targets bitcoin-cli)
endif()


Expand All @@ -281,6 +287,7 @@ if(BUILD_TX)
bitcoin_util
univalue
)
list(APPEND installable_targets bitcoin-tx)
endif()


Expand All @@ -291,6 +298,7 @@ if(BUILD_UTIL)
bitcoin_common
bitcoin_util
)
list(APPEND installable_targets bitcoin-util)
endif()


Expand All @@ -307,3 +315,16 @@ endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif()


install(TARGETS ${installable_targets}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
unset(installable_targets)

if(INSTALL_MAN)
install(DIRECTORY ../doc/man/
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
FILES_MATCHING PATTERN *.1
)
endif()
4 changes: 4 additions & 0 deletions src/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ if(ENABLE_WALLET)
)
target_link_libraries(bench_bitcoin bitcoin_wallet)
endif()

install(TARGETS bench_bitcoin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
10 changes: 10 additions & 0 deletions src/script/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ if(BUILD_SHARED)
SOVERSION 0
VERSION 0.0.0
)
install(TARGETS bitcoinconsensus
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

if(BUILD_STATIC)
Expand Down Expand Up @@ -76,6 +81,11 @@ if(BUILD_STATIC)
OUTPUT_NAME bitcoinconsensus
)
endif()
install(TARGETS bitcoinconsensus_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/bitcoinconsensus.h"
Expand Down
4 changes: 4 additions & 0 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ if(ENABLE_WALLET)
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp)
endif()
endif()

install(TARGETS test_bitcoin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

0 comments on commit 8390dc4

Please sign in to comment.