forked from qt-creator/qt-creator
CMake: Add BUILD_TESTS CMake variable to filter tests to build
This allows building one test: -DBUILD_TESTS=tst_my_test, this will set BUILD_TESTS_BY_DEFAULT to OFF (default value is ON) and set BUILD_TEST_TST_MY_TEST to ON. Change-Id: I7800f3d238121725bb9fa4146f76ddcd2b10bde9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -40,6 +40,7 @@ set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||
option(BUILD_PLUGINS_BY_DEFAULT "Build plugins by default. This can be used to build all plugins by default, or none." ON)
|
||||
option(BUILD_EXECUTABLES_BY_DEFAULT "Build executables by default. This can be used to build all executables by default, or none." ON)
|
||||
option(BUILD_LIBRARIES_BY_DEFAULT "Build libraries by default. This can be used to build all libraries by default, or none." ON)
|
||||
option(BUILD_TESTS_BY_DEFAULT "Build tests by default. This can be used to build all tests by default, or none." ON)
|
||||
option(QTC_SEPARATE_DEBUG_INFO "Extract debug information from binary files." OFF)
|
||||
option(WITH_SCCACHE_SUPPORT "Enables support for building with SCCACHE and separate debug info with MSVC, which SCCACHE normally doesn't support." OFF)
|
||||
|
||||
@@ -51,6 +52,7 @@ function(qtc_check_default_values_for_list list_type)
|
||||
set(PLUGINS_single plugin)
|
||||
set(EXECUTABLES_single executable)
|
||||
set(LIBRARIES_single library)
|
||||
set(TESTS_single test)
|
||||
|
||||
if (NOT DEFINED BUILD_${list_type})
|
||||
return()
|
||||
@@ -67,6 +69,7 @@ endfunction()
|
||||
qtc_check_default_values_for_list(PLUGINS)
|
||||
qtc_check_default_values_for_list(EXECUTABLES)
|
||||
qtc_check_default_values_for_list(LIBRARIES)
|
||||
qtc_check_default_values_for_list(TESTS)
|
||||
|
||||
function(qtc_plugin_enabled varName name)
|
||||
if (NOT (name IN_LIST __QTC_PLUGINS))
|
||||
@@ -790,6 +793,17 @@ function(add_qtc_test name)
|
||||
|
||||
update_cached_list(__QTC_TESTS "${name}")
|
||||
|
||||
string(TOUPPER "BUILD_TEST_${name}" _build_test_var)
|
||||
set(_build_test_default ${BUILD_TESTS_BY_DEFAULT})
|
||||
if (DEFINED ENV{QTC_${_build_test_var}})
|
||||
set(_build_test_default "$ENV{QTC_${_build_test_var}}")
|
||||
endif()
|
||||
set(${_build_test_var} "${_build_test_default}" CACHE BOOL "Build test ${name}.")
|
||||
|
||||
if (NOT ${_build_test_var})
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(dependency ${_arg_DEPENDS})
|
||||
if (NOT TARGET ${dependency} AND NOT _arg_GTEST)
|
||||
if (WITH_DEBUG_CMAKE)
|
||||
|
@@ -194,6 +194,10 @@ add_qtc_test(unittest GTEST
|
||||
mockimagecachestorage.h
|
||||
)
|
||||
|
||||
if (NOT TARGET unittest)
|
||||
return()
|
||||
endif()
|
||||
|
||||
function(extend_qtc_test_with_target_sources target)
|
||||
cmake_parse_arguments(_arg "" "" "DEFINES;INCLUDES" ${ARGN})
|
||||
|
||||
|
Reference in New Issue
Block a user