| 1 |
# Copyright (C) 2022 The Qt Company Ltd. |
| 2 |
# SPDX-License-Identifier: BSD-3-Clause |
| 3 |
|
| 4 |
if(CMAKE_VERSION VERSION_LESS "3.19" AND MSVC AND QT_FEATURE_debug_and_release) |
| 5 |
message(WARNING "qdoc tests will not be built in this configuration.") |
| 6 |
return() |
| 7 |
endif() |
| 8 |
|
| 9 |
set(QDOC_PROJECT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/) |
| 10 |
set(QDOC_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/qdoc/src/qdoc) |
| 11 |
set(QDOC_INCLUDE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../../src/qdoc/qdoc/src/) |
| 12 |
|
| 13 |
# Mirrors the definition for test targets from the source directory to the |
| 14 |
# "tests" directory. |
| 15 |
# The CI for the Qt project is set up so that, when tests are run in CI, only |
| 16 |
# the "tests" directory under the root of a repo is configured and test targets |
| 17 |
# are later run over an already built Qt (with everything exported from the |
| 18 |
# various src directories). |
| 19 |
# This means that any target that is defined outside the "tests" directory in |
| 20 |
# the root of the repo will not be picked up for testing by CI. |
| 21 |
# |
| 22 |
# As QDoc is currently organizing so that its part of the "src" directory |
| 23 |
# contains everything related to its of its subprojects, tests included, our |
| 24 |
# tests targets will not be checked by CI. |
| 25 |
# |
| 26 |
# To avoid this issue, each test target is defined in its own self-contained |
| 27 |
# "CMakeLists.txt" file under its correct place in the "src" directory and is |
| 28 |
# later included here to ensure that it is picked up when Ci run the tests for |
| 29 |
# the qttools repository. |
| 30 |
# |
| 31 |
# Outside of CI, both the "src" and "tests" directory will be configured and we |
| 32 |
# need to avoid repeating the targets definition. |
| 33 |
# |
| 34 |
# When CI is running its tests, it will set `QT_BUILD_STANDALONE_TESTS`, which |
| 35 |
# we can depend on to filter the inclusions. |
| 36 |
if(QT_BUILD_STANDALONE_TESTS) |
| 37 |
include(${QDOC_PROJECT_DIRECTORY}/catch_generators/tests/CMakeLists.txt) |
| 38 |
|
| 39 |
# Add all tests in src/qdoc/qdoc/tests: |
| 40 |
file(GLOB qdoc_tests_dir_content LIST_DIRECTORIES true "${QDOC_PROJECT_DIRECTORY}/qdoc/tests/*") |
| 41 |
foreach(path IN LISTS qdoc_tests_dir_content) |
| 42 |
if(EXISTS "${path}/CMakeLists.txt") |
| 43 |
get_filename_component(test_directory "${path}" NAME) |
| 44 |
add_subdirectory("${path}" "${test_directory}") |
| 45 |
endif() |
| 46 |
endforeach() |
| 47 |
endif() |