# Must be included before CMAKE_INSTALL_INCLUDEDIR is used. include(GNUInstallDirs) set(${PROJECT_NAME}_installables "") if(SECP256K1_ASM STREQUAL "arm") add_library(common OBJECT asm/field_10x26_arm.s ) set(common_obj "$") else() set(common_obj "") endif() add_library(precomputed OBJECT precomputed_ecmult.c precomputed_ecmult_gen.c ) set(internal_obj "$" "${common_obj}") add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL secp256k1.c ${internal_obj} ) target_include_directories(${PROJECT_NAME} INTERFACE $ ) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:DLL_EXPORT> ) set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_LIB_VERSION_CURRENT}.${${PROJECT_NAME}_LIB_VERSION_AGE}.${${PROJECT_NAME}_LIB_VERSION_REVISION}" SOVERSION "${${PROJECT_NAME}_LIB_VERSION_CURRENT}" ) if(SECP256K1_BUILD_SHARED) get_target_property(use_pic ${PROJECT_NAME} POSITION_INDEPENDENT_CODE) set_target_properties(precomputed PROPERTIES POSITION_INDEPENDENT_CODE ${use_pic}) set_target_properties(${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_ALL FALSE) list(APPEND ${PROJECT_NAME}_installables ${PROJECT_NAME}) endif() add_library(${PROJECT_NAME}_static STATIC EXCLUDE_FROM_ALL secp256k1.c ${internal_obj} ) target_include_directories(${PROJECT_NAME}_static INTERFACE $ ) if(NOT MSVC) set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME} ) endif() if(SECP256K1_BUILD_STATIC) set_target_properties(${PROJECT_NAME}_static PROPERTIES EXCLUDE_FROM_ALL FALSE) list(APPEND ${PROJECT_NAME}_installables ${PROJECT_NAME}_static) endif() add_library(binary_interface INTERFACE) target_compile_definitions(binary_interface INTERFACE $<$:_CRT_SECURE_NO_WARNINGS> ) add_library(link_library INTERFACE) if(SECP256K1_BUILD_SHARED) target_link_libraries(link_library INTERFACE ${PROJECT_NAME}) elseif(SECP256K1_BUILD_STATIC) target_link_libraries(link_library INTERFACE ${PROJECT_NAME}_static) endif() if(SECP256K1_BUILD_BENCHMARK) add_executable(bench bench.c) target_link_libraries(bench binary_interface link_library) add_executable(bench_internal bench_internal.c ${internal_obj}) target_link_libraries(bench_internal binary_interface) add_executable(bench_ecmult bench_ecmult.c ${internal_obj}) target_link_libraries(bench_ecmult binary_interface) endif() if(SECP256K1_BUILD_TESTS) add_executable(noverify_tests tests.c ${internal_obj}) target_link_libraries(noverify_tests binary_interface) add_test(noverify_tests noverify_tests) if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage") add_executable(tests tests.c ${internal_obj}) target_compile_definitions(tests PRIVATE VERIFY) target_link_libraries(tests binary_interface) add_test(tests tests) endif() endif() if(SECP256K1_BUILD_EXHAUSTIVE_TESTS) # Note: do not include $ in exhaustive_tests (it uses runtime-generated tables). add_executable(exhaustive_tests tests_exhaustive.c ${common_obj}) target_compile_definitions(exhaustive_tests PRIVATE $<$>:VERIFY>) target_link_libraries(exhaustive_tests binary_interface) add_test(exhaustive_tests exhaustive_tests) endif() if(SECP256K1_BUILD_CTIME_TESTS) add_executable(ctime_tests ctime_tests.c) target_link_libraries(ctime_tests binary_interface link_library) endif() install(TARGETS ${${PROJECT_NAME}_installables} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) set(${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1.h" "${PROJECT_SOURCE_DIR}/include/secp256k1_preallocated.h" ) if(SECP256K1_ENABLE_MODULE_ECDH) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_ecdh.h") endif() if(SECP256K1_ENABLE_MODULE_RECOVERY) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_recovery.h") endif() if(SECP256K1_ENABLE_MODULE_EXTRAKEYS) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_extrakeys.h") endif() if(SECP256K1_ENABLE_MODULE_SCHNORRSIG) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_schnorrsig.h") endif() install(FILES ${${PROJECT_NAME}_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )