2022-10-02 17:26:00 +03:00
|
|
|
find_package(Qt6 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED Core Test Xml Network Qml Quick)
|
2017-12-14 17:10:33 +03:00
|
|
|
|
2022-11-10 16:05:55 +03:00
|
|
|
macro(nextcloud_build_test test_class)
|
|
|
|
set(CMAKE_AUTOMOC TRUE)
|
|
|
|
set(OWNCLOUD_TEST_CLASS ${test_class})
|
|
|
|
string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE)
|
|
|
|
|
|
|
|
add_executable(${OWNCLOUD_TEST_CLASS}Test test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp)
|
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
|
|
|
|
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
|
|
|
Nextcloud::sync
|
|
|
|
testutils
|
|
|
|
nextcloudCore
|
|
|
|
cmdCore
|
2022-05-20 20:03:40 +03:00
|
|
|
Qt::Test
|
|
|
|
Qt::Quick
|
2022-11-28 13:57:32 +03:00
|
|
|
Qt::Core5Compat
|
2022-11-10 16:05:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE nextcloudsync_vfs_cfapi)
|
|
|
|
elseif (LINUX)
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE nextcloudsync_vfs_xattr)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
IF(BUILD_UPDATER)
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE updater)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(-DOWNCLOUD_TEST)
|
|
|
|
add_definitions(-DOWNCLOUD_BIN_PATH="${CMAKE_BINARY_DIR}/bin")
|
|
|
|
|
|
|
|
target_include_directories(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/"
|
|
|
|
${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer
|
|
|
|
)
|
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES FOLDER Tests)
|
|
|
|
endmacro()
|
|
|
|
|
2021-02-01 23:07:17 +03:00
|
|
|
macro(nextcloud_add_test test_class)
|
2014-07-07 18:30:32 +04:00
|
|
|
set(CMAKE_AUTOMOC TRUE)
|
2016-03-30 18:58:15 +03:00
|
|
|
set(OWNCLOUD_TEST_CLASS ${test_class})
|
2012-10-26 22:24:12 +04:00
|
|
|
string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE)
|
|
|
|
|
2021-02-01 23:07:17 +03:00
|
|
|
add_executable(${OWNCLOUD_TEST_CLASS}Test test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp)
|
2017-02-07 21:31:55 +03:00
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
|
2012-10-26 22:24:12 +04:00
|
|
|
|
2021-04-13 13:39:10 +03:00
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
2021-10-05 13:00:22 +03:00
|
|
|
Nextcloud::sync
|
2021-02-01 23:07:17 +03:00
|
|
|
testutils
|
2021-01-15 01:07:32 +03:00
|
|
|
nextcloudCore
|
2021-02-01 23:07:17 +03:00
|
|
|
cmdCore
|
2022-05-20 20:03:40 +03:00
|
|
|
Qt::Test
|
|
|
|
Qt::Quick
|
2022-11-28 13:57:32 +03:00
|
|
|
Qt::Core5Compat
|
2012-10-26 22:24:12 +04:00
|
|
|
)
|
|
|
|
|
2021-06-11 20:17:10 +03:00
|
|
|
if (WIN32)
|
2021-04-13 13:39:10 +03:00
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
|
|
|
nextcloudsync_vfs_cfapi
|
2021-06-11 20:17:10 +03:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-10-09 00:52:56 +03:00
|
|
|
if (LINUX)
|
2021-04-13 13:39:10 +03:00
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
|
|
|
nextcloudsync_vfs_xattr
|
2021-06-11 20:17:10 +03:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-03-11 00:10:45 +03:00
|
|
|
IF(BUILD_UPDATER)
|
2021-04-13 13:39:10 +03:00
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test PRIVATE
|
2020-03-11 00:10:45 +03:00
|
|
|
updater
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-10-02 10:40:44 +03:00
|
|
|
add_definitions(-DOWNCLOUD_TEST)
|
2017-07-06 09:41:02 +03:00
|
|
|
add_definitions(-DOWNCLOUD_BIN_PATH="${CMAKE_BINARY_DIR}/bin")
|
2018-08-15 11:46:16 +03:00
|
|
|
add_test(NAME ${OWNCLOUD_TEST_CLASS}Test
|
|
|
|
COMMAND ${OWNCLOUD_TEST_CLASS}Test
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
|
2021-05-07 15:10:44 +03:00
|
|
|
target_include_directories(${OWNCLOUD_TEST_CLASS}Test
|
2021-01-15 01:07:32 +03:00
|
|
|
PRIVATE
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/"
|
|
|
|
${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer
|
|
|
|
)
|
2021-05-07 15:10:44 +03:00
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES FOLDER Tests)
|
2013-08-09 14:56:43 +04:00
|
|
|
endmacro()
|
2017-01-16 19:13:52 +03:00
|
|
|
|
2021-02-01 23:07:17 +03:00
|
|
|
macro(nextcloud_add_benchmark test_class)
|
2017-01-16 19:13:52 +03:00
|
|
|
set(CMAKE_AUTOMOC TRUE)
|
|
|
|
set(OWNCLOUD_TEST_CLASS ${test_class})
|
|
|
|
string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE)
|
|
|
|
|
2021-02-01 23:07:17 +03:00
|
|
|
add_executable(${OWNCLOUD_TEST_CLASS}Bench benchmarks/bench${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp)
|
2017-02-07 21:31:55 +03:00
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
|
2017-01-16 19:13:52 +03:00
|
|
|
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Bench
|
2021-10-05 13:00:22 +03:00
|
|
|
Nextcloud::sync
|
2021-02-01 23:07:17 +03:00
|
|
|
testutils
|
|
|
|
nextcloudCore
|
|
|
|
cmdCore
|
2022-05-20 20:03:40 +03:00
|
|
|
Qt::Core
|
|
|
|
Qt::Test
|
|
|
|
Qt::Xml
|
|
|
|
Qt::Network
|
2022-11-28 13:57:32 +03:00
|
|
|
Qt::Core5Compat
|
2017-01-16 19:13:52 +03:00
|
|
|
)
|
|
|
|
|
2020-03-11 00:10:45 +03:00
|
|
|
IF(BUILD_UPDATER)
|
|
|
|
target_link_libraries(${OWNCLOUD_TEST_CLASS}Bench
|
|
|
|
updater
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-01-16 19:13:52 +03:00
|
|
|
add_definitions(-DOWNCLOUD_TEST)
|
2017-07-06 09:41:02 +03:00
|
|
|
add_definitions(-DOWNCLOUD_BIN_PATH="${CMAKE_BINARY_DIR}/bin")
|
2021-05-07 15:10:44 +03:00
|
|
|
set_target_properties(${OWNCLOUD_TEST_CLASS}Bench PROPERTIES FOLDER Tests/Benchmarks)
|
2017-01-16 19:13:52 +03:00
|
|
|
endmacro()
|