Skip to content

Commit

Permalink
Allow windows linking of test programs (open-quantum-safe#1751)
Browse files Browse the repository at this point in the history
The kat_kem and kat_sig programs could not be linked when building natively on windows. This was caused by multiple definitions of symbols. By using the /FORCE:MULTIPLE compiler option, this is allowed, similar in spirit to what was already used for cross-compiling to Windows.

Fixes open-quantum-safe#1749

Signed-off-by: Mattias Lindblad <[email protected]>
  • Loading branch information
matlimatli authored Apr 7, 2024
1 parent 32afec8 commit 701dea5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ target_link_libraries(example_kem PRIVATE ${TEST_DEPS})

add_executable(kat_kem kat_kem.c test_helpers.c)
target_link_libraries(kat_kem PRIVATE ${TEST_DEPS})
if(CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_SHARED_LIBS)
# workaround for Windows .dll cross-compiling
target_link_options(kat_kem PRIVATE -Wl,--allow-multiple-definition)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_SHARED_LIBS)
# workaround for Windows .dll
if(CMAKE_CROSSCOMPILING)
target_link_options(kat_kem PRIVATE -Wl,--allow-multiple-definition)
else()
target_link_options(kat_kem PRIVATE "/FORCE:MULTIPLE")
endif()
endif()

add_executable(test_kem test_kem.c)
Expand All @@ -86,9 +90,13 @@ target_link_libraries(example_sig PRIVATE ${TEST_DEPS})

add_executable(kat_sig kat_sig.c test_helpers.c)
target_link_libraries(kat_sig PRIVATE ${TEST_DEPS})
if(CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_SHARED_LIBS)
# workaround for Windows .dll cross-compiling
target_link_options(kat_sig PRIVATE -Wl,--allow-multiple-definition)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_SHARED_LIBS)
# workaround for Windows .dll
if(CMAKE_CROSSCOMPILING)
target_link_options(kat_sig PRIVATE -Wl,--allow-multiple-definition)
else()
target_link_options(kat_sig PRIVATE "/FORCE:MULTIPLE")
endif()
endif()

add_executable(test_sig test_sig.c)
Expand Down

0 comments on commit 701dea5

Please sign in to comment.