Skip to content

Commit

Permalink
project: cmake: add option to explicity enable/disable building tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marc-cpdesign committed Jun 16, 2021
1 parent c181965 commit d63ee5e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 $<NOT:{SUBPROJECT}>)

include(GNUInstallDirs)

set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -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()

0 comments on commit d63ee5e

Please sign in to comment.