From 0b8597a86ee8bed2c34f52d309fd57b5f29a1595 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Fri, 8 Dec 2017 17:29:23 +0100 Subject: Autogen: Tests: Separate mocOnly and mocOnlyOpts tests --- Tests/QtAutogen/CMakeLists.txt | 11 ----------- Tests/QtAutogen/CommonTests.cmake | 2 ++ Tests/QtAutogen/MocOnly/CMakeLists.txt | 8 ++++++++ Tests/QtAutogen/MocOnly/StyleA.cpp | 5 +++++ Tests/QtAutogen/MocOnly/StyleA.hpp | 17 +++++++++++++++++ Tests/QtAutogen/MocOnly/StyleB.cpp | 5 +++++ Tests/QtAutogen/MocOnly/StyleB.hpp | 16 ++++++++++++++++ Tests/QtAutogen/MocOnly/main.cpp | 9 +++++++++ Tests/QtAutogen/MocOptions/CMakeLists.txt | 9 +++++++++ Tests/QtAutogen/MocOptions/Object.cpp | 5 +++++ Tests/QtAutogen/MocOptions/Object.hpp | 13 +++++++++++++ Tests/QtAutogen/MocOptions/main.cpp | 7 +++++++ Tests/QtAutogen/TestMacros.cmake | 7 +++---- Tests/QtAutogen/mocOnlySource/StyleA.cpp | 5 ----- Tests/QtAutogen/mocOnlySource/StyleA.hpp | 15 --------------- Tests/QtAutogen/mocOnlySource/StyleB.cpp | 5 ----- Tests/QtAutogen/mocOnlySource/StyleB.hpp | 16 ---------------- Tests/QtAutogen/mocOnlySource/main.cpp | 9 --------- 18 files changed, 99 insertions(+), 65 deletions(-) create mode 100644 Tests/QtAutogen/MocOnly/CMakeLists.txt create mode 100644 Tests/QtAutogen/MocOnly/StyleA.cpp create mode 100644 Tests/QtAutogen/MocOnly/StyleA.hpp create mode 100644 Tests/QtAutogen/MocOnly/StyleB.cpp create mode 100644 Tests/QtAutogen/MocOnly/StyleB.hpp create mode 100644 Tests/QtAutogen/MocOnly/main.cpp create mode 100644 Tests/QtAutogen/MocOptions/CMakeLists.txt create mode 100644 Tests/QtAutogen/MocOptions/Object.cpp create mode 100644 Tests/QtAutogen/MocOptions/Object.hpp create mode 100644 Tests/QtAutogen/MocOptions/main.cpp delete mode 100644 Tests/QtAutogen/mocOnlySource/StyleA.cpp delete mode 100644 Tests/QtAutogen/mocOnlySource/StyleA.hpp delete mode 100644 Tests/QtAutogen/mocOnlySource/StyleB.cpp delete mode 100644 Tests/QtAutogen/mocOnlySource/StyleB.hpp delete mode 100644 Tests/QtAutogen/mocOnlySource/main.cpp diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index dff9d0c..160903a 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -60,17 +60,6 @@ if(NON_ASCII_BDIR AND WIN32) endif() # -- Test -# MOC only -add_executable(mocOnly mocOnlySource/main.cpp mocOnlySource/StyleA.cpp mocOnlySource/StyleB.cpp) -set_property(TARGET mocOnly PROPERTY AUTOMOC ON) -target_link_libraries(mocOnly ${QT_LIBRARIES}) - -add_executable(mocOnlyOpts mocOnlySource/main.cpp mocOnlySource/StyleA.cpp mocOnlySource/StyleB.cpp) -set_property(TARGET mocOnlyOpts PROPERTY AUTOMOC ON) -set_property(TARGET mocOnlyOpts PROPERTY AUTOMOC_MOC_OPTIONS "-nw") -target_link_libraries(mocOnlyOpts ${QT_LIBRARIES}) - -# -- Test # UIC only if(ALLOW_WRAP_CPP) qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake index 0eaf831..5abbee5 100644 --- a/Tests/QtAutogen/CommonTests.cmake +++ b/Tests/QtAutogen/CommonTests.cmake @@ -1 +1,3 @@ # Autogen tests common for Qt4 and Qt5 +ADD_AUTOGEN_TEST(MocOnly mocOnly) +ADD_AUTOGEN_TEST(MocOptions mocOptions) diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt new file mode 100644 index 0000000..33feadf --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) +project(MocOnly) +include("../AutogenTest.cmake") + +# Test different Q_OBJECT position styles +add_executable(mocOnly StyleA.cpp StyleB.cpp main.cpp) +set_property(TARGET mocOnly PROPERTY AUTOMOC ON) +target_link_libraries(mocOnly ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocOnly/StyleA.cpp b/Tests/QtAutogen/MocOnly/StyleA.cpp new file mode 100644 index 0000000..ced1dd1 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/StyleA.cpp @@ -0,0 +1,5 @@ +#include "StyleA.hpp" + +StyleA::StyleA() +{ +} diff --git a/Tests/QtAutogen/MocOnly/StyleA.hpp b/Tests/QtAutogen/MocOnly/StyleA.hpp new file mode 100644 index 0000000..5ba0a87 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/StyleA.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEA_HPP +#define STYLEA_HPP + +#include + +/* clang-format off */ +/// Q_OBJECT on a single new line +/// +class StyleA : public QObject +{ + Q_OBJECT +public: + StyleA(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/StyleB.cpp b/Tests/QtAutogen/MocOnly/StyleB.cpp new file mode 100644 index 0000000..bec6c1c --- /dev/null +++ b/Tests/QtAutogen/MocOnly/StyleB.cpp @@ -0,0 +1,5 @@ +#include "StyleB.hpp" + +StyleB::StyleB() +{ +} diff --git a/Tests/QtAutogen/MocOnly/StyleB.hpp b/Tests/QtAutogen/MocOnly/StyleB.hpp new file mode 100644 index 0000000..86abaa8 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/StyleB.hpp @@ -0,0 +1,16 @@ +#ifndef STYLEB_HPP +#define STYLEB_HPP + +#include + +/* clang-format off */ +/// Q_OBJECT behind a brace on a new line +/// +class StyleB : public QObject +{ Q_OBJECT +public: + StyleB(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/main.cpp b/Tests/QtAutogen/MocOnly/main.cpp new file mode 100644 index 0000000..06f8d81 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/main.cpp @@ -0,0 +1,9 @@ +#include "StyleA.hpp" +#include "StyleB.hpp" + +int main(int argv, char** args) +{ + StyleA styleA; + StyleB styleB; + return 0; +} diff --git a/Tests/QtAutogen/MocOptions/CMakeLists.txt b/Tests/QtAutogen/MocOptions/CMakeLists.txt new file mode 100644 index 0000000..f64b37b --- /dev/null +++ b/Tests/QtAutogen/MocOptions/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocOptions) +include("../AutogenTest.cmake") + +# Test extra options passed to moc via AUTOMOC_MOC_OPTIONS +add_executable(mocOptions Object.cpp main.cpp) +set_property(TARGET mocOptions PROPERTY AUTOMOC ON) +set_property(TARGET mocOptions PROPERTY AUTOMOC_MOC_OPTIONS "-nw") +target_link_libraries(mocOptions ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocOptions/Object.cpp b/Tests/QtAutogen/MocOptions/Object.cpp new file mode 100644 index 0000000..ad109f1 --- /dev/null +++ b/Tests/QtAutogen/MocOptions/Object.cpp @@ -0,0 +1,5 @@ +#include "Object.hpp" + +Object::Object() +{ +} diff --git a/Tests/QtAutogen/MocOptions/Object.hpp b/Tests/QtAutogen/MocOptions/Object.hpp new file mode 100644 index 0000000..e7a6142 --- /dev/null +++ b/Tests/QtAutogen/MocOptions/Object.hpp @@ -0,0 +1,13 @@ +#ifndef Object_HPP +#define Object_HPP + +#include + +class Object : public QObject +{ + Q_OBJECT +public: + Object(); +}; + +#endif diff --git a/Tests/QtAutogen/MocOptions/main.cpp b/Tests/QtAutogen/MocOptions/main.cpp new file mode 100644 index 0000000..7aeab1a --- /dev/null +++ b/Tests/QtAutogen/MocOptions/main.cpp @@ -0,0 +1,7 @@ +#include "Object.hpp" + +int main(int argv, char** args) +{ + Object object; + return 0; +} diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 849a733..966f3b8 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -41,9 +41,8 @@ macro(ADD_AUTOGEN_TEST NAME) unset(_BuildDir) endmacro() - # Allow using qtx_wrap_cpp and qtx_generate_moc or not -set(ALLOW_WRAP_CPP TRUE) +set(QT_TEST_ALLOW_QT_MACROS TRUE) # Do a simple check if there is are non ASCII character in the build path string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR}) if(NON_ASCII_BDIR) @@ -51,11 +50,11 @@ if(NON_ASCII_BDIR) # qtx_wrap_cpp # https://bugreports.qt.io/browse/QTBUG-35480 if(QT_TEST_VERSION STREQUAL 4) - set(ALLOW_WRAP_CPP FALSE) + set(QT_TEST_ALLOW_QT_MACROS FALSE) endif() # On windows qtx_wrap_cpp also fails in Qt5 when used on a path that # contains non ASCII characters if(WIN32) - set(ALLOW_WRAP_CPP FALSE) + set(QT_TEST_ALLOW_QT_MACROS FALSE) endif() endif() diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.cpp b/Tests/QtAutogen/mocOnlySource/StyleA.cpp deleted file mode 100644 index ced1dd1..0000000 --- a/Tests/QtAutogen/mocOnlySource/StyleA.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "StyleA.hpp" - -StyleA::StyleA() -{ -} diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.hpp b/Tests/QtAutogen/mocOnlySource/StyleA.hpp deleted file mode 100644 index 66735b6..0000000 --- a/Tests/QtAutogen/mocOnlySource/StyleA.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef STYLEA_HPP -#define STYLEA_HPP - -#include - -/// Q_OBJECT on a single new line -/// -class StyleA : public QObject -{ - Q_OBJECT -public: - StyleA(); -}; - -#endif diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.cpp b/Tests/QtAutogen/mocOnlySource/StyleB.cpp deleted file mode 100644 index bec6c1c..0000000 --- a/Tests/QtAutogen/mocOnlySource/StyleB.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "StyleB.hpp" - -StyleB::StyleB() -{ -} diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.hpp b/Tests/QtAutogen/mocOnlySource/StyleB.hpp deleted file mode 100644 index 425daf8..0000000 --- a/Tests/QtAutogen/mocOnlySource/StyleB.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef STYLEB_HPP -#define STYLEB_HPP - -#include - -/* clang-format off */ -/// Q_OBJECT behind a brace -/// -class StyleB : public QObject -{ Q_OBJECT -public: - StyleB(); -}; -/* clang-format on */ - -#endif diff --git a/Tests/QtAutogen/mocOnlySource/main.cpp b/Tests/QtAutogen/mocOnlySource/main.cpp deleted file mode 100644 index 06f8d81..0000000 --- a/Tests/QtAutogen/mocOnlySource/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "StyleA.hpp" -#include "StyleB.hpp" - -int main(int argv, char** args) -{ - StyleA styleA; - StyleB styleB; - return 0; -} -- cgit v0.12