Skip to content

Commit 7400ca5

Browse files
committed
cmake: Implement make install
1 parent 3838e69 commit 7400ca5

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
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

Lines changed: 22 additions & 0 deletions
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

@@ -244,6 +248,7 @@ if(BUILD_DAEMON)
244248
bitcoin_node
245249
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
246250
)
251+
list(APPEND installable_targets bitcoind)
247252
endif()
248253

249254

@@ -268,6 +273,7 @@ if(BUILD_CLI)
268273
bitcoin_util
269274
libevent::libevent
270275
)
276+
list(APPEND installable_targets bitcoin-cli)
271277
endif()
272278

273279

@@ -279,6 +285,7 @@ if(BUILD_TX)
279285
bitcoin_util
280286
univalue
281287
)
288+
list(APPEND installable_targets bitcoin-tx)
282289
endif()
283290

284291

@@ -289,6 +296,7 @@ if(BUILD_UTIL)
289296
bitcoin_common
290297
bitcoin_util
291298
)
299+
list(APPEND installable_targets bitcoin-util)
292300
endif()
293301

294302

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

src/bench/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ if(ENABLE_WALLET)
6666
)
6767
target_link_libraries(bench_bitcoin bitcoin_wallet)
6868
endif()
69+
70+
install(TARGETS bench_bitcoin
71+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
72+
)

src/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,7 @@ if(ENABLE_WALLET)
171171
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp)
172172
endif()
173173
endif()
174+
175+
install(TARGETS test_bitcoin
176+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
177+
)

0 commit comments

Comments
 (0)