Skip to content

Commit

Permalink
Link Threads in common and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zxjtan committed Oct 13, 2023
1 parent 00ec7b3 commit 4dc6f09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ else()
target_compile_definitions(common PRIVATE OQS_HAVE_GETENTROPY)
endif()
endif()
if(CMAKE_USE_PTHREADS_INIT)
target_link_libraries(common PRIVATE Threads::Threads)
endif()

# check available functions to perform aligned mallocs
check_symbol_exists(aligned_alloc stdlib.h CMAKE_HAVE_ALIGNED_ALLOC)
Expand Down
22 changes: 10 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ if(NOT WIN32)
else()
set(INTERNAL_TEST_DEPS ${LIBM})
endif()
if(CMAKE_USE_PTHREADS_INIT)
set(INTERNAL_TEST_DEPS ${INTERNAL_TEST_DEPS} Threads::Threads)
endif()
if(DEFINED SANITIZER_LD_FLAGS)
set(INTERNAL_TEST_DEPS "${INTERNAL_TEST_DEPS} ${SANITIZER_LD_FLAGS}")
set(INTERNAL_TEST_DEPS ${INTERNAL_TEST_DEPS} ${SANITIZER_LD_FLAGS})
endif()
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/git_commit.sh OUTPUT_VARIABLE GIT_COMMIT)
add_definitions(-DOQS_COMPILE_GIT_COMMIT="${GIT_COMMIT}")
Expand Down Expand Up @@ -59,6 +62,9 @@ else()
endif()

set(API_TEST_DEPS oqs ${LIBM})
if(CMAKE_USE_PTHREADS_INIT)
set(API_TEST_DEPS ${API_TEST_DEPS} Threads::Threads)
endif()

# KEM API tests
add_executable(example_kem example_kem.c)
Expand All @@ -68,11 +74,7 @@ add_executable(kat_kem kat_kem.c)
target_link_libraries(kat_kem PRIVATE ${API_TEST_DEPS})

add_executable(test_kem test_kem.c)
if((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_C_COMPILER_ID STREQUAL "GNU"))
target_link_libraries(test_kem PRIVATE ${API_TEST_DEPS} Threads::Threads)
else ()
target_link_libraries(test_kem PRIVATE ${API_TEST_DEPS})
endif()
target_link_libraries(test_kem PRIVATE ${API_TEST_DEPS})

add_executable(test_kem_mem test_kem_mem.c)
target_link_libraries(test_kem_mem PRIVATE ${API_TEST_DEPS})
Expand All @@ -88,11 +90,7 @@ add_executable(kat_sig kat_sig.c)
target_link_libraries(kat_sig PRIVATE ${API_TEST_DEPS})

add_executable(test_sig test_sig.c)
if((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_C_COMPILER_ID STREQUAL "GNU"))
target_link_libraries(test_sig PRIVATE ${API_TEST_DEPS} Threads::Threads)
else ()
target_link_libraries(test_sig PRIVATE ${API_TEST_DEPS})
endif()
target_link_libraries(test_sig PRIVATE ${API_TEST_DEPS})

add_executable(test_sig_mem test_sig_mem.c)
target_link_libraries(test_sig_mem PRIVATE ${API_TEST_DEPS})
Expand All @@ -118,7 +116,7 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
# generating with Ninja
set_target_properties(
dump_alg_info example_kem kat_kem test_kem example_sig kat_sig test_sig test_sig_mem test_kem_mem speed_kem speed_sig
PROPERTIES
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/tests"
Expand Down

0 comments on commit 4dc6f09

Please sign in to comment.