summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdoc/CMakeLists.txt
blob: 994306723acb6d0d4fcaf739f54ea48896345928 (plain)
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
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

if(CMAKE_VERSION VERSION_LESS "3.19" AND MSVC AND QT_FEATURE_debug_and_release)
    message(WARNING "qdoc tests will not be built in this configuration.")
    return()
endif()

set(QDOC_PROJECT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/)
set(QDOC_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/qdoc/src/qdoc)
set(QDOC_INCLUDE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/qdoc/src/)

# Mirrors the definition for test targets from the source directory to the
# "tests" directory.
# The CI for the Qt project is set up so that, when tests are run in CI, only
# the "tests" directory under the root of a repo is configured and test targets
# are later run over an already built Qt (with everything exported from the
# various src directories).
# This means that any target that is defined outside the "tests" directory in
# the root of the repo will not be picked up for testing by CI.
#
# As QDoc is currently organizing so that its part of the "src" directory
# contains everything related to its of its subprojects, tests included, our
# tests targets will not be checked by CI.
#
# To avoid this issue, each test target is defined in its own self-contained
# "CMakeLists.txt" file under its correct place in the "src" directory and is
# later included here to ensure that it is picked up when Ci run the tests for
# the qttools repository.
#
# Outside of CI, both the "src" and "tests" directory will be configured and we
# need to avoid repeating the targets definition.
#
# When CI is running its tests, it will set `QT_BUILD_STANDALONE_TESTS`, which
# we can depend on to filter the inclusions.
if(QT_BUILD_STANDALONE_TESTS)
    include(${QDOC_PROJECT_DIRECTORY}/catch_generators/tests/CMakeLists.txt)

    # Add all tests in src/qdoc/qdoc/tests:
    file(GLOB qdoc_tests_dir_content LIST_DIRECTORIES true "${QDOC_PROJECT_DIRECTORY}/qdoc/tests/*")
    foreach(path IN LISTS qdoc_tests_dir_content)
        if(EXISTS "${path}/CMakeLists.txt")
            get_filename_component(test_directory "${path}" NAME)
            add_subdirectory("${path}" "${test_directory}")
        endif()
    endforeach()
endif()