Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/CMakeLists.txt
Show First 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | add_custom_command( | ||||
OUTPUT src/ecmult_static_context.h | OUTPUT src/ecmult_static_context.h | ||||
COMMAND gen_context | COMMAND gen_context | ||||
) | ) | ||||
target_sources(secp256k1 PRIVATE src/ecmult_static_context.h) | target_sources(secp256k1 PRIVATE src/ecmult_static_context.h) | ||||
endif() | endif() | ||||
include(InstallationHelper) | include(InstallationHelper) | ||||
# If this project is not the top level project, then don't install by default | |||||
get_directory_property(SECP256K1_PARENT_DIRECTORY PARENT_DIRECTORY) | |||||
if(SECP256K1_PARENT_DIRECTORY) | |||||
set(SECP256K1_INSTALL_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) | |||||
endif() | |||||
if(BUILD_SHARED_LIBS) | if(BUILD_SHARED_LIBS) | ||||
install_shared_library(secp256k1 PUBLIC_HEADER ${SECP256K1_PUBLIC_HEADERS}) | install_shared_library(secp256k1 | ||||
PUBLIC_HEADER ${SECP256K1_PUBLIC_HEADERS} | |||||
${SECP256K1_INSTALL_EXCLUDE_FROM_ALL} | |||||
) | |||||
else() | else() | ||||
set_property(TARGET secp256k1 PROPERTY PUBLIC_HEADER ${SECP256K1_PUBLIC_HEADERS}) | set_property(TARGET secp256k1 PROPERTY PUBLIC_HEADER ${SECP256K1_PUBLIC_HEADERS}) | ||||
install_target(secp256k1) | install_target(secp256k1 ${SECP256K1_INSTALL_EXCLUDE_FROM_ALL}) | ||||
endif() | endif() | ||||
# Generate the config | # Generate the config | ||||
configure_file(src/libsecp256k1-config.h.cmake.in src/libsecp256k1-config.h ESCAPE_QUOTES) | configure_file(src/libsecp256k1-config.h.cmake.in src/libsecp256k1-config.h ESCAPE_QUOTES) | ||||
target_compile_definitions(secp256k1 PRIVATE HAVE_CONFIG_H SECP256K1_BUILD) | target_compile_definitions(secp256k1 PRIVATE HAVE_CONFIG_H SECP256K1_BUILD) | ||||
# Build the Java binding | # Build the Java binding | ||||
option(SECP256K1_ENABLE_JNI "Enable the Java Native Interface binding" OFF) | option(SECP256K1_ENABLE_JNI "Enable the Java Native Interface binding" OFF) | ||||
if(SECP256K1_ENABLE_JNI) | if(SECP256K1_ENABLE_JNI) | ||||
if(NOT SECP256K1_ENABLE_MODULE_ECDH) | if(NOT SECP256K1_ENABLE_MODULE_ECDH) | ||||
message(FATAL_ERROR "The secp256k1 JNI support requires ECDH. Try again with -DSECP256K1_ENABLE_MODULE_ECDH=ON.") | message(FATAL_ERROR "The secp256k1 JNI support requires ECDH. Try again with -DSECP256K1_ENABLE_MODULE_ECDH=ON.") | ||||
endif() | endif() | ||||
find_package(Java REQUIRED) | find_package(Java REQUIRED) | ||||
find_package(JNI REQUIRED) | find_package(JNI REQUIRED) | ||||
include(UseJava) | include(UseJava) | ||||
add_library(secp256k1_jni SHARED | add_library(secp256k1_jni SHARED | ||||
src/java/org_bitcoin_NativeSecp256k1.c | src/java/org_bitcoin_NativeSecp256k1.c | ||||
src/java/org_bitcoin_Secp256k1Context.c | src/java/org_bitcoin_Secp256k1Context.c | ||||
) | ) | ||||
install_shared_library(secp256k1_jni) | install_shared_library(secp256k1_jni ${SECP256K1_INSTALL_EXCLUDE_FROM_ALL}) | ||||
target_include_directories(secp256k1_jni PUBLIC ${JNI_INCLUDE_DIRS}) | target_include_directories(secp256k1_jni PUBLIC ${JNI_INCLUDE_DIRS}) | ||||
# As per CMake documentation: the POSITION_INDEPENDENT_CODE property is set | # As per CMake documentation: the POSITION_INDEPENDENT_CODE property is set | ||||
# when a target is created. It defaults to True for SHARED or MODULE library | # when a target is created. It defaults to True for SHARED or MODULE library | ||||
# targets and False otherwise. | # targets and False otherwise. | ||||
# The secp256ki_jni library being shared, the property is set and it will | # The secp256ki_jni library being shared, the property is set and it will | ||||
# build with PIC enabled. But the secp256k1 dependency might not have the | # build with PIC enabled. But the secp256k1 dependency might not have the | ||||
# property set, so it's associated source files won't be built with PIC | # property set, so it's associated source files won't be built with PIC | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |