From e7fb85d00d3a550d0f05e2288e18b43dc572900b Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 7 Aug 2018 16:14:31 +0200 Subject: Autogen: Check if we can run the MocOsMacros test The MocOsMacros test requires moc to support moc_predefs.h on some platforms (e.g. Mac). moc supports moc_predefs.h inclusion since Qt 5.8, therefore run the MocOsMacros only if Qt >= 5.8 and if CMAKE_CXX_COMPILER_PREDEFINES_COMMAND is defined. Fixes #18245 --- Tests/QtAutogen/CommonTests.cmake | 2 +- Tests/QtAutogen/MocOsMacros/CMakeLists.txt | 32 ++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake index 55d36e6..a3f8f39 100644 --- a/Tests/QtAutogen/CommonTests.cmake +++ b/Tests/QtAutogen/CommonTests.cmake @@ -24,7 +24,7 @@ if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) endif() if(NOT QT_TEST_VERSION STREQUAL 4) - ADD_AUTOGEN_TEST(MocOsMacros mocOsMacros) + ADD_AUTOGEN_TEST(MocOsMacros) endif() ADD_AUTOGEN_TEST(UicInclude uicInclude) ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface) diff --git a/Tests/QtAutogen/MocOsMacros/CMakeLists.txt b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt index 51a0ebd..e7b670e 100644 --- a/Tests/QtAutogen/MocOsMacros/CMakeLists.txt +++ b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt @@ -2,15 +2,31 @@ cmake_minimum_required(VERSION 3.11) project(MocOsMacros) include("../AutogenTest.cmake") -# Tests if moc processes the macro Q_OS_MAC +# Tests if moc processes Q_OS_XXX macros -set(CMAKE_AUTOMOC True) +message( "Qt5Core_VERSION: ${Qt5Core_VERSION}" ) +message( + "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND: " + ${CMAKE_CXX_COMPILER_PREDEFINES_COMMAND} ) -add_executable(mocOsMacros - main.cpp - TestClass.cpp - TestClass.hpp +# On some platforms (e.g. MAC) Q_OS_XXX requires moc to include moc_predefs.h +# which is supported since Qt 5.8 and requires +# CMAKE_CXX_COMPILER_PREDEFINES_COMMAND to be defined. +if( ( ${Qt5Core_VERSION} VERSION_GREATER_EQUAL "5.8" ) AND + DEFINED CMAKE_CXX_COMPILER_PREDEFINES_COMMAND ) -target_link_libraries(mocOsMacros PRIVATE ${QT_QTCORE_TARGET}) + message( "Test enabled!" ) + message( + "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: " + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ) -message ( "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ) + set(CMAKE_AUTOMOC True) + add_executable(mocOsMacros + main.cpp + TestClass.cpp + TestClass.hpp + ) + target_link_libraries(mocOsMacros PRIVATE ${QT_QTCORE_TARGET}) +else() + message( "Test disabled!" ) +endif() -- cgit v0.12 From 52676e37941ee6b31139e86ca2dfb28a80c648ae Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 7 Aug 2018 16:30:52 +0200 Subject: Autogen: Tests: Use non inverting Qt version tests --- Tests/QtAutogen/AutogenTest.cmake | 4 ++-- Tests/QtAutogen/CommonTests.cmake | 8 ++++---- Tests/QtAutogen/DefinesTest/CMakeLists.txt | 2 +- Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt | 4 ++-- Tests/QtAutogen/SameName/CMakeLists.txt | 2 +- Tests/QtAutogen/TestMacros.cmake | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Tests/QtAutogen/AutogenTest.cmake b/Tests/QtAutogen/AutogenTest.cmake index 8c0a14f..3969a89 100644 --- a/Tests/QtAutogen/AutogenTest.cmake +++ b/Tests/QtAutogen/AutogenTest.cmake @@ -6,7 +6,7 @@ if(QT_QMAKE_EXECUTABLE) list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) endif() -if (QT_TEST_VERSION STREQUAL 4) +if (QT_TEST_VERSION EQUAL 4) find_package(Qt4 REQUIRED) include(UseQt4) @@ -21,7 +21,7 @@ if (QT_TEST_VERSION STREQUAL 4) qt4_generate_moc(${ARGN}) endmacro() -elseif(QT_TEST_VERSION STREQUAL 5) +elseif(QT_TEST_VERSION EQUAL 5) find_package(Qt5Widgets REQUIRED) set(QT_QTCORE_TARGET Qt5::Core) diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake index a3f8f39..01ed7e9 100644 --- a/Tests/QtAutogen/CommonTests.cmake +++ b/Tests/QtAutogen/CommonTests.cmake @@ -12,7 +12,7 @@ if(QT_TEST_ALLOW_QT_MACROS) endif() ADD_AUTOGEN_TEST(UicSkipSource) ADD_AUTOGEN_TEST(RccSkipSource) -if(NOT QT_TEST_VERSION STREQUAL 4) +if(QT_TEST_VERSION GREATER 4) ADD_AUTOGEN_TEST(MocMacroName mocMacroName) endif() ADD_AUTOGEN_TEST(MocDepends) @@ -23,13 +23,13 @@ endif() if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) endif() -if(NOT QT_TEST_VERSION STREQUAL 4) +if(QT_TEST_VERSION GREATER 4) ADD_AUTOGEN_TEST(MocOsMacros) endif() ADD_AUTOGEN_TEST(UicInclude uicInclude) ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface) ADD_AUTOGEN_TEST(ObjectLibrary someProgram) -if(APPLE AND (NOT QT_TEST_VERSION STREQUAL 4)) +if(APPLE AND (QT_TEST_VERSION GREATER 4)) ADD_AUTOGEN_TEST(MacOsFW) endif() ADD_AUTOGEN_TEST(Parallel parallel) @@ -42,7 +42,7 @@ ADD_AUTOGEN_TEST(SameName sameName) ADD_AUTOGEN_TEST(StaticLibraryCycle slc) # Rerun tests ADD_AUTOGEN_TEST(RerunMocBasic) -if(NOT QT_TEST_VERSION STREQUAL 4) +if(QT_TEST_VERSION GREATER 4) ADD_AUTOGEN_TEST(RerunMocPlugin) endif() ADD_AUTOGEN_TEST(RerunRccDepends) diff --git a/Tests/QtAutogen/DefinesTest/CMakeLists.txt b/Tests/QtAutogen/DefinesTest/CMakeLists.txt index de22845..3761dd8 100644 --- a/Tests/QtAutogen/DefinesTest/CMakeLists.txt +++ b/Tests/QtAutogen/DefinesTest/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(DefinesTest) # Qt4 only definitions test -if(NOT QT_TEST_VERSION STREQUAL 4) +if(NOT QT_TEST_VERSION EQUAL 4) message(ERROR "Invalid Qt test version. This test is for Qt4 only.") endif() diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt index bc0085f..ca22aeb 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.10) project(MocPlugin) include("../../AutogenTest.cmake") -if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") +if (QT_TEST_VERSION LESS 5) + message(SEND_ERROR "Qt 5 or higher required.") endif() set(CMAKE_AUTOMOC_DEPEND_FILTERS diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index c7d6e52..931e40f 100644 --- a/Tests/QtAutogen/SameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -28,7 +28,7 @@ set_target_properties(sameName PROPERTIES ) # Set different compression levels -if (QT_TEST_VERSION STREQUAL 4) +if (QT_TEST_VERSION EQUAL 4) set(rccCompress "-compress") else() set(rccCompress "--compress") diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 8e4bea2..0e27188 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -50,7 +50,7 @@ if(NON_ASCII_BDIR) # Qt4 moc does not support utf8 paths in _parameter files generated by # qtx_wrap_cpp # https://bugreports.qt.io/browse/QTBUG-35480 - if(QT_TEST_VERSION STREQUAL 4) + if(QT_TEST_VERSION EQUAL 4) set(QT_TEST_ALLOW_QT_MACROS FALSE) endif() # On windows qtx_wrap_cpp also fails in Qt5 when used on a path that -- cgit v0.12