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.
This commit is contained in:
Robin Lindén
2019-04-26 22:09:07 +02:00
parent ce0144f8a7
commit c6171bfca4
2 changed files with 8 additions and 3 deletions

View File

@@ -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()

View File

@@ -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}