Skip to content

Commit d86340b

Browse files
committed
cmake: Implement make install
1 parent 5858d45 commit d86340b

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

@@ -246,6 +250,7 @@ if(BUILD_DAEMON)
246250
core
247251
bitcoin_node
248252
)
253+
list(APPEND installable_targets bitcoind)
249254
endif()
250255

251256

@@ -270,6 +275,7 @@ if(BUILD_CLI)
270275
bitcoin_util
271276
libevent::libevent
272277
)
278+
list(APPEND installable_targets bitcoin-cli)
273279
endif()
274280

275281

@@ -281,6 +287,7 @@ if(BUILD_TX)
281287
bitcoin_util
282288
univalue
283289
)
290+
list(APPEND installable_targets bitcoin-tx)
284291
endif()
285292

286293

@@ -291,6 +298,7 @@ if(BUILD_UTIL)
291298
bitcoin_common
292299
bitcoin_util
293300
)
301+
list(APPEND installable_targets bitcoin-util)
294302
endif()
295303

296304

@@ -302,3 +310,17 @@ endif()
302310
if(BUILD_TESTS)
303311
add_subdirectory(test)
304312
endif()
313+
314+
315+
install(TARGETS ${installable_targets}
316+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
317+
)
318+
unset(installable_targets)
319+
320+
if(INSTALL_MAN)
321+
# TODO: these stubs are no longer needed. man pages should be generated at install time.
322+
install(DIRECTORY ../doc/man/
323+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
324+
FILES_MATCHING PATTERN *.1
325+
)
326+
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
@@ -174,3 +174,7 @@ if(ENABLE_WALLET)
174174
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp)
175175
endif()
176176
endif()
177+
178+
install(TARGETS test_bitcoin
179+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
180+
)

0 commit comments

Comments
 (0)