Files
CMake/Tests/RunCMake/NinjaMultiConfig/QtX.cmake
T
Craig Scott a742088472 Tests: Add support for testing Qt6
The minimum CMake version for Qt6 is 3.16, so all the calls to
cmake_minimum_required() are updated here to enforce that
minimum. This will avoid any CMake version-related warnings
from Qt.

Avoid hard-coding Qt5 where the tests could now be using
Qt5 or Qt6.

Fixes: #22188
2021-10-04 22:10:57 +11:00

35 lines
1.1 KiB
CMake

enable_language(CXX)
set(QtX Qt${with_qt_version})
find_package(${QtX} REQUIRED COMPONENTS Core)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOMOC_COMPILER_PREDEFINES OFF)
# Source files are always named qt5.* for simplicity but apply to Qt5 and later
add_executable(exe qt5.cxx)
target_link_libraries(exe PRIVATE ${QtX}::Core)
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
generate_output_files(exe)
set(moc_writes_depfiles 0)
if(${QtX}Core_VERSION VERSION_GREATER_EQUAL "5.15.0")
set(moc_writes_depfiles 1)
endif()
set(autogen_files)
if(moc_writes_depfiles)
list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps")
list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp")
endif()
foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES)
list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${c}.cpp")
list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp")
if(moc_writes_depfiles)
list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d")
endif()
endforeach()
file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES [==[${autogen_files}]==])\n")