2022-07-05 11:26:52 +00:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-08-19 13:21:34 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2022-07-05 11:26:52 +00:00
|
|
|
|
2018-11-22 10:35:17 +00:00
|
|
|
# These macros are inspired by ECM:
|
2018-11-14 12:37:52 +00:00
|
|
|
|
|
|
|
# a macro for tests that have a simple format where the name matches the
|
|
|
|
# directory and project
|
2018-11-22 10:35:17 +00:00
|
|
|
|
|
|
|
# The following macros will produce tests that generate the build
|
|
|
|
# system for the test project, build it and then run its tests.
|
|
|
|
macro(add_cmake_test_generate_build_run_variant name base command)
|
|
|
|
string(REPLACE "." "/" src_dir "${base}")
|
|
|
|
string(REPLACE "." "/" build_dir "${name}")
|
|
|
|
string(REGEX REPLACE "[^.]*\\." "" proj "${name}")
|
|
|
|
add_test(NAME "cmake_${name}"
|
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND}
|
|
|
|
--build-and-test
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${build_dir}"
|
|
|
|
--build-two-config
|
|
|
|
--build-generator ${CMAKE_GENERATOR}
|
|
|
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
|
|
|
--build-project ${proj}
|
|
|
|
${${name}_EXTRA_OPTIONS}
|
|
|
|
--test-command ${command} ${ARGN})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_cmake_test_generate_build_run name)
|
|
|
|
add_cmake_test_generate_build_run_variant("${name}" "${name}" ${ARGN})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# The following macros will produce tests that just run cmake
|
|
|
|
# to generate the build system for the test project.
|
|
|
|
macro(add_cmake_test_generate_variant name base)
|
|
|
|
string(REPLACE "." "/" src_dir "${base}")
|
|
|
|
string(REPLACE "." "/" build_dir "${name}")
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
|
|
|
|
add_test(NAME "cmake_${name}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" "-G${CMAKE_GENERATOR}"
|
|
|
|
"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
|
|
|
|
${${name}_EXTRA_OPTIONS}
|
2018-11-14 12:37:52 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
|
2018-11-22 10:35:17 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
|
2018-11-14 12:37:52 +00:00
|
|
|
endmacro()
|
|
|
|
|
2018-11-22 10:35:17 +00:00
|
|
|
macro(add_cmake_test_generate name)
|
|
|
|
add_cmake_test_generate_variant("${name}" "${name}")
|
2018-11-14 12:37:52 +00:00
|
|
|
endmacro()
|
|
|
|
|
2018-11-22 10:35:17 +00:00
|
|
|
add_cmake_test_generate(features)
|
|
|
|
add_cmake_test_generate(qt_make_output_file)
|