Skip to content

Commit 7dc3874

Browse files
committed
cmake: Implement make install
1 parent 60f0046 commit 7dc3874

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ tristate_option(WITH_USDT
6969

7070
option(BUILD_TESTS "Build test_bitcoin executable." ON)
7171
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
72+
option(INSTALL_MAN "Install man pages." ON)
7273

7374
if(CXX20)
7475
set(CMAKE_CXX_STANDARD 20)

src/CMakeLists.txt

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
include(GNUInstallDirs)
6+
57
configure_file(${CMAKE_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY)
68
add_compile_definitions(HAVE_CONFIG_H)
79
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
@@ -101,6 +103,7 @@ target_link_libraries(bitcoin_common
101103
)
102104

103105

106+
set(installable_targets)
104107
if(ENABLE_WALLET)
105108
add_subdirectory(wallet)
106109

@@ -117,6 +120,7 @@ if(ENABLE_WALLET)
117120
bitcoin_util
118121
Boost::headers
119122
)
123+
list(APPEND installable_targets bitcoin-wallet)
120124
endif()
121125
endif()
122126

@@ -247,6 +251,7 @@ if(BUILD_DAEMON)
247251
core
248252
bitcoin_node
249253
)
254+
list(APPEND installable_targets bitcoind)
250255
endif()
251256

252257

@@ -271,6 +276,7 @@ if(BUILD_CLI)
271276
bitcoin_util
272277
libevent::libevent
273278
)
279+
list(APPEND installable_targets bitcoin-cli)
274280
endif()
275281

276282

@@ -282,6 +288,7 @@ if(BUILD_TX)
282288
bitcoin_util
283289
univalue
284290
)
291+
list(APPEND installable_targets bitcoin-tx)
285292
endif()
286293

287294

@@ -292,6 +299,7 @@ if(BUILD_UTIL)
292299
bitcoin_common
293300
bitcoin_util
294301
)
302+
list(APPEND installable_targets bitcoin-util)
295303
endif()
296304

297305

@@ -303,3 +311,17 @@ endif()
303311
if(BUILD_TESTS)
304312
add_subdirectory(test)
305313
endif()
314+
315+
316+
install(TARGETS ${installable_targets}
317+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
318+
)
319+
unset(installable_targets)
320+
321+
if(INSTALL_MAN)
322+
# TODO: these stubs are no longer needed. man pages should be generated at install time.
323+
install(DIRECTORY ../doc/man/
324+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
325+
FILES_MATCHING PATTERN *.1
326+
)
327+
endif()

src/bench/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ if(ENABLE_WALLET)
6767
)
6868
target_link_libraries(bench_bitcoin bitcoin_wallet)
6969
endif()
70+
71+
install(TARGETS bench_bitcoin
72+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
73+
)

src/test/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,7 @@ if(ENABLE_WALLET)
175175
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp)
176176
endif()
177177
endif()
178+
179+
install(TARGETS test_bitcoin
180+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
181+
)

0 commit comments

Comments
 (0)