diff --git a/cmake/modules/InstallationHelper.cmake b/cmake/modules/InstallationHelper.cmake index 6788847b8..c66f998f5 100644 --- a/cmake/modules/InstallationHelper.cmake +++ b/cmake/modules/InstallationHelper.cmake @@ -1,89 +1,99 @@ # This file contains facilities for installing the files. include(GNUInstallDirs) function(install_target _target) cmake_parse_arguments(ARG "" "COMPONENT" "" ${ARGN} ) if(NOT ARG_COMPONENT) set(ARG_COMPONENT ${PROJECT_NAME}) endif() install( TARGETS ${_target} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${ARG_COMPONENT} ${ARG_UNPARSED_ARGUMENTS} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT ${ARG_COMPONENT} ${ARG_UNPARSED_ARGUMENTS} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT ${ARG_COMPONENT} ${ARG_UNPARSED_ARGUMENTS} PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT ${ARG_COMPONENT} ${ARG_UNPARSED_ARGUMENTS} ) endfunction() function(install_shared_library NAME) cmake_parse_arguments(ARG "" "" "PUBLIC_HEADER" ${ARGN} ) set(_sources ${ARG_UNPARSED_ARGUMENTS}) get_target_property(_target_type ${NAME} TYPE) if(_target_type STREQUAL "SHARED_LIBRARY") set(_shared_name "${NAME}") target_sources(${NAME} PRIVATE ${_sources}) else() set(_shared_name "${NAME}-shared") add_library(${_shared_name} SHARED ${_sources}) target_link_libraries(${_shared_name} ${NAME}) endif() if(ARG_PUBLIC_HEADER) set_property(TARGET ${_shared_name} PROPERTY PUBLIC_HEADER ${ARG_PUBLIC_HEADER}) endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # FIXME For compatibility reason with autotools, the version is set # to 0.0.0 (major being actually 0). This is obviously wrong and the # version of the library should reflect the version of the release. # On platforms other than linux, only the major version (0) is used. # Replace the VERSION line with the statement below to set the # correct version: # set(_properties VERSION "${CMAKE_PROJECT_VERSION}") list(APPEND _properties VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.0.0") else() list(APPEND _properties VERSION "${CMAKE_PROJECT_VERSION_MAJOR}") endif() # For autotools compatibility, rename the library to ${OUTPUT_NAME}-0.dll if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND _properties OUTPUT_NAME "${NAME}-${CMAKE_PROJECT_VERSION_MAJOR}") # DLL_EXPORT is defined by libtool, and is expected by some sources. target_compile_definitions(${_shared_name} PRIVATE DLL_EXPORT) else() list(APPEND _properties OUTPUT_NAME "${NAME}") endif() list(APPEND _properties SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") set_target_properties(${_shared_name} PROPERTIES ${_properties}) install_target(${_shared_name}) endfunction() + +function(install_manpages COMPONENT) + set(MAN_DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") + + install( + FILES ${ARGN} + DESTINATION "${MAN_DESTINATION}" + COMPONENT "${COMPONENT}" + ) +endfunction() diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index d08b60770..9cea4779f 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,41 +1,20 @@ # Copyright (c) 2019 The Bitcoin developers -include(GNUInstallDirs) -set(MAN_DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") +include(InstallationHelper) -install( - FILES bitcoind.1 - DESTINATION "${MAN_DESTINATION}" - COMPONENT bitcoind -) +install_manpages(bitcoind bitcoind.1) if(BUILD_BITCOIN_CLI) - install( - FILES bitcoin-cli.1 - DESTINATION "${MAN_DESTINATION}" - COMPONENT bitcoind - ) + install_manpages(bitcoind bitcoin-cli.1) endif() if(BUILD_BITCOIN_TX) - install( - FILES bitcoin-tx.1 - DESTINATION "${MAN_DESTINATION}" - COMPONENT bitcoind - ) + install_manpages(bitcoind bitcoin-tx.1) endif() if(BUILD_BITCOIN_QT) - install( - FILES bitcoin-qt.1 - DESTINATION "${MAN_DESTINATION}" - COMPONENT bitcoin-qt - ) + install_manpages(bitcoin-qt bitcoin-qt.1) endif() if(BUILD_BITCOIN_WALLET) - install( - FILES bitcoin-wallet.1 - DESTINATION "${MAN_DESTINATION}" - COMPONENT bitcoin-wallet - ) + install_manpages(bitcoin-wallet bitcoin-wallet.1) endif()