File: CalamaresAddTest.cmake

package info (click to toggle)
calamares 3.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,104 kB
  • sloc: cpp: 71,902; python: 4,365; xml: 1,379; sh: 717; ansic: 105; makefile: 7
file content (56 lines) | stat: -rw-r--r-- 1,699 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# === This file is part of Calamares - <https://calamares.io> ===
#
#   SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
#   SPDX-License-Identifier: BSD-2-Clause
#
#   Calamares is Free Software: see the License-Identifier above.
#
#
###
#
# Support functions for building Calamares tests.
# This extends KDE's ECM tests with some custom patterns.
#
# calamares_add_test(
#   <NAME>
#   [GUI]
#   [RESOURCES FILE]
#   SOURCES <FILE..>
#   )

include(CMakeParseArguments)
include(CalamaresAutomoc)

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})

    if(ECM_FOUND AND BUILD_TESTING)
        ecm_add_test(
            ${TEST_SOURCES} ${TEST_RESOURCES}
            TEST_NAME
                ${TEST_NAME}
            LINK_LIBRARIES
                Calamares::calamares
                ${TEST_LIBRARIES}
                ${qtname}::Core
                ${qtname}::Test
        )
        calamares_automoc( ${TEST_NAME} )
        # We specifically pass in the source directory of the test-being-
        # compiled, so that it can find test-files in that source dir.
        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 ${qtname}::Gui)
        endif()
        if(TEST_RESOURCES)
            calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
        endif()
    endif()
endfunction()