Skip to content

Commit 5219f18

Browse files
committed
cmake: Implement make install
1 parent 14d15dd commit 5219f18

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ tristate_option(WITH_USDT
7676

7777
option(BUILD_TESTS "Build test_bitcoin executable." ON)
7878
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
79+
option(INSTALL_MAN "Install man pages." ON)
7980

8081
if(CXX20)
8182
set(CMAKE_CXX_STANDARD 20)

src/CMakeLists.txt

+21
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

@@ -307,3 +315,16 @@ endif()
307315
if(BUILD_TESTS)
308316
add_subdirectory(test)
309317
endif()
318+
319+
320+
install(TARGETS ${installable_targets}
321+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
322+
)
323+
unset(installable_targets)
324+
325+
if(INSTALL_MAN)
326+
install(DIRECTORY ../doc/man/
327+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
328+
FILES_MATCHING PATTERN *.1
329+
)
330+
endif()

src/bench/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ if(ENABLE_WALLET)
7171
)
7272
target_link_libraries(bench_bitcoin bitcoin_wallet)
7373
endif()
74+
75+
install(TARGETS bench_bitcoin
76+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
77+
)

src/script/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ if(BUILD_SHARED)
4747
SOVERSION 0
4848
VERSION 0.0.0
4949
)
50+
install(TARGETS bitcoinconsensus
51+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
52+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
53+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
54+
)
5055
endif()
5156

5257
if(BUILD_STATIC)
@@ -76,6 +81,11 @@ if(BUILD_STATIC)
7681
OUTPUT_NAME bitcoinconsensus
7782
)
7883
endif()
84+
install(TARGETS bitcoinconsensus_static
85+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
86+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
87+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
88+
)
7989
endif()
8090

8191
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/bitcoinconsensus.h"

src/test/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ if(ENABLE_WALLET)
179179
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp)
180180
endif()
181181
endif()
182+
183+
install(TARGETS test_bitcoin
184+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
185+
)

0 commit comments

Comments
 (0)