From d63ee5e59784c1bd5580255519d11f2f95e97990 Mon Sep 17 00:00:00 2001 From: Marc Reilly Date: Wed, 16 Jun 2021 12:13:05 +1000 Subject: [PATCH] project: cmake: add option to explicity enable/disable building tests This allows user/builder to chose whether or not to build the tests. The option retains the previous default behaviour, so that tests are built if we are a subproject. Signed-off-by: Marc Reilly --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c485944..5ae22e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.8) if(DEFINED PROJECT_NAME) set(SUBPROJECT ON) +else() + set(SUBPROJECT OFF) endif() project(qtpromise VERSION 0.6.0 LANGUAGES CXX) @@ -10,6 +12,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core) +option(qtpromise_BuildTests $) + include(GNUInstallDirs) set(CMAKE_AUTOMOC ON) @@ -125,7 +129,7 @@ install(FILES ${PROJECT_SOURCE_DIR}/include/QtPromise DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/include) -if(NOT SUBPROJECT) +if(qtpromise_BuildTests) enable_testing() add_subdirectory(tests) endif()