Skip to content

Commit

Permalink
firo-tx: add CMake compilation.
Browse files Browse the repository at this point in the history
Improve miscellaneous CMake files.
  • Loading branch information
aleflm committed Feb 10, 2025
1 parent aed6efc commit 6031191
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 37 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ set(COPYRIGHT_HOLDERS "The %s developers")
set(COPYRIGHT_HOLDERS_FINAL "The ${CLIENT_NAME} developers")
set(CLIENT_BUGREPORT "https://github.com/firoorg/firo/issues")

#=============================
# Set Project-wide output folders
#=============================
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()

#=============================
# Language setup
#=============================
Expand Down
2 changes: 2 additions & 0 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ set(CMAKE_OBJDUMP "@OBJDUMP@")
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF)

set(CMAKE_FIND_ROOT_PATH "@depends_prefix@")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Expand Down
39 changes: 23 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if(ENABLE_WALLET)
add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc)
target_link_libraries(bitcoin-wallet
core_interface
bitcoin_wallet
firo_wallet
bitcoin_common
bitcoin_util
Boost::headers
Expand Down Expand Up @@ -253,7 +253,7 @@ if(BUILD_DAEMON)
bitcoin_node
univalue
Boost::thread
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
$<TARGET_NAME_IF_EXISTS:firo_wallet>
)
list(APPEND installable_targets bitcoind)
endif()
Expand All @@ -266,7 +266,7 @@ if(WITH_MULTIPROCESS)
core_interface
bitcoin_node
bitcoin_ipc
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
$<TARGET_NAME_IF_EXISTS:firo_wallet>
)
list(APPEND installable_targets bitcoin-node)

Expand All @@ -288,50 +288,57 @@ if(WITH_MULTIPROCESS)
endif()


add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL
add_library(firo_cli STATIC EXCLUDE_FROM_ALL
rpc/client.cpp
rpc/protocol.cpp
util.cpp
)
target_link_libraries(bitcoin_cli
target_link_libraries(firo_cli
PUBLIC
core_interface
univalue
Boost::filesystem
Boost::thread
Boost::program_options
)
target_include_directories(bitcoin_cli
target_include_directories(firo_cli
PUBLIC
)

# Bitcoin Core RPC client
if(BUILD_CLI)
add_executable(bitcoin-cli bitcoin-cli.cpp)
add_windows_resources(bitcoin-cli bitcoin-cli-res.rc)
target_link_libraries(bitcoin-cli
add_executable(firo-cli bitcoin-cli.cpp)
add_windows_resources(firo-cli bitcoin-cli-res.rc)
target_link_libraries(firo-cli
core_interface
bitcoin_cli
firo_cli
bitcoin_common
bitcoin_util
libevent::extra
libevent::core
)
list(APPEND installable_targets bitcoin-cli)
set_target_properties(bitcoin-cli PROPERTIES OUTPUT_NAME ${FIRO_CLI_NAME})
list(APPEND installable_targets firo-cli)
set_target_properties(firo-cli PROPERTIES OUTPUT_NAME ${FIRO_CLI_NAME})
endif()


if(BUILD_TX)
add_executable(bitcoin-tx bitcoin-tx.cpp)
add_windows_resources(bitcoin-tx bitcoin-tx-res.rc)
target_link_libraries(bitcoin-tx
add_executable(firo-tx bitcoin-tx.cpp
keystore.cpp
script/standard.cpp
)
add_windows_resources(firo-tx bitcoin-tx-res.rc)
target_link_libraries(firo-tx
core_interface
bitcoin_crypto
firo_cli
bitcoin_common
bitcoin_util
univalue
secp256k1pp
secp256k1
)
list(APPEND installable_targets bitcoin-tx)
list(APPEND installable_targets firo-tx)
endif()


Expand Down
10 changes: 10 additions & 0 deletions src/crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

add_subdirectory(progpow)

add_library(bitcoin_crypto STATIC EXCLUDE_FROM_ALL
aes.cpp
chacha20.cpp
Expand All @@ -12,13 +14,21 @@ add_library(bitcoin_crypto STATIC EXCLUDE_FROM_ALL
sha1.cpp
sha256.cpp
sha512.cpp
scrypt.cpp
Lyra2Z/Lyra2.c
Lyra2Z/Lyra2Z.c
Lyra2Z/Sponge.c
Lyra2Z/blake.c
../support/cleanse.cpp
)

target_link_libraries(bitcoin_crypto
PRIVATE
core_interface
${Boost_LIBRARIES}
PUBLIC
ethash
keccak
)

target_include_directories(bitcoin_crypto
Expand Down
29 changes: 29 additions & 0 deletions src/crypto/progpow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

add_library(keccak STATIC EXCLUDE_FROM_ALL
lib/keccak/keccak.c
lib/keccak/keccakf800.c
lib/keccak/keccakf1600.c
)

add_library(ethash STATIC EXCLUDE_FROM_ALL
lib/ethash/ethash.cpp
lib/ethash/managed.cpp
lib/ethash/primes.c
lib/ethash/progpow.cpp
)

target_link_libraries(ethash
PRIVATE
core_interface
${Boost_LIBRARIES}
PUBLIC
keccak
)

target_include_directories(ethash
PUBLIC
${Boost_INCLUDE_DIR}
)
9 changes: 0 additions & 9 deletions src/secp256k1/cmake/FindGMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ find_library(GMP_LIBRARIES
/usr/local/lib
)

# Define this symbol if libgmp is installed
add_compile_definitions(HAVE_LIBGMP=1)
# Define this symbol to use the gmp implementation for num
add_compile_definitions(USE_NUM_GMP=1)
# Define this symbol to use the num-based field inverse implementation
add_compile_definitions(USE_FIELD_INV_NUM=1)
# Define this symbol to use the num-based scalar inverse implementation
add_compile_definitions(USE_SCALAR_INV_NUM=1)

if(GMP_INCLUDES)
file(STRINGS "${GMP_INCLUDES}/gmp.h" gmp_version_str REGEX "^#define[\t ]+__GNU_MP_VERSION[\t ]+[0-9]+")
string(REGEX REPLACE "^#define[\t ]+__GNU_MP_VERSION[\t ]+([0-9]+).*" "\\1" GMP_VERSION_MAJOR "${gmp_version_str}")
Expand Down
30 changes: 21 additions & 9 deletions src/secp256k1/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ include(GNUInstallDirs)
# from being exported.
add_library(secp256k1 OBJECT secp256k1.c)

target_link_libraries(secp256k1 PUBLIC gmp)

set_property(TARGET secp256k1 PROPERTY POSITION_INDEPENDENT_CODE ON)

add_library(secp256k1pp
cpp/GroupElement.cpp
cpp/MultiExponent.cpp
cpp/Scalar.cpp
)

target_link_libraries(secp256k1
PUBLIC
gmp
PRIVATE
OpenSSL::Crypto
)

#=============================
# secp256k1 Configuration
#=============================
# Define this symbol if libgmp is installed
add_compile_definitions(secp256k1 PUBLIC -DHAVE_LIBGMP=1)
# Define this symbol to use the gmp implementation for num
add_compile_definitions(secp256k1 PUBLIC -DUSE_NUM_GMP=1)
# Define this symbol to use the num-based field inverse implementation
add_compile_definitions(secp256k1 PUBLIC -DUSE_FIELD_INV_NUM=1)
# Define this symbol to use the num-based scalar inverse implementation
add_compile_definitions(secp256k1 PUBLIC -DUSE_SCALAR_INV_NUM=1)

add_library(secp256k1pp
cpp/GroupElement.cpp
cpp/MultiExponent.cpp
cpp/Scalar.cpp
)

set_property(TARGET secp256k1pp PROPERTY POSITION_INDEPENDENT_CODE ON)

target_link_libraries(secp256k1pp
PUBLIC secp256k1
PUBLIC secp256k1 gmp
)

add_library(secp256k1_asm INTERFACE)
Expand Down
2 changes: 2 additions & 0 deletions src/secp256k1/src/cpp/GroupElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "../field.h"
#include "../field_impl.h"
#include "../num.h"
#include "../num_impl.h"
#include "../group.h"
#include "../group_impl.h"
#include "../hash.h"
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file COPYING or https://opensource.org/license/mit/.

# Wallet functionality used by bitcoind and bitcoin-wallet executables.
add_library(bitcoin_wallet STATIC EXCLUDE_FROM_ALL
add_library(firo_wallet STATIC EXCLUDE_FROM_ALL
authhelper.cpp
bip39.cpp
crypter.cpp
Expand All @@ -19,7 +19,7 @@ add_library(bitcoin_wallet STATIC EXCLUDE_FROM_ALL
walletexcept.cpp
)

target_link_libraries(bitcoin_wallet
target_link_libraries(firo_wallet
PRIVATE
core_interface
bitcoin_common
Expand All @@ -31,4 +31,4 @@ target_link_libraries(bitcoin_wallet
)

# Firo only supports BDB for wallet storage.
target_link_libraries(bitcoin_wallet PUBLIC BerkeleyDB::BerkeleyDB)
target_link_libraries(firo_wallet PUBLIC BerkeleyDB::BerkeleyDB)

0 comments on commit 6031191

Please sign in to comment.