From 13bb716f046e33d9dbd20ac2156deb0f677797d3 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 22 Aug 2017 19:09:50 +0200 Subject: Autogen: Fix and extend SKIP_AUTOMOC test --- Tests/QtAutogen/CMakeLists.txt | 15 +++++++++++++-- Tests/QtAutogen/skipMoc.cpp | 6 ++++-- Tests/QtAutogen/skipSource/qItemC.cpp | 12 ++++++++++++ Tests/QtAutogen/skipSource/qItemD.cpp | 17 +++++++++++++++++ Tests/QtAutogen/skipSource/qItemD.hpp | 13 +++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 Tests/QtAutogen/skipSource/qItemD.cpp create mode 100644 Tests/QtAutogen/skipSource/qItemD.hpp diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index be864c3..81ab734 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -114,16 +114,27 @@ target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) # -- Test # Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target if(ALLOW_WRAP_CPP) + # Generate header mocs manually qtx_wrap_cpp(skipMocWrapMoc skipSource/qItemA.hpp - skipSource/qItemB.hpp) + skipSource/qItemB.hpp + skipSource/qItemC.hpp + skipSource/qItemD.hpp + ) set(skipMocSources skipMoc.cpp skipSource/qItemA.cpp skipSource/qItemB.cpp - skipSource/qItemC.cpp) + skipSource/qItemC.cpp + skipSource/qItemD.cpp + ) + # When cpp files are skipped, the hpp won't be processed either, + # unless they are mentioned in the sources - which they aren't. set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) + # When hpp files are skipped, the cpp still get processed. + set_property(SOURCE skipSource/qItemC.hpp PROPERTY SKIP_AUTOMOC ON) + set_property(SOURCE skipSource/qItemD.hpp PROPERTY SKIP_AUTOGEN ON) # AUTOMOC enabled only add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) set_property(TARGET skipMocA PROPERTY AUTOMOC ON) diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp index 85305f5..d6b292f 100644 --- a/Tests/QtAutogen/skipMoc.cpp +++ b/Tests/QtAutogen/skipMoc.cpp @@ -2,12 +2,14 @@ #include "skipSource/qItemA.hpp" #include "skipSource/qItemB.hpp" #include "skipSource/qItemC.hpp" +#include "skipSource/qItemD.hpp" int main(int, char**) { QItemA itemA; - QItemA itemB; - QItemA itemC; + QItemB itemB; + QItemC itemC; + QItemD itemD; // Fails to link if the symbol is not present. return 0; diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp index 700abd6..622f282 100644 --- a/Tests/QtAutogen/skipSource/qItemC.cpp +++ b/Tests/QtAutogen/skipSource/qItemC.cpp @@ -1,5 +1,17 @@ #include "qItemC.hpp" +class QItemC_Local : public QObject +{ + Q_OBJECT +public: + QItemC_Local(){}; + ~QItemC_Local(){}; +}; + void QItemC::go() { + QItemC_Local localObject; } + +// We need AUTOMOC processing +#include "qItemC.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.cpp b/Tests/QtAutogen/skipSource/qItemD.cpp new file mode 100644 index 0000000..fe0f4e4 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.cpp @@ -0,0 +1,17 @@ +#include "qItemD.hpp" + +class QItemD_Local : public QObject +{ + Q_OBJECT +public: + QItemD_Local(){}; + ~QItemD_Local(){}; +}; + +void QItemD::go() +{ + QItemD_Local localObject; +} + +// We need AUTOMOC processing +#include "qItemD.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.hpp b/Tests/QtAutogen/skipSource/qItemD.hpp new file mode 100644 index 0000000..99e0acb --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMD_HPP +#define QITEMD_HPP + +#include + +class QItemD : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif -- cgit v0.12