diff options
Diffstat (limited to 'Tests/QtAutogen/MocOnly')
-rw-r--r-- | Tests/QtAutogen/MocOnly/CMakeLists.txt | 29 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgDebug.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgDebug.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgOther.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgOther.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/IncA.cpp | 19 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/IncA.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/IncB.cpp | 19 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/IncB.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/StyleA.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/StyleA.hpp | 17 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/StyleB.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/StyleB.hpp | 16 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/main.cpp | 27 |
14 files changed, 207 insertions, 0 deletions
diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt new file mode 100644 index 0000000..b5d405a --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.16) +project(MocOnly) +include("../AutogenCoreTest.cmake") + +add_executable(mocOnly + main.cpp + # Test different Q_OBJECT position styles + StyleA.cpp + StyleB.cpp + # Test different moc_/.moc include positions + IncA.cpp + IncB.cpp +) +# XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion +# when the Xcode generator supports per-config sources. +if(NOT NO_PER_CONFIG_SOURCES) + target_sources(mocOnly PRIVATE + "$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/CfgDebug.cpp>" + "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_CURRENT_SOURCE_DIR}/CfgOther.cpp>" + ) + target_compile_definitions(mocOnly PRIVATE + "$<$<CONFIG:Debug>:HAVE_CFG_DEBUG>" + "$<$<NOT:$<CONFIG:Debug>>:HAVE_CFG_OTHER>" + ) +endif() +set_property(TARGET mocOnly PROPERTY AUTOMOC ON) +target_link_libraries(mocOnly ${QT_LIBRARIES}) +# Add compile definitions with unusual characters +target_compile_definitions(mocOnly PUBLIC "TOKEN=\"hello\;\"" ) diff --git a/Tests/QtAutogen/MocOnly/CfgDebug.cpp b/Tests/QtAutogen/MocOnly/CfgDebug.cpp new file mode 100644 index 0000000..07ca3fb --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgDebug.cpp @@ -0,0 +1,5 @@ +#include "CfgDebug.hpp" + +CfgDebug::CfgDebug() +{ +} diff --git a/Tests/QtAutogen/MocOnly/CfgDebug.hpp b/Tests/QtAutogen/MocOnly/CfgDebug.hpp new file mode 100644 index 0000000..3cd90a4 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgDebug.hpp @@ -0,0 +1,15 @@ +#ifndef CFGDEBUG_HPP +#define CFGDEBUG_HPP + +#include <QObject> + +/* clang-format off */ +class CfgDebug : public QObject +{ + Q_OBJECT +public: + CfgDebug(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/CfgOther.cpp b/Tests/QtAutogen/MocOnly/CfgOther.cpp new file mode 100644 index 0000000..0ccd433 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgOther.cpp @@ -0,0 +1,5 @@ +#include "CfgOther.hpp" + +CfgOther::CfgOther() +{ +} diff --git a/Tests/QtAutogen/MocOnly/CfgOther.hpp b/Tests/QtAutogen/MocOnly/CfgOther.hpp new file mode 100644 index 0000000..7cacd52 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgOther.hpp @@ -0,0 +1,15 @@ +#ifndef CFGOTHER_HPP +#define CFGOTHER_HPP + +#include <QObject> + +/* clang-format off */ +class CfgOther : public QObject +{ + Q_OBJECT +public: + CfgOther(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/IncA.cpp b/Tests/QtAutogen/MocOnly/IncA.cpp new file mode 100644 index 0000000..94610cd --- /dev/null +++ b/Tests/QtAutogen/MocOnly/IncA.cpp @@ -0,0 +1,19 @@ +#include "moc_IncA.cpp" +/// AUTOMOC moc_ include on the first line of the file! +#include "IncA.hpp" + +/// @brief Source local QObject +/// +class IncAPrivate : public QObject +{ + Q_OBJECT +public: + IncAPrivate(){}; +}; + +IncA::IncA() +{ + IncAPrivate priv; +} + +#include "IncA.moc" diff --git a/Tests/QtAutogen/MocOnly/IncA.hpp b/Tests/QtAutogen/MocOnly/IncA.hpp new file mode 100644 index 0000000..ecc889f --- /dev/null +++ b/Tests/QtAutogen/MocOnly/IncA.hpp @@ -0,0 +1,15 @@ +#ifndef INCA_HPP +#define INCA_HPP + +#include <QObject> + +/// @brief Test moc include pattern in the source file +/// +class IncA : public QObject +{ + Q_OBJECT +public: + IncA(); +}; + +#endif diff --git a/Tests/QtAutogen/MocOnly/IncB.cpp b/Tests/QtAutogen/MocOnly/IncB.cpp new file mode 100644 index 0000000..bd441a9 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/IncB.cpp @@ -0,0 +1,19 @@ +#include "IncB.hpp" + +/// @brief Source local QObject +/// +class IncBPrivate : public QObject +{ + Q_OBJECT +public: + IncBPrivate(){}; +}; + +IncB::IncB() +{ + IncBPrivate priv; +} + +/// AUTOMOC moc_ include on the last line of the file! +#include "IncB.moc" +#include "moc_IncB.cpp" diff --git a/Tests/QtAutogen/MocOnly/IncB.hpp b/Tests/QtAutogen/MocOnly/IncB.hpp new file mode 100644 index 0000000..8331ea2 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/IncB.hpp @@ -0,0 +1,15 @@ +#ifndef INCB_HPP +#define INCB_HPP + +#include <QObject> + +/// @brief Test moc include pattern in the source file +/// +class IncB : public QObject +{ + Q_OBJECT +public: + IncB(); +}; + +#endif 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 <QObject> + +/* 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 <QObject> + +/* 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..6c0f6f2 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/main.cpp @@ -0,0 +1,27 @@ +#include <iostream> + +#include "IncA.hpp" +#include "IncB.hpp" +#include "StyleA.hpp" +#include "StyleB.hpp" + +#ifdef HAVE_CFG_DEBUG +# include "CfgDebug.hpp" +#endif + +#ifdef HAVE_CFG_OTHER +# include "CfgOther.hpp" +#endif + +int main(int argv, char** args) +{ + StyleA styleA; + StyleB styleB; + IncA incA; + IncB incB; + + // Test the TOKEN definition passed on the command line + std::string token(TOKEN); + std::cout << "std::string(TOKEN): \"" << token << "\"\n"; + return (token == "hello;") ? 0 : -1; +} |