diff --git a/Builds/CMake/RippledInstall.cmake b/Builds/CMake/RippledInstall.cmake index 457452219..3cdeca9e6 100644 --- a/Builds/CMake/RippledInstall.cmake +++ b/Builds/CMake/RippledInstall.cmake @@ -4,7 +4,6 @@ install ( TARGETS - secp256k1 ed25519-donna common opts @@ -16,6 +15,18 @@ install ( ARCHIVE DESTINATION lib RUNTIME DESTINATION bin INCLUDES DESTINATION include) + +if(${INSTALL_SECP256K1}) +install ( + TARGETS + secp256k1 + EXPORT RippleExports + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include) +endif() + install (EXPORT RippleExports FILE RippleTargets.cmake NAMESPACE Ripple:: diff --git a/Builds/CMake/deps/Findsecp256k1.cmake b/Builds/CMake/deps/Findsecp256k1.cmake new file mode 100644 index 000000000..f8caf0cd0 --- /dev/null +++ b/Builds/CMake/deps/Findsecp256k1.cmake @@ -0,0 +1,22 @@ +find_package (PkgConfig REQUIRED) +pkg_search_module (secp256k1_PC QUIET libsecp256k1) + +if(static) + set(SECP256K1_LIB libsecp256k1.a) +else() + set(SECP256K1_LIB secp256k1) +endif() + +find_library(secp256k1 + NAMES ${SECP256K1_LIB} + HINTS + ${secp256k1_PC_LIBDIR} + ${secp256k1_PC_LIBRARY_PATHS} + NO_DEFAULT_PATH) + +find_path (SECP256K1_INCLUDE_DIR + NAMES secp256k1.h + HINTS + ${secp256k1_PC_INCLUDEDIR} + ${secp256k1_PC_INCLUDEDIRS} + NO_DEFAULT_PATH) diff --git a/Builds/CMake/deps/Secp256k1.cmake b/Builds/CMake/deps/Secp256k1.cmake index 8f61b3044..944470024 100644 --- a/Builds/CMake/deps/Secp256k1.cmake +++ b/Builds/CMake/deps/Secp256k1.cmake @@ -2,34 +2,58 @@ NIH dep: secp256k1 #]===================================================================] -add_library (secp256k1 STATIC - src/secp256k1/src/secp256k1.c) -target_compile_definitions (secp256k1 - PRIVATE - USE_NUM_NONE - USE_FIELD_10X26 - USE_FIELD_INV_BUILTIN - USE_SCALAR_8X32 - USE_SCALAR_INV_BUILTIN) -target_include_directories (secp256k1 - PUBLIC - $ - $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/secp256k1) -target_compile_options (secp256k1 - PRIVATE - $<$:-wd4319> - $<$>: - -Wno-deprecated-declarations - -Wno-unused-function - > - $<$:-Wno-nonnull-compare>) -add_library (NIH::secp256k1 ALIAS secp256k1) -target_link_libraries (ripple_libs INTERFACE NIH::secp256k1) +add_library (secp256k1_lib STATIC IMPORTED GLOBAL) + +if (NOT WIN32) + find_package(secp256k1) +endif() + + +if(secp256k1) + set_target_properties (secp256k1_lib PROPERTIES + IMPORTED_LOCATION_DEBUG + ${secp256k1} + IMPORTED_LOCATION_RELEASE + ${secp256k1} + INTERFACE_INCLUDE_DIRECTORIES + ${SECP256K1_INCLUDE_DIR}) + + add_library (secp256k1 ALIAS secp256k1_lib) + add_library (NIH::secp256k1 ALIAS secp256k1_lib) + +else() + set(INSTALL_SECP256K1 true) + + add_library (secp256k1 STATIC + src/secp256k1/src/secp256k1.c) + target_compile_definitions (secp256k1 + PRIVATE + USE_NUM_NONE + USE_FIELD_10X26 + USE_FIELD_INV_BUILTIN + USE_SCALAR_8X32 + USE_SCALAR_INV_BUILTIN) + target_include_directories (secp256k1 + PUBLIC + $ + $ + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/secp256k1) + target_compile_options (secp256k1 + PRIVATE + $<$:-wd4319> + $<$>: + -Wno-deprecated-declarations + -Wno-unused-function + > + $<$:-Wno-nonnull-compare>) + target_link_libraries (ripple_libs INTERFACE NIH::secp256k1) #[===========================[ - headers installation + headers installation #]===========================] -install ( - FILES - src/secp256k1/include/secp256k1.h + install ( + FILES + src/secp256k1/include/secp256k1.h DESTINATION include/secp256k1/include) + + add_library (NIH::secp256k1 ALIAS secp256k1) +endif()