From 5380ad9d58c614aeaddb6be7a7fcc28cbf50c856 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Wed, 31 May 2023 16:48:04 +0200 Subject: Tests: Add test for AUTOMOC_MOC_OPTIONS Fixes: #23894 --- Tests/QtAutogen/MocOptions2/CMakeLists.txt | 10 ++++++++++ Tests/QtAutogen/MocOptions2/main.cpp | 7 +++++++ Tests/QtAutogen/MocOptions2/object.cpp | 5 +++++ Tests/QtAutogen/MocOptions2/object.hpp | 15 +++++++++++++++ Tests/QtAutogen/Tests.cmake | 1 + 5 files changed, 38 insertions(+) create mode 100644 Tests/QtAutogen/MocOptions2/CMakeLists.txt create mode 100644 Tests/QtAutogen/MocOptions2/main.cpp create mode 100644 Tests/QtAutogen/MocOptions2/object.cpp create mode 100644 Tests/QtAutogen/MocOptions2/object.hpp diff --git a/Tests/QtAutogen/MocOptions2/CMakeLists.txt b/Tests/QtAutogen/MocOptions2/CMakeLists.txt new file mode 100644 index 0000000..c664f4d --- /dev/null +++ b/Tests/QtAutogen/MocOptions2/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +project(MocOptions2) +include("../AutogenCoreTest.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) +target_compile_options(mocOptions PRIVATE "-D_EXTRA_DEFINE") +set_property(TARGET mocOptions PROPERTY AUTOMOC_MOC_OPTIONS "-D_EXTRA_DEFINE") +target_link_libraries(mocOptions ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocOptions2/main.cpp b/Tests/QtAutogen/MocOptions2/main.cpp new file mode 100644 index 0000000..98875f0 --- /dev/null +++ b/Tests/QtAutogen/MocOptions2/main.cpp @@ -0,0 +1,7 @@ +#include "object.hpp" + +int main() +{ + Object object; + return 0; +} diff --git a/Tests/QtAutogen/MocOptions2/object.cpp b/Tests/QtAutogen/MocOptions2/object.cpp new file mode 100644 index 0000000..7960736 --- /dev/null +++ b/Tests/QtAutogen/MocOptions2/object.cpp @@ -0,0 +1,5 @@ +#include "object.hpp" + +Object::Object() +{ +} diff --git a/Tests/QtAutogen/MocOptions2/object.hpp b/Tests/QtAutogen/MocOptions2/object.hpp new file mode 100644 index 0000000..0bb4e81 --- /dev/null +++ b/Tests/QtAutogen/MocOptions2/object.hpp @@ -0,0 +1,15 @@ +#ifndef Object_HPP +#define Object_HPP + +#include + +#ifdef _EXTRA_DEFINE +class Object : public QObject +{ + Q_OBJECT +public: + Object(); +}; +#endif + +#endif diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 7dd9c84..d676abd 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -12,6 +12,7 @@ ADD_AUTOGEN_TEST(ManySources manySources) ADD_AUTOGEN_TEST(MocInterfaceMacroNames) ADD_AUTOGEN_TEST(MocOnly mocOnly) ADD_AUTOGEN_TEST(MocOptions mocOptions) +ADD_AUTOGEN_TEST(MocOptions2) ADD_AUTOGEN_TEST(ObjectLibrary someProgram) ADD_AUTOGEN_TEST(Parallel parallel) ADD_AUTOGEN_TEST(Parallel1 parallel1) -- cgit v0.12