cmake: add optional source files to bitcoin_crypto directly

This commit is contained in:
Daniel Pfeifer 2024-11-11 12:11:36 +01:00
parent 19f277711e
commit ed2cd60878
2 changed files with 17 additions and 25 deletions

View file

@ -8,7 +8,7 @@ declare -A LIBS
LIBS[cli]="libbitcoin_cli.a"
LIBS[common]="libbitcoin_common.a"
LIBS[consensus]="libbitcoin_consensus.a"
LIBS[crypto]="crypto/libbitcoin_crypto.a crypto/libbitcoin_crypto_x86_shani.a crypto/libbitcoin_crypto_sse41.a crypto/libbitcoin_crypto_avx2.a"
LIBS[crypto]="crypto/libbitcoin_crypto.a"
LIBS[node]="libbitcoin_node.a"
LIBS[util]="util/libbitcoin_util.a"
LIBS[wallet]="wallet/libbitcoin_wallet.a"

View file

@ -28,41 +28,33 @@ target_link_libraries(bitcoin_crypto
)
if(HAVE_SSE41)
add_library(bitcoin_crypto_sse41 STATIC EXCLUDE_FROM_ALL
sha256_sse41.cpp
target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_SSE41)
target_sources(bitcoin_crypto PRIVATE sha256_sse41.cpp)
set_property(SOURCE sha256_sse41.cpp PROPERTY
COMPILE_OPTIONS ${SSE41_CXXFLAGS}
)
target_compile_definitions(bitcoin_crypto_sse41 PUBLIC ENABLE_SSE41)
target_compile_options(bitcoin_crypto_sse41 PRIVATE ${SSE41_CXXFLAGS})
target_link_libraries(bitcoin_crypto_sse41 PRIVATE core_interface)
target_link_libraries(bitcoin_crypto PRIVATE bitcoin_crypto_sse41)
endif()
if(HAVE_AVX2)
add_library(bitcoin_crypto_avx2 STATIC EXCLUDE_FROM_ALL
sha256_avx2.cpp
target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_AVX2)
target_sources(bitcoin_crypto PRIVATE sha256_avx2.cpp)
set_property(SOURCE sha256_avx2.cpp PROPERTY
COMPILE_OPTIONS ${AVX2_CXXFLAGS}
)
target_compile_definitions(bitcoin_crypto_avx2 PUBLIC ENABLE_AVX2)
target_compile_options(bitcoin_crypto_avx2 PRIVATE ${AVX2_CXXFLAGS})
target_link_libraries(bitcoin_crypto_avx2 PRIVATE core_interface)
target_link_libraries(bitcoin_crypto PRIVATE bitcoin_crypto_avx2)
endif()
if(HAVE_SSE41 AND HAVE_X86_SHANI)
add_library(bitcoin_crypto_x86_shani STATIC EXCLUDE_FROM_ALL
sha256_x86_shani.cpp
target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_SSE41 ENABLE_X86_SHANI)
target_sources(bitcoin_crypto PRIVATE sha256_x86_shani.cpp)
set_property(SOURCE sha256_x86_shani.cpp PROPERTY
COMPILE_OPTIONS ${X86_SHANI_CXXFLAGS}
)
target_compile_definitions(bitcoin_crypto_x86_shani PUBLIC ENABLE_SSE41 ENABLE_X86_SHANI)
target_compile_options(bitcoin_crypto_x86_shani PRIVATE ${X86_SHANI_CXXFLAGS})
target_link_libraries(bitcoin_crypto_x86_shani PRIVATE core_interface)
target_link_libraries(bitcoin_crypto PRIVATE bitcoin_crypto_x86_shani)
endif()
if(HAVE_ARM_SHANI)
add_library(bitcoin_crypto_arm_shani STATIC EXCLUDE_FROM_ALL
sha256_arm_shani.cpp
target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_ARM_SHANI)
target_sources(bitcoin_crypto PRIVATE sha256_arm_shani.cpp)
set_property(SOURCE sha256_arm_shani.cpp PROPERTY
COMPILE_OPTIONS ${ARM_SHANI_CXXFLAGS}
)
target_compile_definitions(bitcoin_crypto_arm_shani PUBLIC ENABLE_ARM_SHANI)
target_compile_options(bitcoin_crypto_arm_shani PRIVATE ${ARM_SHANI_CXXFLAGS})
target_link_libraries(bitcoin_crypto_arm_shani PRIVATE core_interface)
target_link_libraries(bitcoin_crypto PRIVATE bitcoin_crypto_arm_shani)
endif()