Skip to content

Commit d63ee5e

Browse files
committed
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 <[email protected]>
1 parent c181965 commit d63ee5e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.8)
22

33
if(DEFINED PROJECT_NAME)
44
set(SUBPROJECT ON)
5+
else()
6+
set(SUBPROJECT OFF)
57
endif()
68

79
project(qtpromise VERSION 0.6.0 LANGUAGES CXX)
@@ -10,6 +12,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
1012

1113
find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core)
1214

15+
option(qtpromise_BuildTests $<NOT:{SUBPROJECT}>)
16+
1317
include(GNUInstallDirs)
1418

1519
set(CMAKE_AUTOMOC ON)
@@ -125,7 +129,7 @@ install(FILES ${PROJECT_SOURCE_DIR}/include/QtPromise
125129
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/include)
126130

127131

128-
if(NOT SUBPROJECT)
132+
if(qtpromise_BuildTests)
129133
enable_testing()
130134
add_subdirectory(tests)
131135
endif()

0 commit comments

Comments
 (0)