Skip to content

Commit 36fa94a

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 36fa94a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 8 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,11 @@ 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 "Build Test Programs" ON)
16+
if (${SUBPROJECT})
17+
set(qtpromise_BuildTests OFF)
18+
endif()
19+
1320
include(GNUInstallDirs)
1421

1522
set(CMAKE_AUTOMOC ON)
@@ -125,7 +132,7 @@ install(FILES ${PROJECT_SOURCE_DIR}/include/QtPromise
125132
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/include)
126133

127134

128-
if(NOT SUBPROJECT)
135+
if(qtpromise_BuildTests)
129136
enable_testing()
130137
add_subdirectory(tests)
131138
endif()

0 commit comments

Comments
 (0)