2020-08-25 16:05:56 +02:00
|
|
|
# === This file is part of Calamares - <https://calamares.io> ===
|
2020-02-17 12:02:53 +01:00
|
|
|
#
|
2020-08-26 00:24:40 +02:00
|
|
|
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
#
|
2020-08-25 16:05:56 +02:00
|
|
|
# Calamares is Free Software: see the License-Identifier above.
|
2020-02-17 12:02:53 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Support functions for building Calamares tests.
|
|
|
|
# This extends KDE's ECM tests with some custom patterns.
|
|
|
|
#
|
|
|
|
# calamares_add_test(
|
|
|
|
# <NAME>
|
|
|
|
# [GUI]
|
2020-09-09 11:58:56 +02:00
|
|
|
# [RESOURCES FILE]
|
2020-02-17 12:02:53 +01:00
|
|
|
# SOURCES <FILE..>
|
|
|
|
# )
|
|
|
|
|
2021-09-16 11:45:12 +02:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
include(CalamaresAutomoc)
|
2020-02-17 12:02:53 +01:00
|
|
|
|
2021-09-16 11:45:12 +02:00
|
|
|
function(calamares_add_test name)
|
|
|
|
set(options GUI)
|
|
|
|
set(oneValueArgs RESOURCES)
|
|
|
|
set(multiValueArgs SOURCES LIBRARIES DEFINITIONS)
|
|
|
|
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
set(TEST_NAME ${name})
|
2020-02-17 12:02:53 +01:00
|
|
|
|
2021-09-16 11:45:12 +02:00
|
|
|
if(ECM_FOUND AND BUILD_TESTING)
|
2020-02-17 12:02:53 +01:00
|
|
|
ecm_add_test(
|
2020-09-09 11:58:56 +02:00
|
|
|
${TEST_SOURCES} ${TEST_RESOURCES}
|
2020-02-17 12:02:53 +01:00
|
|
|
TEST_NAME
|
|
|
|
${TEST_NAME}
|
|
|
|
LINK_LIBRARIES
|
2021-07-26 14:27:52 +02:00
|
|
|
Calamares::calamares
|
2020-02-17 14:36:52 +01:00
|
|
|
${TEST_LIBRARIES}
|
2020-02-17 12:02:53 +01:00
|
|
|
Qt5::Core
|
|
|
|
Qt5::Test
|
2021-09-16 11:45:12 +02:00
|
|
|
)
|
2020-02-17 12:02:53 +01:00
|
|
|
calamares_automoc( ${TEST_NAME} )
|
2020-11-02 12:01:02 +01:00
|
|
|
# We specifically pass in the source directory of the test-being-
|
|
|
|
# compiled, so that it can find test-files in that source dir.
|
2021-09-16 11:45:12 +02:00
|
|
|
target_compile_definitions(
|
|
|
|
${TEST_NAME}
|
|
|
|
PRIVATE -DBUILD_AS_TEST="${CMAKE_CURRENT_SOURCE_DIR}" ${TEST_DEFINITIONS}
|
|
|
|
)
|
|
|
|
if(TEST_GUI)
|
|
|
|
target_link_libraries(${TEST_NAME} Calamares::calamaresui Qt5::Gui)
|
2020-02-17 12:02:53 +01:00
|
|
|
endif()
|
2021-09-16 11:45:12 +02:00
|
|
|
if(TEST_RESOURCES)
|
2020-09-09 11:58:56 +02:00
|
|
|
calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
|
|
|
|
endif()
|
2020-02-17 12:02:53 +01:00
|
|
|
endif()
|
|
|
|
endfunction()
|