| 1 |
# === This file is part of Calamares - <https://calamares.io> === |
| 2 |
# |
| 3 |
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <[email protected]> |
| 4 |
# SPDX-License-Identifier: BSD-2-Clause |
| 5 |
# |
| 6 |
# Calamares is Free Software: see the License-Identifier above. |
| 7 |
# |
| 8 |
# |
| 9 |
### |
| 10 |
# |
| 11 |
# Support functions for building Calamares tests. |
| 12 |
# This extends KDE's ECM tests with some custom patterns. |
| 13 |
# |
| 14 |
# calamares_add_test( |
| 15 |
# <NAME> |
| 16 |
# [GUI] |
| 17 |
# [RESOURCES FILE] |
| 18 |
# SOURCES <FILE..> |
| 19 |
# ) |
| 20 |
|
| 21 |
include(CMakeParseArguments) |
| 22 |
include(CalamaresAutomoc) |
| 23 |
|
| 24 |
function(calamares_add_test name) |
| 25 |
set(options GUI) |
| 26 |
set(oneValueArgs RESOURCES) |
| 27 |
set(multiValueArgs SOURCES LIBRARIES DEFINITIONS) |
| 28 |
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
| 29 |
set(TEST_NAME ${name}) |
| 30 |
|
| 31 |
if(ECM_FOUND AND BUILD_TESTING) |
| 32 |
ecm_add_test( |
| 33 |
${TEST_SOURCES} ${TEST_RESOURCES} |
| 34 |
TEST_NAME |
| 35 |
${TEST_NAME} |
| 36 |
LINK_LIBRARIES |
| 37 |
Calamares::calamares |
| 38 |
${TEST_LIBRARIES} |
| 39 |
${qtname}::Core |
| 40 |
${qtname}::Test |
| 41 |
) |
| 42 |
calamares_automoc( ${TEST_NAME} ) |
| 43 |
# We specifically pass in the source directory of the test-being- |
| 44 |
# compiled, so that it can find test-files in that source dir. |
| 45 |
target_compile_definitions( |
| 46 |
${TEST_NAME} |
| 47 |
PRIVATE -DBUILD_AS_TEST="${CMAKE_CURRENT_SOURCE_DIR}" ${TEST_DEFINITIONS} |
| 48 |
) |
| 49 |
if(TEST_GUI) |
| 50 |
target_link_libraries(${TEST_NAME} Calamares::calamaresui ${qtname}::Gui) |
| 51 |
endif() |
| 52 |
if(TEST_RESOURCES) |
| 53 |
calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} ) |
| 54 |
endif() |
| 55 |
endif() |
| 56 |
endfunction() |