From c6171bfca479fb2ee375e2b1f55e174ed79c4f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Lind=C3=A9n?= Date: Fri, 26 Apr 2019 22:09:07 +0200 Subject: [PATCH] Add option to disable building/running the tests This is a nice feature to have for when the project is included in another project as e.g. a git submodule or used with CMake's FetchContent. --- CMakeLists.txt | 9 ++++++--- README.md | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff08d4b..4370f6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.11) project("sodium") +option(SODIUM_DISABLE_TESTS "Disable tests" OFF) + add_library(${PROJECT_NAME} libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c @@ -268,6 +270,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/libsodium/src/libsodium/include/sodium/version.h ) -enable_testing() - -add_subdirectory(test) +if(NOT SODIUM_DISABLE_TESTS) + enable_testing() + add_subdirectory(test) +endif() diff --git a/README.md b/README.md index 22cc654..1be9328 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ FetchContent_Declare( FetchContent_GetProperties(Sodium) if(NOT sodium_POPULATED) + set(SODIUM_DISABLE_TESTS ON) + FetchContent_Populate(Sodium) add_subdirectory( ${sodium_SOURCE_DIR}