summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-02-07 11:25:33 +0800
committerTim Blechmann <tim@klingt.org>2024-02-08 23:30:29 +0800
commit25b89f2c88cdfc98bfa462949531a33f7ef50996 (patch)
treebdf2131aaadd9b77959b2504df47adc6688ee916 /cmake
parent68179f76053ee042a421dd4a1a27f3fbb185b475 (diff)
cmake: build repo helpers - fine-grained test/example options
the tests/examples could only be enabled globally. when working on a specific repo, it's beneficial to disable tests/examples for other projects to reduce project sizes (and cmake configure/generate times) Change-Id: I0026ba87b667d427043cc8eb1baa6c28b2046dd7 Pick-to: 6.7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildRepoHelpers.cmake16
1 files changed, 12 insertions, 4 deletions
diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake
index c2a8ee56bb..6b2918f748 100644
--- a/cmake/QtBuildRepoHelpers.cmake
+++ b/cmake/QtBuildRepoHelpers.cmake
@@ -429,9 +429,13 @@ endmacro()
macro(qt_build_repo_impl_tests)
if (QT_BUILD_TESTS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
- add_subdirectory(tests)
- if(NOT QT_BUILD_TESTS_BY_DEFAULT)
- set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
+ option(QT_BUILD_TESTS_PROJECT_${PROJECT_NAME} "Configure tests for project ${PROJECT_NAME}" TRUE)
+
+ if (QT_BUILD_TESTS_PROJECT_${PROJECT_NAME})
+ add_subdirectory(tests)
+ if(NOT QT_BUILD_TESTS_BY_DEFAULT)
+ set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
endif()
endif()
endmacro()
@@ -441,7 +445,11 @@ macro(qt_build_repo_impl_examples)
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt"
AND NOT QT_BUILD_STANDALONE_TESTS)
message(STATUS "Configuring examples.")
- add_subdirectory(examples)
+
+ option(QT_BUILD_EXAMPLES_PROJECT_${PROJECT_NAME} "Configure examples for project ${PROJECT_NAME}" TRUE)
+ if (QT_BUILD_EXAMPLES_PROJECT_${PROJECT_NAME})
+ add_subdirectory(examples)
+ endif()
endif()
endmacro()