From ba13edc67354f2ccdbf5698dda4d39a215f25ec4 Mon Sep 17 00:00:00 2001 From: thb-sb Date: Wed, 26 Jun 2024 07:55:46 +0200 Subject: [PATCH] Fix #440: disable tests and examples using `BUILD_TESTING`. By providing cmake with `BUILD_TESTING=OFF`, no test or example will be built. `BUILD_TESTING` is `ON` by default, since we are using [`enable_testing`] along with `CTest`. [`enable_testing`]: https://cmake.org/cmake/help/latest/command/enable_testing.html Signed-off-by: thb-sb --- CMakeLists.txt | 1 + CONFIGURE.md | 4 ++++ examples/CMakeLists.txt | 4 ++++ test/CMakeLists.txt | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f721499..364c5f5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ endfunction() add_subdirectory(oqsprov) # Testing +include(CTest) enable_testing() add_subdirectory(test) diff --git a/CONFIGURE.md b/CONFIGURE.md index 626513d3..6fa66003 100644 --- a/CONFIGURE.md +++ b/CONFIGURE.md @@ -97,6 +97,10 @@ void load_oqs_provider(OSSL_LIB_CTX *libctx) { See [`examples/static_oqsprovider.c`](examples/static_oqsprovider.c) for a complete example of how to load oqsprovider using `OSSL_PROVIDER_add_builtin`. +### BUILD_TESTING + +By setting this to "OFF", no tests or examples will be compiled. + ## Convenience build script options For anyone interested in building the complete software stack diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 43ec0ca8..d221343c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,7 @@ +if(NOT BUILD_TESTING) + return() +endif() + if (OQS_PROVIDER_BUILD_STATIC) add_executable(example_static_oqsprovider static_oqsprovider.c) target_link_libraries(example_static_oqsprovider PRIVATE ${OPENSSL_CRYPTO_LIBRARY} oqsprovider) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9c4c0854..50a85d34 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,7 @@ +if(NOT BUILD_TESTING) + return() +endif() + include(GNUInstallDirs) if (CMAKE_GENERATOR MATCHES "Visual Studio") set(OQS_PROV_BINARY_DIR ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})