diff options
author | vnugent <public@vaughnnugent.com> | 2024-08-17 12:18:05 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-08-17 12:18:05 -0400 |
commit | 0925f5c786badb715d564e991d2306632c2aecad (patch) | |
tree | bd46009803c2a136eb85ea9d8566f595ba387291 /CMakeLists.txt | |
parent | 614c02097f5f173299948df279c2d3e2f9f748f9 (diff) | |
parent | 756a184762db4cb0a9945d066b59d0e2f58c18d8 (diff) |
Merge branch 'develop' into c-sharp
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1f707..4a10738 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ project( set(_NC_PROJ_NAME "noscrypt") option(NC_BUILD_TESTS "Build tests" OFF) +option(NC_ENABLE_UTILS "Enables the sidecar utility library" OFF) option(NC_DISABLE_INPUT_VALIDATION "Disables public function input validation" OFF) option(NC_FETCH_MBEDTLS "Fetch Mbed-TLS from it's source repository locally" OFF) option(NC_FETCH_SECP256K1 "Fetch and locally build secp256k1 source code" ON) @@ -50,7 +51,7 @@ if(NC_FETCH_SECP256K1) FetchContent_Declare( libsecp256k1 GIT_REPOSITORY https://github.com/bitcoin-core/secp256k1 - GIT_TAG e3a885d42a7800c1ccebad94ad1e2b82c4df5c65 # release-0.5.0 + GIT_TAG 642c885b6102725e25623738529895a95addc4f4 # release-0.5.1 GIT_PROGRESS TRUE ) @@ -94,6 +95,17 @@ set(NOSCRYPT_HEADERS "src/nc-crypto.h" ) +#if utils are enabled, add the source files +if(NC_ENABLE_UTILS) + list(APPEND NOSCRYPT_SRCS "src/noscryptutil.c") + list(APPEND NOSCRYPT_HEADERS "include/noscryptutil.h") + + #notify the project that utils are enabled + list(APPEND NC_PROJ_DEFINTIONS NC_ENABLE_UTILS) + + message(STATUS "Utilities libraries are enabled") +endif() + #static/shared library add_library(${_NC_PROJ_NAME} SHARED ${NOSCRYPT_SRCS} ${NOSCRYPT_HEADERS}) add_library(${_NC_PROJ_NAME}_static STATIC ${NOSCRYPT_SRCS} ${NOSCRYPT_HEADERS}) @@ -131,19 +143,6 @@ target_include_directories(${_NC_PROJ_NAME}_static SYSTEM PUBLIC vendor/secp256k # ############################################# -#try to load openssl quietly in order to check for its availability -find_package(OpenSSL QUIET) - -#setup default linking to crypto libraries for certain plaftorms. -#Windows defaults to bcrypt, openssl otherwise if installed -if(CRYPTO_LIB STREQUAL "") - if(MSVC) - set(CRYPTO_LIB "bcrypt") - elseif(OPENSSL_FOUND) - set(CRYPTO_LIB "openssl") - endif() -endif() - #Include mbedtls if enabled if(NC_FETCH_MBEDTLS) @@ -172,6 +171,22 @@ if(NC_FETCH_MBEDTLS) endif() +#try to load openssl quietly in order to check for its availability +find_package(OpenSSL QUIET) + +#setup default linking to crypto libraries for certain plaftorms. +#Windows defaults to bcrypt, openssl otherwise if installed +if(CRYPTO_LIB STREQUAL "") + if(MSVC) + set(CRYPTO_LIB "bcrypt") + elseif(OPENSSL_FOUND) + set(CRYPTO_LIB "openssl") + endif() + + message(STATUS "No crypto library was specified, defaulting to ${CRYPTO_LIB}") +endif() + + #if mbedtls linking is enabled target the library if(CRYPTO_LIB STREQUAL "mbedtls") @@ -364,11 +379,13 @@ if(NC_BUILD_TESTS) #add test executable and link to shared library for more realistic usage add_executable(nctest tests/test.c) target_link_libraries(nctest ${_NC_PROJ_NAME}) + target_include_directories(nctest PRIVATE include) target_include_directories(nctest PRIVATE src) #allow access to internal headers #enable c11 for testing target_compile_features(nctest PRIVATE c_std_11) + target_compile_definitions(nctest PRIVATE ${NC_PROJ_DEFINTIONS}) enable_testing() @@ -404,9 +421,20 @@ install(TARGETS ${_NC_PROJ_NAME}_static INCLUDES DESTINATION include ) -install(FILES - include/noscrypt.h +SET(NC_INSTALL_HEADERS + include/noscrypt.h #static install headers include/platform.h +) + +if(NC_ENABLE_UTILS) + LIST(APPEND + NC_INSTALL_HEADERS + include/noscryptutil.h + ) +endif() + +install(FILES + ${NC_INSTALL_HEADERS} DESTINATION noscrypt ) |