From be339abb1682a9887d29c5a0fe3746300f52380f Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 9 Jun 2020 12:07:59 +0200 Subject: [PATCH] CMake Build: Fix unittests Change-Id: I4214954d880d19dbe9a070d031c417dc3caf068a Reviewed-by: Alessandro Portale --- cmake/QtCreatorAPI.cmake | 5 ++++- tests/unit/unittest/CMakeLists.txt | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 4249e718242..1c5dbbcece0 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -679,11 +679,14 @@ function(add_qtc_test name) endif() endfunction() -function(finalize_qtc_gtest test_name) +function(finalize_qtc_gtest test_name exclude_sources_regex) if (NOT TARGET ${test_name}) return() endif() get_target_property(test_sources ${test_name} SOURCES) + if (exclude_sources_regex) + list(FILTER test_sources EXCLUDE REGEX "${exclude_sources_regex}") + endif() include(GoogleTest) gtest_add_tests(TARGET ${test_name} SOURCES ${test_sources} TEST_LIST test_list) diff --git a/tests/unit/unittest/CMakeLists.txt b/tests/unit/unittest/CMakeLists.txt index db6bb6c5911..3fd9c4b7af4 100644 --- a/tests/unit/unittest/CMakeLists.txt +++ b/tests/unit/unittest/CMakeLists.txt @@ -20,7 +20,7 @@ add_qtc_test(unittest GTEST Qt5::Xml Qt5::Concurrent Qt5::Qml Qt5::Gui Googletest clangrefactoringbackend_lib clangbackend_lib clangpchmanagerbackend_lib - CPlusPlus Sqlite Utils + CPlusPlus Utils DEFINES UNIT_TESTS DONT_CHECK_MESSAGE_COUNTER @@ -174,6 +174,13 @@ add_qtc_test(unittest GTEST sqlitevalue-test.cpp ) +extend_qtc_test(unittest + DEFINES + $ + SOURCES + ../../../src/libs/3rdparty/sqlite/sqlite3.c +) + # Do not work on the source directory data add_custom_command(TARGET unittest POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory @@ -289,7 +296,7 @@ extend_qtc_test(unittest smallstring-benchmark.cpp ) -finalize_qtc_gtest(unittest) +finalize_qtc_gtest(unittest ".c$") # Path needs to be before CppTools target_include_directories(unittest