|
| 1 | +# Copyright (c) 2023-present The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or https://opensource.org/license/mit/. |
| 4 | + |
| 5 | +# Must be included before CMAKE_INSTALL_INCLUDEDIR is used. |
| 6 | +include(GNUInstallDirs) |
| 7 | + |
| 8 | +add_library(bitcoinconsensus |
| 9 | + ../support/cleanse.cpp |
| 10 | + bitcoinconsensus.cpp |
| 11 | + ${bitcoin_crypto_base_sources} |
| 12 | + ${bitcoin_consensus_sources} |
| 13 | +) |
| 14 | +target_compile_definitions(bitcoinconsensus |
| 15 | + PRIVATE |
| 16 | + BUILD_BITCOIN_INTERNAL |
| 17 | +) |
| 18 | +target_include_directories(bitcoinconsensus |
| 19 | + PUBLIC |
| 20 | + $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> |
| 21 | + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
| 22 | +) |
| 23 | +target_link_libraries(bitcoinconsensus |
| 24 | + PRIVATE |
| 25 | + core |
| 26 | + secp256k1 |
| 27 | +) |
| 28 | +set_target_properties(bitcoinconsensus PROPERTIES |
| 29 | + SOVERSION 0 |
| 30 | + VERSION 0.0.0 |
| 31 | +) |
| 32 | + |
| 33 | +install(TARGETS bitcoinconsensus |
| 34 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 35 | + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 36 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 37 | +) |
| 38 | +install(FILES bitcoinconsensus.h |
| 39 | + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 40 | +) |
| 41 | + |
| 42 | +include(GeneratePkgConfigFile) |
| 43 | +generate_pkg_config_file(${PROJECT_SOURCE_DIR}/libbitcoinconsensus.pc.in libbitcoinconsensus.pc) |
| 44 | +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbitcoinconsensus.pc |
| 45 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig |
| 46 | +) |
| 47 | + |
| 48 | +function(make_bitcoinconsensus_dll_available target) |
| 49 | + if(WIN32 AND BUILD_SHARED_LIBS) |
| 50 | + # The DLL must reside either in the same folder where the executable is |
| 51 | + # or somewhere in PATH. Using the former option. |
| 52 | + add_custom_command( |
| 53 | + TARGET ${target} POST_BUILD |
| 54 | + COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:bitcoinconsensus> $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_NAME:bitcoinconsensus> |
| 55 | + VERBATIM |
| 56 | + ) |
| 57 | + endif() |
| 58 | +endfunction() |
0 commit comments