From 5c73c39981d442e4b7834e737aeb3511c91457c5 Mon Sep 17 00:00:00 2001 From: Nikola Zivkovic Date: Fri, 24 Jun 2022 13:03:02 +0200 Subject: [PATCH] Enable building tests only if the project is built as a standalone one --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95c85ff..cf86d70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,13 @@ project(zip set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_VERBOSE_MAKEFILE ON) -option(CMAKE_DISABLE_TESTING "Disable test creation" OFF) +# Enable building tests only if the project is being built as a standalone one +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + option(CMAKE_DISABLE_TESTING "Disable test creation" OFF) +else () + option(CMAKE_DISABLE_TESTING "Disable test creation" ON) +endif () + option(CMAKE_ENABLE_SANITIZERS "Enable zip sanitizers" OFF) option(ZIP_STATIC_PIC "Build static zip with PIC" ON) option(ZIP_BUILD_DOCS "Generate API documentation with Doxygen" OFF)