diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-06 16:39:15 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-06 16:39:29 (GMT) |
commit | e1f632cea05b726dcf1e19d55b5549f422dbbe1d (patch) | |
tree | 887cff23a62183b1be3a7ff561a6c04d56ca6aca /Tests | |
parent | b67c53dddfcf956f4d55cbdc0f4e7705f62e805b (diff) | |
parent | 9eab3cad6a118b1dc3b8bcb4da3d6f29c67fce43 (diff) | |
download | CMake-e1f632cea05b726dcf1e19d55b5549f422dbbe1d.zip CMake-e1f632cea05b726dcf1e19d55b5549f422dbbe1d.tar.gz CMake-e1f632cea05b726dcf1e19d55b5549f422dbbe1d.tar.bz2 |
Merge topic 'autogen_hh_headers'
9eab3cad6a Tests: Add AUTOGEN policy CMP0100 test
8c2be3ae94 Tests: Restore Autogen/SameName .hh header test
abad139c99 Autogen: Process .hh headers based on new policy CMP0100 settings
4db1463e05 Autogen: Try adding header suffix to moc output file name on name conflicts
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4170
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt | 31 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/Obj.cpp | 31 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/Obj.hh | 20 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/Obj2.cpp | 31 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/Obj2.hh | 20 | ||||
-rw-r--r-- | Tests/QtAutogen/MocCMP0100/main.cpp | 9 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/main.cpp | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/object.hh | 13 | ||||
-rw-r--r-- | Tests/QtAutogen/Tests.cmake | 1 |
12 files changed, 182 insertions, 1 deletions
diff --git a/Tests/QtAutogen/MocCMP0100/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt new file mode 100644 index 0000000..559cffe --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocCMP0100) +include("../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) + +add_subdirectory(OLD) +add_subdirectory(NEW) diff --git a/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt new file mode 100644 index 0000000..654b31e --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0100 NEW) + +add_executable(mocCMP0100New + ${CSD}/main.cpp + ${CSD}/Obj.hh # Manually include Obj.hh + ${CSD}/Obj.cpp + ${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh +) +target_link_libraries(mocCMP0100New ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt new file mode 100644 index 0000000..2be0535 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0100 OLD) + +# Generate moc files externally. +# If AUTOMOC generates the header moc files as well +# (it should not in OLD behavior), the test will fail with a +# multiple definition error when linking the executable. +qtx_wrap_cpp(mocCMP0100OldMoc ${CSD}/Obj.hh ${CSD}/Obj2.hh) +qtx_generate_moc(${CBD}/Obj.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj.moc) +qtx_generate_moc(${CBD}/Obj2.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj2.moc) + +# Make sure AUTOGEN file skipping is disabled +set_source_files_properties( + ${CSD}/Obj.hh + ${CBD}/Obj.cpp + ${CSD}/Obj2.hh + ${CBD}/Obj2.cpp + PROPERTIES + SKIP_AUTOGEN OFF + SKIP_AUTOMOC OFF +) + +add_executable(mocCMP0100Old + ${CSD}/main.cpp + ${CSD}/Obj.hh # Manually include Obj.hh + ${CSD}/Obj.cpp + ${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh + ${mocCMP0100OldMoc} +) +target_link_libraries(mocCMP0100Old ${QT_LIBRARIES}) +target_include_directories(mocCMP0100Old PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/QtAutogen/MocCMP0100/Obj.cpp b/Tests/QtAutogen/MocCMP0100/Obj.cpp new file mode 100644 index 0000000..bb6d0a0 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj.cpp @@ -0,0 +1,31 @@ +#include "Obj.hh" + +#include <QObject> + +class ObjPrivate : public QObject +{ + Q_OBJECT +public: + ObjPrivate(); + ~ObjPrivate(); +}; + +ObjPrivate::ObjPrivate() +{ +} + +ObjPrivate::~ObjPrivate() +{ +} + +Obj::Obj() + : d(new ObjPrivate) +{ +} + +Obj::~Obj() +{ + delete d; +} + +#include "Obj.moc" diff --git a/Tests/QtAutogen/MocCMP0100/Obj.hh b/Tests/QtAutogen/MocCMP0100/Obj.hh new file mode 100644 index 0000000..940bfc2 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj.hh @@ -0,0 +1,20 @@ +#ifndef OBJ_HH +#define OBJ_HH + +#include <QObject> + +// Qt enabled private class +class ObjPrivate; +// Qt enabled class +class Obj : public QObject +{ + Q_OBJECT +public: + Obj(); + ~Obj(); + +private: + ObjPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0100/Obj2.cpp b/Tests/QtAutogen/MocCMP0100/Obj2.cpp new file mode 100644 index 0000000..8a359ad --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj2.cpp @@ -0,0 +1,31 @@ +#include "Obj2.hh" + +#include <QObject> + +class Obj2Private : public QObject +{ + Q_OBJECT +public: + Obj2Private(); + ~Obj2Private(); +}; + +Obj2Private::Obj2Private() +{ +} + +Obj2Private::~Obj2Private() +{ +} + +Obj2::Obj2() + : d(new Obj2Private) +{ +} + +Obj2::~Obj2() +{ + delete d; +} + +#include "Obj2.moc" diff --git a/Tests/QtAutogen/MocCMP0100/Obj2.hh b/Tests/QtAutogen/MocCMP0100/Obj2.hh new file mode 100644 index 0000000..1c74cdd --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj2.hh @@ -0,0 +1,20 @@ +#ifndef OBJ2_HH +#define OBJ2_HH + +#include <QObject> + +// Qt enabled private class +class Obj2Private; +// Qt enabled class +class Obj2 : public QObject +{ + Q_OBJECT +public: + Obj2(); + ~Obj2(); + +private: + Obj2Private* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0100/main.cpp b/Tests/QtAutogen/MocCMP0100/main.cpp new file mode 100644 index 0000000..17061da --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/main.cpp @@ -0,0 +1,9 @@ +#include "Obj.hh" +#include "Obj2.hh" + +int main(int argv, char** args) +{ + Obj obj; + Obj2 obj2; + return 0; +} diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index cd29a2a..4ce8dbd 100644 --- a/Tests/QtAutogen/SameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -1,7 +1,10 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16.0) project(SameName) include("../AutogenGuiTest.cmake") +# Process .hh headers in AUTOMOC +cmake_policy(SET CMP0100 NEW) + # Test AUTOMOC and AUTORCC on source files with the same name # but in different subdirectories @@ -18,6 +21,7 @@ add_executable(sameName ccc/data.qrc item.cpp object.h + object.hh object.h++ object.hpp object.hxx diff --git a/Tests/QtAutogen/SameName/main.cpp b/Tests/QtAutogen/SameName/main.cpp index 19a6f6d..725f4cd 100644 --- a/Tests/QtAutogen/SameName/main.cpp +++ b/Tests/QtAutogen/SameName/main.cpp @@ -6,6 +6,7 @@ #include "item.hpp" #include "object.h" #include "object.h++" +#include "object.hh" #include "object.hpp" #include "object.hxx" #include "object_upper_ext.H" @@ -21,6 +22,7 @@ int main(int argv, char** args) ::ccc::Item ccc_item; // Object instances ::Object_h obj_h; + ::Object_hh obj_hh; ::Object_hplpl obj_hplpl; ::Object_hpp obj_hpp; ::Object_hxx obj_hxx; diff --git a/Tests/QtAutogen/SameName/object.hh b/Tests/QtAutogen/SameName/object.hh new file mode 100644 index 0000000..3e16f83 --- /dev/null +++ b/Tests/QtAutogen/SameName/object.hh @@ -0,0 +1,13 @@ +#ifndef OBJECT_HH +#define OBJECT_HH + +#include <QObject> + +class Object_hh : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 2b001d4..a19a9ae 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -32,6 +32,7 @@ ADD_AUTOGEN_TEST(UicSkipSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) + ADD_AUTOGEN_TEST(MocCMP0100) ADD_AUTOGEN_TEST(MocInclude) ADD_AUTOGEN_TEST(MocIncludeSymlink) ADD_AUTOGEN_TEST(MocSkipSource) |