diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 14:14:31 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 14:33:27 (GMT) |
commit | e7fb85d00d3a550d0f05e2288e18b43dc572900b (patch) | |
tree | d053137af86dc11185e5f0091ea3ba3aff2260b6 /Tests | |
parent | d7a52f8c24a29ff7f64b00566b646f2d125d4ac0 (diff) | |
download | CMake-e7fb85d00d3a550d0f05e2288e18b43dc572900b.zip CMake-e7fb85d00d3a550d0f05e2288e18b43dc572900b.tar.gz CMake-e7fb85d00d3a550d0f05e2288e18b43dc572900b.tar.bz2 |
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
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/CommonTests.cmake | 2 | ||||
-rw-r--r-- | 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() |