Commit f708739f authored by Craig Scott's avatar Craig Scott
Browse files

WIP: Tests: Add support for testing Qt6

parent cc94429c
......@@ -257,6 +257,13 @@ if(BUILD_TESTING)
#---------------------------------------------------------------------------
# Add tests below here.
if(NOT DEFINED CMake_TEST_Qt6)
set(CMake_TEST_Qt6 1)
endif()
if(CMake_TEST_Qt6)
find_package(Qt6 COMPONENTS Core Widgets QUIET NO_MODULE)
endif()
if(NOT DEFINED CMake_TEST_Qt5)
set(CMake_TEST_Qt5 1)
endif()
......@@ -1384,6 +1391,9 @@ if(BUILD_TESTING)
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND)
add_subdirectory(Qt6Autogen)
endif()
if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND)
add_subdirectory(Qt5Autogen)
endif()
......
# Set Qt test version and include the Autogen test macros
set(QT_TEST_VERSION 6)
include("../QtAutogen/TestMacros.cmake")
# Common tests
include("../QtAutogen/Tests.cmake")
set(TEST_BUILD_DIRS "${TEST_BUILD_DIRS}" PARENT_SCOPE)
......@@ -21,27 +21,27 @@ if (QT_TEST_VERSION EQUAL 4)
qt4_generate_moc(${ARGN})
endmacro()
elseif(QT_TEST_VERSION EQUAL 5)
elseif(QT_TEST_VERSION GREATER_EQUAL 5)
find_package(Qt5Core REQUIRED)
find_package(Qt${QT_TEST_VERSION}Core REQUIRED)
set(QT_QTCORE_TARGET Qt5::Core)
set(QT_LIBRARIES Qt5::Core)
set(QT_QTCORE_TARGET Qt${QT_TEST_VERSION}::Core)
set(QT_LIBRARIES Qt${QT_TEST_VERSION}::Core)
# Include directories
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt${QT_TEST_VERSION}Core_INCLUDE_DIRS})
# Definitions
if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
if(Qt${QT_TEST_VERSION}_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
endif()
# Qt macros
macro(qtx_wrap_cpp)
qt5_wrap_cpp(${ARGN})
cmake_language(CALL qt${QT_TEST_VERSION}_wrap_cpp ${ARGN})
endmacro()
macro(qtx_generate_moc)
qt5_generate_moc(${ARGN})
cmake_language(CALL qt${QT_TEST_VERSION}_generate_moc ${ARGN})
endmacro()
else()
......
......@@ -21,27 +21,27 @@ if (QT_TEST_VERSION EQUAL 4)
qt4_generate_moc(${ARGN})
endmacro()
elseif(QT_TEST_VERSION EQUAL 5)
elseif(QT_TEST_VERSION GREATER_EQUAL 5)
find_package(Qt5Widgets REQUIRED)
find_package(Qt${QT_TEST_VERSION}Widgets REQUIRED)
set(QT_QTCORE_TARGET Qt5::Core)
set(QT_LIBRARIES Qt5::Widgets)
set(QT_QTCORE_TARGET Qt${QT_TEST_VERSION}::Core)
set(QT_LIBRARIES Qt${QT_TEST_VERSION}::Widgets)
# Include directories
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt${QT_TEST_VERSION}Widgets_INCLUDE_DIRS})
# Definitions
if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
if(Qt${QT_TEST_VERSION}_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
endif()
# Qt macros
macro(qtx_wrap_cpp)
qt5_wrap_cpp(${ARGN})
cmake_language(CALL qt${QT_TEST_VERSION}_wrap_cpp ${ARGN})
endmacro()
macro(qtx_generate_moc)
qt5_generate_moc(${ARGN})
cmake_language(CALL qt${QT_TEST_VERSION}_generate_moc ${ARGN})
endmacro()
else()
......
......@@ -16,6 +16,8 @@ add_library(privateSlot OBJECT private_slot.cpp)
# Pass Qt compiler features to targets that don't link against Qt
target_compile_features(codeeditorLib PRIVATE ${QT_COMPILE_FEATURES})
target_compile_features(privateSlot PRIVATE ${QT_COMPILE_FEATURES})
target_link_libraries(codeeditorLib PRIVATE ${QT_LIBRARIES})
target_link_libraries(privateSlot PRIVATE ${QT_LIBRARIES})
configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY)
add_custom_command(
......
......@@ -70,7 +70,11 @@ int CodeEditor::lineNumberAreaWidth()
++digits;
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
#else
int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
#endif
return space;
}
......
......@@ -7,8 +7,17 @@ else()
endif()
list(APPEND Autogen_BUILD_OPTIONS
"-DCMAKE_AUTOGEN_VERBOSE=1"
"-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
)
if(Qt${QT_TEST_VERSION}Core_DIR)
get_filename_component(prefix "${Qt${QT_TEST_VERSION}Core_DIR}" DIRECTORY)
get_filename_component(prefix "${prefix}" DIRECTORY)
get_filename_component(prefix "${prefix}" DIRECTORY)
list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_PREFIX_PATH:STRING=${prefix}")
else()
list(APPEND Autogen_BUILD_OPTIONS
"-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
)
endif()
# XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion
# when the Xcode generator supports per-config sources.
if(CMAKE_GENERATOR STREQUAL "Xcode")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment