From c4304e3d22c80a2574ecaeec9053ad6283c03e85 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 22 Mar 2023 18:48:25 +0100 Subject: [PATCH] CMakeLists.txt: move add_library() to top of "library" section so that we don't need to use variables for everything. --- CMakeLists.txt | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ced110d..7d05286 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ set(EC_LIB "libsecp256k1" CACHE STRING "What elliptic curve implementation to us set( LIB_NAME ${PROJECT_NAME} ) -set( LIB_SOURCE +add_library( ${LIB_NAME} STATIC src/base58.cpp src/ec.cpp src/WIF.cpp @@ -57,23 +57,37 @@ set( LIB_SOURCE src/openssl/hash.cpp ) +target_include_directories( ${LIB_NAME} + PUBLIC + $ + $ +) + +# Skip prefix on unix. +if (UNIX) + set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") +endif() + # OpenSSL include(OpenSSL) +target_link_libraries( ${LIB_NAME} PRIVATE OpenSSL::Crypto) # EC Implementation if (${EC_LIB} STREQUAL "libsecp256k1") add_subdirectory( vendor/secp256k1 ) # Note: this is a big hack to get cmake to not export this library. # Must be a better way, but works so cba. - LIST(APPEND LIB_PRIVATE_INCLUDE $>) - LIST(APPEND LIB_SOURCE + target_include_directories( ${LIB_NAME} + PRIVATE $> + ) + target_sources( ${LIB_NAME} PRIVATE $ src/libsecp256k1/ec.cpp src/libsecp256k1/ecdsa.cpp ) elseif (${EC_LIB} STREQUAL "openssl") - LIST(APPEND LIB_SOURCE + target_sources( ${LIB_NAME} PRIVATE src/openssl/ec.cpp src/openssl/ecdsa.cpp src/openssl/helpers.c @@ -83,25 +97,6 @@ else() message(FATAL_ERROR "Invalid ec implementation: " ${EC_LIB}) endif() -add_library( ${LIB_NAME} STATIC ${LIB_SOURCE} ) - -# Skip prefix on unix. -if (UNIX) - set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") -endif() - - -target_link_libraries( ${LIB_NAME} - PRIVATE OpenSSL::Crypto -) - -target_include_directories( ${LIB_NAME} - PRIVATE ${LIB_PRIVATE_INCLUDE} - PUBLIC - $ - $ -) - # -------------------------------- # Tests # --------------------------------