Skip to content

Commit

Permalink
Changes needed when building with a static libcrypto on Linux (#584)
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Ashley <[email protected]>
  • Loading branch information
ashman-p authored Dec 12, 2024
1 parent 7e1ee0f commit 8cf2217
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 6 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ if(NOT BUILD_TESTING)
endif()

if (OQS_PROVIDER_BUILD_STATIC)
get_filename_component(OPENSSL_LIB_TYPE ${OPENSSL_CRYPTO_LIBRARY} LAST_EXT)
add_executable(example_static_oqsprovider static_oqsprovider.c)
target_link_libraries(example_static_oqsprovider PRIVATE ${OPENSSL_CRYPTO_LIBRARY} oqsprovider)
if(OPENSSL_LIB_TYPE STREQUAL ".a")
target_link_libraries(example_static_oqsprovider PRIVATE ${OPENSSL_CRYPTO_LIBRARY} oqsprovider)
else()
target_link_libraries(example_static_oqsprovider PRIVATE ${OPENSSL_CRYPTO_LIBRARY} oqsprovider dl pthread )
endif()
targets_set_static_provider(example_static_oqsprovider)
add_test(NAME test_example_static_oqsprovider
COMMAND example_static_oqsprovider)
Expand Down
20 changes: 14 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ set_tests_properties(oqs_signatures
)
endif()

set(REQ_LIBS_T, "")
if (OQS_PROVIDER_BUILD_STATIC)
get_filename_component(OPENSSL_LIB_TYPE ${OPENSSL_CRYPTO_LIBRARY} LAST_EXT)
if(OPENSSL_LIB_TYPE STREQUAL ".a")
set(REQ_LIBS_T "dl" "pthread")
endif()
endif()

add_executable(oqs_test_signatures oqs_test_signatures.c test_common.c)
target_link_libraries(oqs_test_signatures PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_signatures PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})

add_test(
NAME oqs_kems
Expand All @@ -49,7 +57,7 @@ set_tests_properties(oqs_kems
endif()

add_executable(oqs_test_kems oqs_test_kems.c test_common.c)
target_link_libraries(oqs_test_kems PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_kems PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})

add_test(
NAME oqs_groups
Expand All @@ -70,7 +78,7 @@ set_tests_properties(oqs_groups
)
endif()
add_executable(oqs_test_groups oqs_test_groups.c test_common.c tlstest_helpers.c)
target_link_libraries(oqs_test_groups PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_groups PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})

add_test(
NAME oqs_tlssig
Expand All @@ -92,10 +100,10 @@ set_tests_properties(oqs_tlssig
)
endif()
add_executable(oqs_test_tlssig oqs_test_tlssig.c test_common.c tlstest_helpers.c)
target_link_libraries(oqs_test_tlssig PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_tlssig PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})

add_executable(oqs_test_endecode oqs_test_endecode.c test_common.c)
target_link_libraries(oqs_test_endecode PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_endecode PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})
add_test(
NAME oqs_endecode
COMMAND oqs_test_endecode
Expand All @@ -116,7 +124,7 @@ endif()

add_executable(oqs_test_evp_pkey_params oqs_test_evp_pkey_params.c test_common.c)
target_include_directories(oqs_test_evp_pkey_params PRIVATE "../oqsprov")
target_link_libraries(oqs_test_evp_pkey_params PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})
target_link_libraries(oqs_test_evp_pkey_params PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS} ${REQ_LIBS_T})
add_test(
NAME oqs_evp_pkey_params
COMMAND oqs_test_evp_pkey_params
Expand Down

0 comments on commit 8cf2217

Please sign in to comment.