aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-05-28 08:59:47 +0200
committerEike Ziller <eike.ziller@qt.io>2021-05-28 08:34:21 +0000
commit57f889feb5eaf24b5cb1bbdee9374a01e8fd6a7d (patch)
treeb90833551f910862186117badbc3984b08aa70ec /cmake
parent0ae67dc83f9ed170363ef0f2b58cf13dbcdc242a (diff)
CMake build: Fix extend_qtc_test
extend_qtc_test should gracefully do nothing if the test was declared, but disabled for any reason. add_qtc_test failed to add the test to the list of declared tests, if dependencies were missing, so extend_qtc_test was complaining that the test didn't exist in that case. add_qtc_test must always add the test to the list of declared tests, and extend_qtc_test must only fail if the test was never declared, but do nothing if the test target does not exist (because the test was disabled for some reason). Change-Id: I414a169e3e23c3c0e11c11e2ee86effa706b545c Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtCreatorAPI.cmake16
1 files changed, 9 insertions, 7 deletions
diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake
index 283fb0649e5..d2f4415ec4e 100644
--- a/cmake/QtCreatorAPI.cmake
+++ b/cmake/QtCreatorAPI.cmake
@@ -588,7 +588,9 @@ function(extend_qtc_test target_name)
if (NOT (target_name IN_LIST __QTC_TESTS))
message(FATAL_ERROR "extend_qtc_test: Unknown test target \"${target_name}\"")
endif()
- extend_qtc_target(${target_name} ${ARGN})
+ if (TARGET ${target_name})
+ extend_qtc_target(${target_name} ${ARGN})
+ endif()
endfunction()
function(add_qtc_executable name)
@@ -782,6 +784,12 @@ endfunction()
function(add_qtc_test name)
cmake_parse_arguments(_arg "GTEST" "TIMEOUT" "DEFINES;DEPENDS;INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC" ${ARGN})
+ if ($_arg_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "add_qtc_test had unparsed arguments!")
+ endif()
+
+ update_cached_list(__QTC_TESTS "${name}")
+
foreach(dependency ${_arg_DEPENDS})
if (NOT TARGET ${dependency} AND NOT _arg_GTEST)
if (WITH_DEBUG_CMAKE)
@@ -791,12 +799,6 @@ function(add_qtc_test name)
endif()
endforeach()
- if ($_arg_UNPARSED_ARGUMENTS)
- message(FATAL_ERROR "add_qtc_test had unparsed arguments!")
- endif()
-
- update_cached_list(__QTC_TESTS "${name}")
-
set(TEST_DEFINES SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
# relax cast requirements for tests