From 7a36cc79b1450baa1aa40204db5225e6a858224d Mon Sep 17 00:00:00 2001 From: thb-sb Date: Wed, 19 Jul 2023 13:49:38 +0200 Subject: [PATCH] Fix a bug in the CMake script. PR [#207] introduced a check for setting the right suffix to the library, depending on the target OS: https://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L7://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L79 However, mixed with PR [#201] and the `OQS_PROVIDER_BUILD_STATIC` option, the library may be suffixed with the wrong extension: we may end up with a static library named `oqsprovider.dylib`, even if it's an archive: ```shell $ cmake -GNinja \ -DOQS_PROVIDER_BUILD_STATIC=ON \ -B build $ cmake --build build $ file build/lib/oqsprovider.dylib build/lib/oqsprovider.dylib: current ar archive random library $ # ^ should be named `oqsprovider.a`! ``` The check mentioned above is only relevant when oqsprovider is built as a module. This commit fixes this bug and introduces a check in the CircleCI jobs to verify that `oqsprovider.a` is actually produced. [#201](https://github.com/open-quantum-safe/oqs-provider/pull/201) [#207](https://github.com/open-quantum-safe/oqs-provider/pull/207) --- .circleci/config.yml | 4 ++++ oqsprov/CMakeLists.txt | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 89408c4c..578eef48 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,6 +74,7 @@ jobs: name: Run tests command: | if << parameters.OQS_PROVIDER_BUILD_STATIC >> ; then + test -f _build/lib/oqsprovider.a ctest --test-dir _build/ else ./scripts/runtests.sh -V @@ -98,6 +99,7 @@ jobs: name: Run tests (-DNOPUBKEY_IN_PRIVKEY=ON) command: | if << parameters.OQS_PROVIDER_BUILD_STATIC >> ; then + test -f _build/lib/oqsprovider.a ctest --test-dir _build/ else ./scripts/runtests.sh -V @@ -175,6 +177,7 @@ jobs: name: Run tests command: | if << parameters.OQS_PROVIDER_BUILD_STATIC >> ; then + test -f _build/lib/oqsprovider.a ctest --test-dir _build/ --output-on-failure else ./scripts/runtests.sh -V @@ -191,6 +194,7 @@ jobs: name: Run tests command: | if << parameters.OQS_PROVIDER_BUILD_STATIC >> ; then + test -f _build/lib/oqsprovider.a ctest --test-dir _build/ --output-on-failure else ./scripts/runtests.sh -V diff --git a/oqsprov/CMakeLists.txt b/oqsprov/CMakeLists.txt index 9bc7870f..93ba12f3 100644 --- a/oqsprov/CMakeLists.txt +++ b/oqsprov/CMakeLists.txt @@ -58,24 +58,26 @@ set_target_properties(oqsprovider # For Windows DLLs RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -if (APPLE) - # OpenSSL looks for `.dylib` files on XNU-based platforms. - # Because `MODULE` writes to a `.so` file by default, we must explicitely - # set the suffix here. - set_target_properties(oqsprovider - PROPERTIES - SUFFIX ".dylib" - ) -endif() +if (NOT OQS_PROVIDER_BUILD_STATIC) + if (APPLE) + # OpenSSL looks for `.dylib` files on XNU-based platforms. + # Because `MODULE` writes to a `.so` file by default, we must explicitely + # set the suffix here. + set_target_properties(oqsprovider + PROPERTIES + SUFFIX ".dylib" + ) + endif() -if (CYGWIN OR MSVC) - # OpenSSL looks for `.dll` files on Windows platforms. - # Because `MODULE` writes to a `.so` file by default, we must explicitely - # set the suffix here. - set_target_properties(oqsprovider - PROPERTIES - SUFFIX ".dll" - ) + if (CYGWIN OR MSVC) + # OpenSSL looks for `.dll` files on Windows platforms. + # Because `MODULE` writes to a `.so` file by default, we must explicitely + # set the suffix here. + set_target_properties(oqsprovider + PROPERTIES + SUFFIX ".dll" + ) + endif() endif() target_link_libraries(oqsprovider PUBLIC OQS::oqs ${OPENSSL_CRYPTO_LIBRARY} ${OQS_ADDL_SOCKET_LIBS})