Skip to content

Commit 973a3b0

Browse files
committed
cmake: Implement install build target
1 parent 84ac35c commit 973a3b0

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ option(BUILD_BENCH "Build bench_bitcoin executable." OFF)
187187
option(BUILD_FUZZ_BINARY "Build fuzz binary." OFF)
188188
cmake_dependent_option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)
189189

190+
option(INSTALL_MAN "Install man pages." ON)
191+
190192
set(configure_warnings)
191193

192194
include(CheckPIESupported)

src/CMakeLists.txt

Lines changed: 23 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 https://opensource.org/license/mit/.
44

5+
include(GNUInstallDirs)
6+
57
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY)
68
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
79

@@ -160,6 +162,7 @@ target_link_libraries(bitcoin_common
160162
)
161163

162164

165+
set(installable_targets)
163166
if(ENABLE_WALLET)
164167
add_subdirectory(wallet)
165168

@@ -176,6 +179,7 @@ if(ENABLE_WALLET)
176179
bitcoin_util
177180
Boost::headers
178181
)
182+
list(APPEND installable_targets bitcoin-wallet)
179183
endif()
180184
endif()
181185

@@ -304,6 +308,7 @@ if(BUILD_DAEMON)
304308
bitcoin_node
305309
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
306310
)
311+
list(APPEND installable_targets bitcoind)
307312
endif()
308313
if(WITH_MULTIPROCESS)
309314
add_executable(bitcoin-node
@@ -316,6 +321,7 @@ if(WITH_MULTIPROCESS)
316321
bitcoin_ipc
317322
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
318323
)
324+
list(APPEND installable_targets bitcoin-node)
319325
endif()
320326

321327

@@ -340,6 +346,7 @@ if(BUILD_CLI)
340346
bitcoin_util
341347
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
342348
)
349+
list(APPEND installable_targets bitcoin-cli)
343350
endif()
344351

345352

@@ -351,6 +358,7 @@ if(BUILD_TX)
351358
bitcoin_util
352359
univalue
353360
)
361+
list(APPEND installable_targets bitcoin-tx)
354362
endif()
355363

356364

@@ -361,6 +369,7 @@ if(BUILD_UTIL)
361369
bitcoin_common
362370
bitcoin_util
363371
)
372+
list(APPEND installable_targets bitcoin-util)
364373
endif()
365374

366375

@@ -406,3 +415,17 @@ endif()
406415
if(BUILD_FUZZ_BINARY)
407416
add_subdirectory(test/fuzz)
408417
endif()
418+
419+
420+
install(TARGETS ${installable_targets}
421+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
422+
)
423+
unset(installable_targets)
424+
425+
if(INSTALL_MAN)
426+
# TODO: these stubs are no longer needed. man pages should be generated at install time.
427+
install(DIRECTORY ../doc/man/
428+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
429+
FILES_MATCHING PATTERN *.1
430+
)
431+
endif()

src/bench/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ endif()
7979
add_test(NAME bench_sanity_check_high_priority
8080
COMMAND bench_bitcoin -sanity-check -priority-level=high
8181
)
82+
83+
install(TARGETS bench_bitcoin
84+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
85+
)

src/kernel/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,10 @@ target_link_libraries(bitcoinkernel
9797
set_target_properties(bitcoinkernel PROPERTIES
9898
CXX_VISIBILITY_PRESET default
9999
)
100+
101+
include(GNUInstallDirs)
102+
install(TARGETS bitcoinkernel
103+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
104+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
105+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
106+
)

src/qt/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,17 @@ if(WITH_MULTIPROCESS)
255255
bitcoin_ipc
256256
)
257257
import_plugins(bitcoin-gui)
258+
list(APPEND installable_targets bitcoin-gui)
258259
if(WIN32)
259260
set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE)
260261
endif()
261262
endif()
262263

264+
install(TARGETS ${installable_targets}
265+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
266+
COMPONENT GUI
267+
)
268+
263269
if(BUILD_GUI_TESTS)
264270
add_subdirectory(test)
265271
endif()

src/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,7 @@ function(add_all_test_targets)
217217
endfunction()
218218

219219
add_all_test_targets()
220+
221+
install(TARGETS test_bitcoin
222+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
223+
)

0 commit comments

Comments
 (0)