From acdc5dfaee8502f12486204fd2f01ba7eb0bbbfd Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 22 Aug 2019 16:20:03 +0200 Subject: [PATCH] Skip emebedding test data when there is no target On android test data is embedded into to the binary via resources. This will not work with sourceless tests such as the qml only test cases. Change-Id: I3ecf28223b3c7c6dae4ca3f15519adc028082598 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- cmake/QtBuild.cmake | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 53ed7194304..aad4fe6da43 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2322,24 +2322,27 @@ function(add_qt_test name) endif() if(builtin_testdata) - target_compile_definitions("${name}" PRIVATE BUILTIN_TESTDATA) + # Safe guard against qml only tests, no source files == no target + if (TARGET "${name}") + target_compile_definitions("${name}" PRIVATE BUILTIN_TESTDATA) - foreach(testdata IN LISTS arg_TESTDATA) - list(APPEND builtin_files ${testdata}) - endforeach() + foreach(testdata IN LISTS arg_TESTDATA) + list(APPEND builtin_files ${testdata}) + endforeach() - set(blacklist_path "BLACKLIST") - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") - list(APPEND builtin_files ${blacklist_path}) - endif() + set(blacklist_path "BLACKLIST") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") + list(APPEND builtin_files ${blacklist_path}) + endif() - list(REMOVE_DUPLICATES builtin_files) + list(REMOVE_DUPLICATES builtin_files) - if (builtin_files) - add_qt_resource(${name} "testdata" - PREFIX "/" - FILES ${builtin_files} - BASE ${CMAKE_CURRENT_SOURCE_DIR}) + if (builtin_files) + add_qt_resource(${name} "testdata" + PREFIX "/" + FILES ${builtin_files} + BASE ${CMAKE_CURRENT_SOURCE_DIR}) + endif() endif() else() # Install test data