diff options
Diffstat (limited to 'Tests/QtAutogen')
454 files changed, 5444 insertions, 1097 deletions
diff --git a/Tests/QtAutogen/AutogenCoreTest.cmake b/Tests/QtAutogen/AutogenCoreTest.cmake new file mode 100644 index 000000000..580385928 --- /dev/null +++ b/Tests/QtAutogen/AutogenCoreTest.cmake @@ -0,0 +1,55 @@ + +# Tell find_package(Qt5) where to find Qt. +if(QT_QMAKE_EXECUTABLE) + get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) + get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) + list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) +endif() + +if (QT_TEST_VERSION EQUAL 4) + + find_package(Qt4 REQUIRED QtCore) + include(UseQt4) + + set(QT_QTCORE_TARGET Qt4::QtCore) + + # Qt macros + macro(qtx_wrap_cpp) + qt4_wrap_cpp(${ARGN}) + endmacro() + macro(qtx_generate_moc) + qt4_generate_moc(${ARGN}) + endmacro() + +elseif(QT_TEST_VERSION EQUAL 5) + + find_package(Qt5Core REQUIRED) + + set(QT_QTCORE_TARGET Qt5::Core) + set(QT_LIBRARIES Qt5::Core) + + # Include directories + include_directories(${Qt5Core_INCLUDE_DIRS}) + + # Definitions + if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + endif() + + # Qt macros + macro(qtx_wrap_cpp) + qt5_wrap_cpp(${ARGN}) + endmacro() + macro(qtx_generate_moc) + qt5_generate_moc(${ARGN}) + endmacro() + +else() + message(SEND_ERROR "Invalid Qt version specified: ${QT_TEST_VERSION}") +endif() + +# Get Qt compile features +get_property(QT_COMPILE_FEATURES + TARGET ${QT_QTCORE_TARGET} + PROPERTY INTERFACE_COMPILE_FEATURES +) diff --git a/Tests/QtAutogen/AutogenGuiTest.cmake b/Tests/QtAutogen/AutogenGuiTest.cmake new file mode 100644 index 000000000..b76d341a4 --- /dev/null +++ b/Tests/QtAutogen/AutogenGuiTest.cmake @@ -0,0 +1,55 @@ + +# Tell find_package(Qt5) where to find Qt. +if(QT_QMAKE_EXECUTABLE) + get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) + get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) + list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) +endif() + +if (QT_TEST_VERSION EQUAL 4) + + find_package(Qt4 REQUIRED) + include(UseQt4) + + set(QT_QTCORE_TARGET Qt4::QtCore) + + # Qt macros + macro(qtx_wrap_cpp) + qt4_wrap_cpp(${ARGN}) + endmacro() + macro(qtx_generate_moc) + qt4_generate_moc(${ARGN}) + endmacro() + +elseif(QT_TEST_VERSION EQUAL 5) + + find_package(Qt5Widgets REQUIRED) + + set(QT_QTCORE_TARGET Qt5::Core) + set(QT_LIBRARIES Qt5::Widgets) + + # Include directories + include_directories(${Qt5Widgets_INCLUDE_DIRS}) + + # Definitions + if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + endif() + + # Qt macros + macro(qtx_wrap_cpp) + qt5_wrap_cpp(${ARGN}) + endmacro() + macro(qtx_generate_moc) + qt5_generate_moc(${ARGN}) + endmacro() + +else() + message(SEND_ERROR "Invalid Qt version specified: ${QT_TEST_VERSION}") +endif() + +# Get Qt compile features +get_property(QT_COMPILE_FEATURES + TARGET ${QT_QTCORE_TARGET} + PROPERTY INTERFACE_COMPILE_FEATURES +) diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt new file mode 100644 index 000000000..9e6fe8b34 --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 3.11) +project(AutogenOriginDependsOff) +include("../AutogenCoreTest.cmake") + +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CSD}) +include_directories(${CBD}) + +# A GENERATED file ensures there will be an _autogen target in VS +add_custom_command ( + OUTPUT "${CBD}/config.hpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CSD}/config.hpp.in" "${CBD}/config.hpp" + ) + + +# Library "a_mc" provides a header that holds a string with the content of +# mocs_compilation.cpp from a_qt. It therefore must depend on a_qt_autogen. +add_custom_target ( a_mc + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} + "-DMCF=${CBD}/a_qt_autogen/mocs_compilation.cpp" + "-DCF_IN=${CSD}/a_mc.hpp.in" + "-DCF_OUT=${CBD}/a_mc.hpp" + -P ${CSD}/configure_content.cmake + ) +add_dependencies ( a_mc a_qt_autogen ) + +# Library "a_qt" +# - depends on a GENERATED file +# - AUTOMOC enabled +# - depends on a target (a_mc) that depends on a_qt_qutogen +add_library ( a_qt a_qt.cpp "${CBD}/config.hpp" ) +add_dependencies ( a_qt a_mc ) +target_link_libraries ( a_qt ${QT_QTCORE_TARGET}) +set_target_properties ( a_qt PROPERTIES AUTOMOC TRUE) +# Disable AUTOGEN_ORIGIN_DEPENDS to avoid loop dependencies +set_target_properties ( a_qt PROPERTIES AUTOGEN_ORIGIN_DEPENDS OFF) + + +# Library "b_mc" provides a header that holds a string function that returns +# the content of mocs_compilation.cpp from b_qt. +# It therefore must depend on b_qt_autogen. +add_custom_command ( + OUTPUT ${CBD}/b_mc.cpp + DEPENDS b_qt_autogen + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} + "-DMCF=${CBD}/b_qt_autogen/mocs_compilation.cpp" + "-DCF_IN=${CSD}/b_mc.cpp.in" + "-DCF_OUT=${CBD}/b_mc.cpp" + -P ${CSD}/configure_content.cmake + ) +add_library ( b_mc ${CSD}/b_mc.hpp ${CBD}/b_mc.cpp ) + +# Library "b_qt" +# - depends on a GENERATED file +# - AUTOMOC enabled +# - depends on a library (b_mc) that depends on b_qt_qutogen +add_library ( b_qt b_qt.cpp "${CBD}/config.hpp" ) +target_link_libraries ( b_qt b_mc ) +target_link_libraries ( b_qt ${QT_QTCORE_TARGET}) +set_target_properties ( b_qt PROPERTIES AUTOMOC TRUE) +# Disable AUTOGEN_ORIGIN_DEPENDS to avoid loop dependencies +set_target_properties ( b_qt PROPERTIES AUTOGEN_ORIGIN_DEPENDS OFF) + + +# The main target depends on both libraries which depend on the _autogen +# target of the main target. +add_executable ( autogenOriginDependsOff main.cpp ) +target_link_libraries ( autogenOriginDependsOff a_qt b_qt ) diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in new file mode 100644 index 000000000..fe71f673d --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in @@ -0,0 +1,9 @@ +#ifndef A_MC_HPP +#define A_MC_HPP + +namespace a_mc { + +char const* mocs_compilation = "@MOCS_COMPILATION@"; +} + +#endif diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp new file mode 100644 index 000000000..c7c6863d5 --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp @@ -0,0 +1,29 @@ + +#include "a_qt.hpp" + +#include <a_mc.hpp> + +namespace a_qt { + +/// @brief A source local QObject based class +class Source_QObject : public QObject +{ + Q_OBJECT +public: + Source_QObject() {} + ~Source_QObject() {} + + std::string str; +}; + +std::string mocs_compilation() +{ + // Create and destroy QObject based classes + Header_QObject header_obj; + Source_QObject source_obj; + + return std::string(a_mc::mocs_compilation); +} +} + +#include "a_qt.moc" diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp new file mode 100644 index 000000000..fafc8a20e --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp @@ -0,0 +1,27 @@ +#ifndef A_QT_HPP +#define A_QT_HPP + +#include <string> + +#include <config.hpp> + +#include <QObject> + +namespace a_qt { + +/// @brief A header local QObject based class +class Header_QObject : public QObject +{ + Q_OBJECT +public: + Header_QObject() {} + ~Header_QObject() {} + + std::string str; +}; + +/// @brief Function that returns the content of mocs_compilation.cpp +extern std::string mocs_compilation(); +} + +#endif diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in new file mode 100644 index 000000000..0f5ec308c --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in @@ -0,0 +1,9 @@ +#include <b_mc.hpp> + +namespace b_mc { + +char const* mocs_compilation() +{ + return "@MOCS_COMPILATION@"; +} +} diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp new file mode 100644 index 000000000..043727359 --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp @@ -0,0 +1,9 @@ +#ifndef B_MC_HPP +#define B_MC_HPP + +namespace b_mc { + +extern char const* mocs_compilation(); +} + +#endif diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp new file mode 100644 index 000000000..c5adaebda --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp @@ -0,0 +1,29 @@ + +#include "b_qt.hpp" + +#include <b_mc.hpp> + +namespace b_qt { + +/// @brief A source local QObject based class +class Source_QObject : public QObject +{ + Q_OBJECT +public: + Source_QObject() {} + ~Source_QObject() {} + + std::string str; +}; + +std::string mocs_compilation() +{ + // Create and destroy QObject based classes + Header_QObject header_obj; + Source_QObject source_obj; + + return std::string(b_mc::mocs_compilation()); +} +} + +#include "b_qt.moc" diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp new file mode 100644 index 000000000..b798e71ca --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp @@ -0,0 +1,27 @@ +#ifndef B_QT_HPP +#define B_QT_HPP + +#include <string> + +#include <config.hpp> + +#include <QObject> + +namespace b_qt { + +/// @brief A header local QObject based class +class Header_QObject : public QObject +{ + Q_OBJECT +public: + Header_QObject() {} + ~Header_QObject() {} + + std::string str; +}; + +/// @brief Function that returns the content of mocs_compilation.cpp +extern std::string mocs_compilation(); +} + +#endif diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in new file mode 100644 index 000000000..e415d0855 --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in @@ -0,0 +1,8 @@ +#ifndef CONFIG_HPP +#define CONFIG_HPP + +// Application configuration + +enum dummy { NO_OP }; + +#endif diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake b/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake new file mode 100644 index 000000000..0fc6e638d --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) + +# Read mocs_compilation.cpp file into variable +file(READ "${MCF}" MOCS_COMPILATION) +string(REPLACE "\\" "\\\\" MOCS_COMPILATION "${MOCS_COMPILATION}" ) +string(REPLACE "\"" "\\\"" MOCS_COMPILATION "${MOCS_COMPILATION}" ) +string(REPLACE "\n" "\"\n\"" MOCS_COMPILATION "${MOCS_COMPILATION}" ) + +# Configure file +configure_file ( "${CF_IN}" "${CF_OUT}" @ONLY ) diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp new file mode 100644 index 000000000..3fb6c7095 --- /dev/null +++ b/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp @@ -0,0 +1,16 @@ + +#include <string> + +#include <a_qt.hpp> +#include <b_qt.hpp> + +int main() +{ + if (a_qt::mocs_compilation().empty()) { + return -1; + } + if (b_qt::mocs_compilation().empty()) { + return -1; + } + return 0; +} diff --git a/Tests/QtAutogen/mocDepends/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt index 6241ef93d..5aabe0e68 100644 --- a/Tests/QtAutogen/mocDepends/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt @@ -1,17 +1,6 @@ -cmake_minimum_required(VERSION 3.9) -project(mocDepends CXX) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() +cmake_minimum_required(VERSION 3.10) +project(AutogenOriginDependsOn) +include("../AutogenCoreTest.cmake") include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) @@ -41,9 +30,8 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenFile.hpp) add_executable(mocDepGenFile testGenFile.cpp ${CBD}/GenFile.hpp) -target_link_libraries(mocDepGenFile ${QT_CORE_TARGET}) +target_link_libraries(mocDepGenFile ${QT_QTCORE_TARGET}) set_target_properties(mocDepGenFile PROPERTIES AUTOMOC TRUE) -set_property(TARGET mocDepGenFile PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1) # -- Test dependency on header generating custom target @@ -69,7 +57,7 @@ add_custom_target(mocDepTargetUtil COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenTarget.hpp) add_executable(mocDepTarget testGenTarget.cpp) -target_link_libraries(mocDepTarget ${QT_CORE_TARGET}) +target_link_libraries(mocDepTarget ${QT_QTCORE_TARGET}) set_target_properties(mocDepTarget PROPERTIES AUTOMOC TRUE) add_dependencies(mocDepTarget mocDepTargetUtil) @@ -96,56 +84,8 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.hpp.in ${CBD}/simpleLib.hpp COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.cpp.in ${CBD}/simpleLib.cpp) add_library(SimpleLib STATIC ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp) -target_link_libraries(SimpleLib ${QT_CORE_TARGET}) +target_link_libraries(SimpleLib ${QT_QTCORE_TARGET}) add_executable(mocDepGenLib testGenLib.cpp) -target_link_libraries(mocDepGenLib SimpleLib ${QT_CORE_TARGET}) +target_link_libraries(mocDepGenLib SimpleLib ${QT_QTCORE_TARGET}) set_target_properties(mocDepGenLib PROPERTIES AUTOMOC TRUE) - - -# -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency -# -# This tests the dependency of the mocDepATDFile_autogen target of -# mocDepATDTarget to the utility target mocDepATDFileUtil. -# If mocDepATDFile_autogen gets built *before* or in *parallel* to -# mocDepATDFileUtil, the build will fail. That's -# because ATDFile.hpp, which is required by mocDepATDFile_autogen, -# is only valid after the mocDepATDFileUtil build has been completed. -# -# The sleep seconds artificially increase the build time of -# mocDepATDFileUtil to simulate a slow utility target build that takes -# longer to run than the build of the mocDepATDFile_autogen target. -add_custom_command( - OUTPUT ${CBD}/ATDFile.hpp - COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp - COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp) - -add_executable(mocDepATDFile testATDFile.cpp) -target_link_libraries(mocDepATDFile ${QT_CORE_TARGET}) -set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE) -set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp) - - -# -- Test AUTOGEN_TARGET_DEPENDS with target dependency -# -# This tests the dependency of the mocDepATDTarget_autogen target of -# mocDepATDTarget to the utility target mocDepATDTargetUtil. -# If mocDepATDTarget_autogen gets built *before* or in *parallel* to -# mocDepATDTargetUtil, the build will fail. That's -# because ATDTarget.hpp, which is required by mocDepATDTarget_autogen, -# is only valid after the mocDepATDTargetUtil build has been completed. -# -# The sleep seconds artificially increase the build time of -# mocDepATDTargetUtil to simulate a slow utility target build that takes -# longer to run than the build of the mocDepATDTarget_autogen target. -add_custom_target(mocDepATDTargetUtil - BYPRODUCTS ${CBD}/ATDTarget.hpp - COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp - COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp) - -add_executable(mocDepATDTarget testATDTarget.cpp) -target_link_libraries(mocDepATDTarget ${QT_CORE_TARGET}) -set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE) -set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil) diff --git a/Tests/QtAutogen/mocDepends/object_invalid.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/object_invalid.hpp.in index 854d9a143..854d9a143 100644 --- a/Tests/QtAutogen/mocDepends/object_invalid.hpp.in +++ b/Tests/QtAutogen/AutogenOriginDependsOn/object_invalid.hpp.in diff --git a/Tests/QtAutogen/mocDepends/object_valid.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/object_valid.hpp.in index f364f7c97..f364f7c97 100644 --- a/Tests/QtAutogen/mocDepends/object_valid.hpp.in +++ b/Tests/QtAutogen/AutogenOriginDependsOn/object_valid.hpp.in diff --git a/Tests/QtAutogen/mocDepends/simpleLib.cpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.cpp.in index fa33bd375..fa33bd375 100644 --- a/Tests/QtAutogen/mocDepends/simpleLib.cpp.in +++ b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.cpp.in diff --git a/Tests/QtAutogen/mocDepends/simpleLib.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.hpp.in index b65b0cb4a..b65b0cb4a 100644 --- a/Tests/QtAutogen/mocDepends/simpleLib.hpp.in +++ b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.hpp.in diff --git a/Tests/QtAutogen/mocDepends/testGenFile.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenFile.cpp index 7df6e137c..7df6e137c 100644 --- a/Tests/QtAutogen/mocDepends/testGenFile.cpp +++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenFile.cpp diff --git a/Tests/QtAutogen/mocDepends/testGenLib.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.cpp index c14e15958..c14e15958 100644 --- a/Tests/QtAutogen/mocDepends/testGenLib.cpp +++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.cpp diff --git a/Tests/QtAutogen/mocDepends/testGenLib.hpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp index 408335bd2..55457d212 100644 --- a/Tests/QtAutogen/mocDepends/testGenLib.hpp +++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp @@ -1,9 +1,10 @@ #ifndef TEST3_HPP #define TEST3_HPP -#include "simpleLib.hpp" #include <QObject> +#include "simpleLib.hpp" + // This object triggers the AUTOMOC on this file class LObject : public QObject { diff --git a/Tests/QtAutogen/mocDepends/testGenTarget.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenTarget.cpp index 911076efd..911076efd 100644 --- a/Tests/QtAutogen/mocDepends/testGenTarget.cpp +++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenTarget.cpp diff --git a/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt new file mode 100644 index 000000000..492b5dbd3 --- /dev/null +++ b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.10) +project(AutogenTargetDepends) +include("../AutogenCoreTest.cmake") + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) + +# -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency +# +# This tests the dependency of the mocDepATDFile_autogen target of +# mocDepATDTarget to the utility target mocDepATDFileUtil. +# If mocDepATDFile_autogen gets built *before* or in *parallel* to +# mocDepATDFileUtil, the build will fail. That's +# because ATDFile.hpp, which is required by mocDepATDFile_autogen, +# is only valid after the mocDepATDFileUtil build has been completed. +# +# The sleep seconds artificially increase the build time of +# mocDepATDFileUtil to simulate a slow utility target build that takes +# longer to run than the build of the mocDepATDFile_autogen target. +add_custom_command( + OUTPUT ${CBD}/ATDFile.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp + COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp) + +add_executable(mocDepATDFile testATDFile.cpp) +target_link_libraries(mocDepATDFile ${QT_QTCORE_TARGET}) +set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE) +set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp) + + +# -- Test AUTOGEN_TARGET_DEPENDS with target dependency +# +# This tests the dependency of the mocDepATDTarget_autogen target of +# mocDepATDTarget to the utility target mocDepATDTargetUtil. +# If mocDepATDTarget_autogen gets built *before* or in *parallel* to +# mocDepATDTargetUtil, the build will fail. That's +# because ATDTarget.hpp, which is required by mocDepATDTarget_autogen, +# is only valid after the mocDepATDTargetUtil build has been completed. +# +# The sleep seconds artificially increase the build time of +# mocDepATDTargetUtil to simulate a slow utility target build that takes +# longer to run than the build of the mocDepATDTarget_autogen target. +add_custom_target(mocDepATDTargetUtil + BYPRODUCTS ${CBD}/ATDTarget.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp + COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp) + +add_executable(mocDepATDTarget testATDTarget.cpp) +target_link_libraries(mocDepATDTarget ${QT_QTCORE_TARGET}) +set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE) +set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil) diff --git a/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in b/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in new file mode 100644 index 000000000..854d9a143 --- /dev/null +++ b/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in @@ -0,0 +1 @@ +#ifndef diff --git a/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in b/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in new file mode 100644 index 000000000..f364f7c97 --- /dev/null +++ b/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in @@ -0,0 +1,14 @@ +#ifndef OBJECT_HPP +#define OBJECT_HPP + +#include <QObject> + +class Object : public QObject +{ + Q_OBJECT +public: + Q_SLOT + void aSlot(){}; +}; + +#endif diff --git a/Tests/QtAutogen/mocDepends/testATDFile.cpp b/Tests/QtAutogen/AutogenTargetDepends/testATDFile.cpp index 6bddfcd39..6bddfcd39 100644 --- a/Tests/QtAutogen/mocDepends/testATDFile.cpp +++ b/Tests/QtAutogen/AutogenTargetDepends/testATDFile.cpp diff --git a/Tests/QtAutogen/mocDepends/testATDTarget.cpp b/Tests/QtAutogen/AutogenTargetDepends/testATDTarget.cpp index 831fc2691..831fc2691 100644 --- a/Tests/QtAutogen/mocDepends/testATDTarget.cpp +++ b/Tests/QtAutogen/AutogenTargetDepends/testATDTarget.cpp diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt deleted file mode 100644 index 073c5fdef..000000000 --- a/Tests/QtAutogen/CMakeLists.txt +++ /dev/null @@ -1,365 +0,0 @@ -cmake_minimum_required(VERSION 3.7) - -project(QtAutogen) - -# Tell find_package(Qt5) where to find Qt. -if(QT_QMAKE_EXECUTABLE) - get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) - get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) - set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) -endif() - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - - # Include this directory before using the UseQt4 file. - add_subdirectory(defines_test) - - include(UseQt4) - - set(QT_QTCORE_TARGET Qt4::QtCore) - - macro(qtx_wrap_cpp) - qt4_wrap_cpp(${ARGN}) - endmacro() - -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - find_package(Qt5Widgets REQUIRED) - - set(QT_QTCORE_TARGET Qt5::Core) - - include_directories(${Qt5Widgets_INCLUDE_DIRS}) - set(QT_LIBRARIES Qt5::Widgets) - - if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) - add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) - endif() - - macro(qtx_wrap_cpp) - qt5_wrap_cpp(${ARGN}) - endmacro() - -endif() - -get_property(QT_COMPILE_FEATURES TARGET ${QT_QTCORE_TARGET} PROPERTY INTERFACE_COMPILE_FEATURES) - -# -- Test -# RCC only -add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc) -set_property(TARGET rccOnly PROPERTY AUTORCC ON) -target_link_libraries(rccOnly ${QT_QTCORE_TARGET}) - -# -- Test -# RCC empty -add_executable(rccEmpty rccEmpty.cpp rccEmptyRes.qrc) -set_property(TARGET rccEmpty PROPERTY AUTORCC ON) -target_link_libraries(rccEmpty ${QT_QTCORE_TARGET}) - -# -- Test -# UIC only -qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) -add_executable(uicOnly uicOnlySource/uiconly.cpp ${uicOnlyMoc}) -set_property(TARGET uicOnly PROPERTY AUTOUIC ON) -target_link_libraries(uicOnly ${QT_LIBRARIES}) - -# -- Test -# Add not_generated_file.qrc to the source list to get the file-level -# dependency, but don't generate a c++ file from it. Disable the AUTORCC -# feature for this target. This tests that qrc files in the sources don't -# have an effect on generation if AUTORCC is off. -add_library(empty STATIC empty.cpp not_generated_file.qrc) -set_target_properties(empty PROPERTIES AUTORCC OFF) -set_target_properties(empty PROPERTIES AUTOMOC TRUE) -target_link_libraries(empty no_link_language) -add_library(no_link_language STATIC empty.h) -set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) -# Pass Qt compiler features to targets that don't link against Qt -target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) -target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) - -# -- Test -# When a file listed in a .qrc file changes the target must be rebuilt -set(timeformat "%Y%j%H%M%S") -set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends") -set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends") -configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -try_compile(RCC_DEPENDS - "${RCC_DEPENDS_BIN}" - "${RCC_DEPENDS_SRC}" - rccDepends - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList) -list(GET targetList 0 rccDependsBin) -file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}") -# Sleep, touch regular qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!") -endif() -# Sleep, update regular qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}") -if (NOT timeStep2 GREATER timeStep1) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!") -endif() -# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}") -if (NOT timeStep3 GREATER timeStep2) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!") -endif() -# Sleep, touch generated qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}") -if (NOT timeStep4 GREATER timeStep3) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!") -endif() -# Sleep, update generated qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Sixth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}") -if (NOT timeStep5 GREATER timeStep4) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!") -endif() -# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Seventh build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}") -if (NOT timeStep6 GREATER timeStep5) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!") -endif() - - -# -- Test -# Ensure a repeated build succeeds when a header containing a QObject changes -set(timeformat "%Y%j%H%M%S") -configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY) -try_compile(MOC_RERUN - "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun" - mocRerun - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List) -list(GET target1List 0 binFile) -file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") -# Change file content and rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - RESULT_VARIABLE mocRerun_result - ) -if (mocRerun_result) - message(SEND_ERROR "Second build of mocRerun failed.") -endif() -# Compare timestamps -file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${binFile}) should have changed in the first step!") -endif() - -# -- Test -# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target -qtx_wrap_cpp(skipMocWrapMoc - skipSource/qItemA.hpp - skipSource/qItemB.hpp) -set(skipMocSources - skipMoc.cpp - skipSource/qItemA.cpp - skipSource/qItemB.cpp - skipSource/qItemC.cpp) -set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) -set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) -# AUTOMOC enabled only -add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) -set_property(TARGET skipMocA PROPERTY AUTOMOC ON) -target_link_libraries(skipMocA ${QT_LIBRARIES}) -# AUTOMOC and AUTOUIC enabled -add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) -set_property(TARGET skipMocB PROPERTY AUTOMOC ON) -set_property(TARGET skipMocB PROPERTY AUTOUIC ON) -target_link_libraries(skipMocB ${QT_LIBRARIES}) - -# -- Test -# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target -set(skipUicSources - skipUic.cpp - skipSource/skipUicGen.cpp - skipSource/skipUicNoGen1.cpp - skipSource/skipUicNoGen2.cpp -) -set_property(SOURCE skipSource/skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON) -set_property(SOURCE skipSource/skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON) -# AUTOUIC enabled -add_executable(skipUicA ${skipUicSources}) -set_property(TARGET skipUicA PROPERTY AUTOUIC ON) -target_link_libraries(skipUicA ${QT_LIBRARIES}) -# AUTOUIC and AUTOMOC enabled -add_executable(skipUicB ${skipUicSources}) -set_property(TARGET skipUicB PROPERTY AUTOUIC ON) -set_property(TARGET skipUicB PROPERTY AUTOMOC ON) -target_link_libraries(skipUicB ${QT_LIBRARIES}) - -# -- Test -# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target -set(skipRccSources - skipRcc.cpp - skipSource/skipRccBad1.qrc - skipSource/skipRccBad2.qrc - skipSource/skipRccGood.qrc -) -set_property(SOURCE skipSource/skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON) -set_property(SOURCE skipSource/skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON) -# AUTORCC enabled -add_executable(skipRccA ${skipRccSources}) -set_property(TARGET skipRccA PROPERTY AUTORCC ON) -target_link_libraries(skipRccA ${QT_LIBRARIES}) -# AUTORCC, AUTOUIC and AUTOMOC enabled -add_executable(skipRccB ${skipRccSources}) -set_property(TARGET skipRccB PROPERTY AUTORCC ON) -set_property(TARGET skipRccB PROPERTY AUTOUIC ON) -set_property(TARGET skipRccB PROPERTY AUTOMOC ON) -target_link_libraries(skipRccB ${QT_LIBRARIES}) - -# -- Test -# Source files with the same basename in different subdirectories -add_subdirectory(sameName) - -# -- Test -# Tests AUTOMOC with generated sources -add_subdirectory(mocDepends) - -# -- Test -# Tests various include moc patterns -add_subdirectory(mocIncludeStrict) - -# -- Test -# Tests various include moc patterns -add_subdirectory(mocIncludeRelaxed) - -# -- Test -# Tests Q_PLUGIN_METADATA json file change detection -if (NOT QT_TEST_VERSION STREQUAL 4) - try_compile(MOC_PLUGIN - "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin" - "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin" - mocPlugin - CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output - ) - if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") - endif() - - set(timeformat "%Y%j%H%M%S") - set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin") - set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin") - find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - - file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") - file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - - # Ensure that the timestamp will change and change the json files - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - - file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") - file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") - file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") - file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") - - if (plAAfter GREATER plABefore) - message(SEND_ERROR "file (${plAFile}) should not have changed!") - endif() - if (plBAfter GREATER plBBefore) - message(SEND_ERROR "file (${plBFile}) should not have changed!") - endif() - if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") - endif() - if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") - endif() - - # Test custom macro - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") - file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") - if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") - endif() - if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") - endif() - -endif() - -# -- Test -# Tests various .ui include directories -add_subdirectory(uicInclude) - -# -- Test -# Complex test case -add_subdirectory(complex) diff --git a/Tests/QtAutogen/complex/Adir/CMakeLists.txt b/Tests/QtAutogen/Complex/Adir/CMakeLists.txt index a1c36ffce..a1c36ffce 100644 --- a/Tests/QtAutogen/complex/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/Complex/Adir/CMakeLists.txt diff --git a/Tests/QtAutogen/complex/Adir/libA.cpp b/Tests/QtAutogen/Complex/Adir/libA.cpp index f79f24af4..f79f24af4 100644 --- a/Tests/QtAutogen/complex/Adir/libA.cpp +++ b/Tests/QtAutogen/Complex/Adir/libA.cpp diff --git a/Tests/QtAutogen/complex/Adir/libA.h b/Tests/QtAutogen/Complex/Adir/libA.h index c4eb9f7dc..a8ca20907 100644 --- a/Tests/QtAutogen/complex/Adir/libA.h +++ b/Tests/QtAutogen/Complex/Adir/libA.h @@ -2,10 +2,10 @@ #ifndef LIBA_H #define LIBA_H -#include "liba_export.h" - #include <QObject> +#include "liba_export.h" + class LIBA_EXPORT LibA : public QObject { Q_OBJECT diff --git a/Tests/QtAutogen/complex/Bdir/CMakeLists.txt b/Tests/QtAutogen/Complex/Bdir/CMakeLists.txt index d33876308..d33876308 100644 --- a/Tests/QtAutogen/complex/Bdir/CMakeLists.txt +++ b/Tests/QtAutogen/Complex/Bdir/CMakeLists.txt diff --git a/Tests/QtAutogen/complex/Bdir/libB.cpp b/Tests/QtAutogen/Complex/Bdir/libB.cpp index d3b675333..d3b675333 100644 --- a/Tests/QtAutogen/complex/Bdir/libB.cpp +++ b/Tests/QtAutogen/Complex/Bdir/libB.cpp diff --git a/Tests/QtAutogen/complex/Bdir/libB.h b/Tests/QtAutogen/Complex/Bdir/libB.h index e4ab788c0..38dae87cb 100644 --- a/Tests/QtAutogen/complex/Bdir/libB.h +++ b/Tests/QtAutogen/Complex/Bdir/libB.h @@ -2,10 +2,10 @@ #ifndef LIBB_H #define LIBB_H -#include "libb_export.h" +#include <QObject> #include "libA.h" -#include <QObject> +#include "libb_export.h" class LIBB_EXPORT LibB : public QObject { diff --git a/Tests/QtAutogen/complex/CMakeLists.txt b/Tests/QtAutogen/Complex/CMakeLists.txt index d48f6cc54..d9fdf5cf4 100644 --- a/Tests/QtAutogen/complex/CMakeLists.txt +++ b/Tests/QtAutogen/Complex/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.10) +project(Complex) +include("../AutogenGuiTest.cmake") # -- Test: AUTOMOC AUTORCC AUTOUIC add_definitions(-DFOO -DSomeDefine="Barx") @@ -20,7 +22,7 @@ add_custom_command( OUTPUT generated.txt COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/generated.txt" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" - ) +) add_custom_target(generate_moc_input DEPENDS generated.txt @@ -34,7 +36,8 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" ) -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_GENERATOR STREQUAL Ninja) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig AND NOT CMAKE_GENERATOR STREQUAL Ninja) set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>) endif() diff --git a/Tests/QtAutogen/complex/abc.cpp b/Tests/QtAutogen/Complex/abc.cpp index 2929b92ee..4c7dc52cb 100644 --- a/Tests/QtAutogen/complex/abc.cpp +++ b/Tests/QtAutogen/Complex/abc.cpp @@ -1,10 +1,11 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "abc.h" -#include "abc_p.h" #include <stdio.h> +#include "abc_p.h" + class PrintAbc : public QObject { Q_OBJECT diff --git a/Tests/QtAutogen/complex/abc.h b/Tests/QtAutogen/Complex/abc.h index ec5f4115a..ec5f4115a 100644 --- a/Tests/QtAutogen/complex/abc.h +++ b/Tests/QtAutogen/Complex/abc.h diff --git a/Tests/QtAutogen/complex/abc_p.h b/Tests/QtAutogen/Complex/abc_p.h index be984876c..1f6102cd0 100644 --- a/Tests/QtAutogen/complex/abc_p.h +++ b/Tests/QtAutogen/Complex/abc_p.h @@ -3,10 +3,10 @@ #ifndef ABC_P_H #define ABC_P_H -#include <QObject> - #include <stdio.h> +#include <QObject> + class AbcP : public QObject { Q_OBJECT diff --git a/Tests/QtAutogen/complex/bar.cpp b/Tests/QtAutogen/Complex/bar.cpp index 734bd7a8e..734bd7a8e 100644 --- a/Tests/QtAutogen/complex/bar.cpp +++ b/Tests/QtAutogen/Complex/bar.cpp diff --git a/Tests/QtAutogen/complex/blub.cpp b/Tests/QtAutogen/Complex/blub.cpp index 1c497e00f..1c497e00f 100644 --- a/Tests/QtAutogen/complex/blub.cpp +++ b/Tests/QtAutogen/Complex/blub.cpp diff --git a/Tests/QtAutogen/complex/blub.h b/Tests/QtAutogen/Complex/blub.h index ff798782b..ff798782b 100644 --- a/Tests/QtAutogen/complex/blub.h +++ b/Tests/QtAutogen/Complex/blub.h diff --git a/Tests/QtAutogen/complex/calwidget.cpp b/Tests/QtAutogen/Complex/calwidget.cpp index 380e98238..f58b18247 100644 --- a/Tests/QtAutogen/complex/calwidget.cpp +++ b/Tests/QtAutogen/Complex/calwidget.cpp @@ -38,6 +38,8 @@ ** ****************************************************************************/ +#include "calwidget.h" + #include <QCalendarWidget> #include <QCheckBox> #include <QComboBox> @@ -47,11 +49,9 @@ #include <QLabel> #include <QTextCharFormat> -#include "calwidget.h" - #include "ui_calwidget.h" #ifdef UI_CALWIDGET_H -#error Definition of UI_CALWIDGET_H should be disabled by file option. +# error Definition of UI_CALWIDGET_H should be disabled by file option. #endif Window::Window() diff --git a/Tests/QtAutogen/complex/calwidget.h b/Tests/QtAutogen/Complex/calwidget.h index 084d959bd..084d959bd 100644 --- a/Tests/QtAutogen/complex/calwidget.h +++ b/Tests/QtAutogen/Complex/calwidget.h diff --git a/Tests/QtAutogen/complex/calwidget.ui b/Tests/QtAutogen/Complex/calwidget.ui index 1c245cac9..1c245cac9 100644 --- a/Tests/QtAutogen/complex/calwidget.ui +++ b/Tests/QtAutogen/Complex/calwidget.ui diff --git a/Tests/QtAutogen/complex/codeeditor.cpp b/Tests/QtAutogen/Complex/codeeditor.cpp index 0caf8a7df..bb6f405ad 100644 --- a/Tests/QtAutogen/complex/codeeditor.cpp +++ b/Tests/QtAutogen/Complex/codeeditor.cpp @@ -38,10 +38,10 @@ ** ****************************************************************************/ -#include <QtGui> - #include "codeeditor.h" +#include <QtGui> + CodeEditor::CodeEditor(QWidget* parent) : QPlainTextEdit(parent) { diff --git a/Tests/QtAutogen/complex/codeeditor.h b/Tests/QtAutogen/Complex/codeeditor.h index b410bd4e6..b410bd4e6 100644 --- a/Tests/QtAutogen/complex/codeeditor.h +++ b/Tests/QtAutogen/Complex/codeeditor.h diff --git a/Tests/QtAutogen/complex/debug_class.cpp b/Tests/QtAutogen/Complex/debug_class.cpp index 46b09e705..3aaf79a08 100644 --- a/Tests/QtAutogen/complex/debug_class.cpp +++ b/Tests/QtAutogen/Complex/debug_class.cpp @@ -1,5 +1,6 @@ #include "debug_class.h" + #include "ui_debug_class.h" DebugClass::DebugClass(QWidget* parent) diff --git a/Tests/QtAutogen/complex/debug_class.h b/Tests/QtAutogen/Complex/debug_class.h index c02f0ede6..c02f0ede6 100644 --- a/Tests/QtAutogen/complex/debug_class.h +++ b/Tests/QtAutogen/Complex/debug_class.h diff --git a/Tests/QtAutogen/complex/debug_class.ui b/Tests/QtAutogen/Complex/debug_class.ui index dc2e1ac18..dc2e1ac18 100644 --- a/Tests/QtAutogen/complex/debug_class.ui +++ b/Tests/QtAutogen/Complex/debug_class.ui diff --git a/Tests/QtAutogen/complex/debug_resource.qrc b/Tests/QtAutogen/Complex/debug_resource.qrc index db98b9bc1..db98b9bc1 100644 --- a/Tests/QtAutogen/complex/debug_resource.qrc +++ b/Tests/QtAutogen/Complex/debug_resource.qrc diff --git a/Tests/QtAutogen/complex/foo.cpp b/Tests/QtAutogen/Complex/foo.cpp index f665eee01..f665eee01 100644 --- a/Tests/QtAutogen/complex/foo.cpp +++ b/Tests/QtAutogen/Complex/foo.cpp diff --git a/Tests/QtAutogen/complex/foo.h b/Tests/QtAutogen/Complex/foo.h index 3e03fe6bd..3e03fe6bd 100644 --- a/Tests/QtAutogen/complex/foo.h +++ b/Tests/QtAutogen/Complex/foo.h diff --git a/Tests/QtAutogen/complex/gadget.cpp b/Tests/QtAutogen/Complex/gadget.cpp index 23d95fa4a..23d95fa4a 100644 --- a/Tests/QtAutogen/complex/gadget.cpp +++ b/Tests/QtAutogen/Complex/gadget.cpp diff --git a/Tests/QtAutogen/complex/gadget.h b/Tests/QtAutogen/Complex/gadget.h index 3253e31d9..3253e31d9 100644 --- a/Tests/QtAutogen/complex/gadget.h +++ b/Tests/QtAutogen/Complex/gadget.h diff --git a/Tests/QtAutogen/complex/generated.cpp b/Tests/QtAutogen/Complex/generated.cpp index d514c619c..d514c619c 100644 --- a/Tests/QtAutogen/complex/generated.cpp +++ b/Tests/QtAutogen/Complex/generated.cpp diff --git a/Tests/QtAutogen/complex/generated.h b/Tests/QtAutogen/Complex/generated.h index 62e1607bf..cac14dedb 100644 --- a/Tests/QtAutogen/complex/generated.h +++ b/Tests/QtAutogen/Complex/generated.h @@ -7,7 +7,10 @@ #include "myinterface.h" #include "myotherinterface.h" -class Generated : public QObject, MyInterface, MyOtherInterface +class Generated + : public QObject + , MyInterface + , MyOtherInterface { Q_OBJECT Q_INTERFACES(MyInterface MyOtherInterface) diff --git a/Tests/QtAutogen/complex/generated.txt.in b/Tests/QtAutogen/Complex/generated.txt.in index 77507bb8e..77507bb8e 100644 --- a/Tests/QtAutogen/complex/generated.txt.in +++ b/Tests/QtAutogen/Complex/generated.txt.in diff --git a/Tests/QtAutogen/complex/generated_resource.qrc.in b/Tests/QtAutogen/Complex/generated_resource.qrc.in index da5fa6289..da5fa6289 100644 --- a/Tests/QtAutogen/complex/generated_resource.qrc.in +++ b/Tests/QtAutogen/Complex/generated_resource.qrc.in diff --git a/Tests/QtAutogen/complex/libC.cpp b/Tests/QtAutogen/Complex/libC.cpp index a3acff161..a3acff161 100644 --- a/Tests/QtAutogen/complex/libC.cpp +++ b/Tests/QtAutogen/Complex/libC.cpp diff --git a/Tests/QtAutogen/complex/libC.h b/Tests/QtAutogen/Complex/libC.h index 3bc2bad54..51ea48d9e 100644 --- a/Tests/QtAutogen/complex/libC.h +++ b/Tests/QtAutogen/Complex/libC.h @@ -2,10 +2,10 @@ #ifndef LIBC_H #define LIBC_H -#include "libc_export.h" +#include <QObject> #include "libB.h" -#include <QObject> +#include "libc_export.h" class LIBC_EXPORT LibC : public QObject { diff --git a/Tests/QtAutogen/complex/main.cpp b/Tests/QtAutogen/Complex/main.cpp index d557c70b3..12f649f03 100644 --- a/Tests/QtAutogen/complex/main.cpp +++ b/Tests/QtAutogen/Complex/main.cpp @@ -52,8 +52,9 @@ #include "xyz.h" #include "yaf.h" #ifdef TEST_DEBUG_CLASS -#include "debug_class.h" -#include <iostream> +# include <iostream> + +# include "debug_class.h" #endif int main(int argv, char** args) diff --git a/Tests/QtAutogen/complex/multiplewidgets.cpp b/Tests/QtAutogen/Complex/multiplewidgets.cpp index fda36ea92..fda36ea92 100644 --- a/Tests/QtAutogen/complex/multiplewidgets.cpp +++ b/Tests/QtAutogen/Complex/multiplewidgets.cpp diff --git a/Tests/QtAutogen/complex/multiplewidgets.h b/Tests/QtAutogen/Complex/multiplewidgets.h index a4d0a5021..a4d0a5021 100644 --- a/Tests/QtAutogen/complex/multiplewidgets.h +++ b/Tests/QtAutogen/Complex/multiplewidgets.h diff --git a/Tests/QtAutogen/complex/myinterface.h.in b/Tests/QtAutogen/Complex/myinterface.h.in index c6c0ba1b6..c6c0ba1b6 100644 --- a/Tests/QtAutogen/complex/myinterface.h.in +++ b/Tests/QtAutogen/Complex/myinterface.h.in diff --git a/Tests/QtAutogen/complex/myotherinterface.h.in b/Tests/QtAutogen/Complex/myotherinterface.h.in index d21e7af7c..d21e7af7c 100644 --- a/Tests/QtAutogen/complex/myotherinterface.h.in +++ b/Tests/QtAutogen/Complex/myotherinterface.h.in diff --git a/Tests/QtAutogen/complex/private_slot.cpp b/Tests/QtAutogen/Complex/private_slot.cpp index ab1682a25..ab1682a25 100644 --- a/Tests/QtAutogen/complex/private_slot.cpp +++ b/Tests/QtAutogen/Complex/private_slot.cpp diff --git a/Tests/QtAutogen/complex/private_slot.h b/Tests/QtAutogen/Complex/private_slot.h index 8041eb2ae..8041eb2ae 100644 --- a/Tests/QtAutogen/complex/private_slot.h +++ b/Tests/QtAutogen/Complex/private_slot.h diff --git a/Tests/QtAutogen/complex/resourcetester.cpp b/Tests/QtAutogen/Complex/resourcetester.cpp index 4ecb6b482..4ecb6b482 100644 --- a/Tests/QtAutogen/complex/resourcetester.cpp +++ b/Tests/QtAutogen/Complex/resourcetester.cpp diff --git a/Tests/QtAutogen/complex/resourcetester.h b/Tests/QtAutogen/Complex/resourcetester.h index dbdb3ad72..dbdb3ad72 100644 --- a/Tests/QtAutogen/complex/resourcetester.h +++ b/Tests/QtAutogen/Complex/resourcetester.h diff --git a/Tests/QtAutogen/complex/second_resource.qrc b/Tests/QtAutogen/Complex/second_resource.qrc index 27bfb143b..27bfb143b 100644 --- a/Tests/QtAutogen/complex/second_resource.qrc +++ b/Tests/QtAutogen/Complex/second_resource.qrc diff --git a/Tests/QtAutogen/complex/second_widget.cpp b/Tests/QtAutogen/Complex/second_widget.cpp index c575f1013..9f51a80cd 100644 --- a/Tests/QtAutogen/complex/second_widget.cpp +++ b/Tests/QtAutogen/Complex/second_widget.cpp @@ -1,5 +1,6 @@ #include "second_widget.h" + #include "ui_second_widget.h" SecondWidget::SecondWidget(QWidget* parent) diff --git a/Tests/QtAutogen/complex/second_widget.h b/Tests/QtAutogen/Complex/second_widget.h index c7929c4b1..c7929c4b1 100644 --- a/Tests/QtAutogen/complex/second_widget.h +++ b/Tests/QtAutogen/Complex/second_widget.h diff --git a/Tests/QtAutogen/complex/second_widget.ui b/Tests/QtAutogen/Complex/second_widget.ui index 4effa589c..4effa589c 100644 --- a/Tests/QtAutogen/complex/second_widget.ui +++ b/Tests/QtAutogen/Complex/second_widget.ui diff --git a/Tests/QtAutogen/complex/sub/bar.h b/Tests/QtAutogen/Complex/sub/bar.h index e4093f61c..e4093f61c 100644 --- a/Tests/QtAutogen/complex/sub/bar.h +++ b/Tests/QtAutogen/Complex/sub/bar.h diff --git a/Tests/QtAutogen/complex/targetObjectsTest.cpp b/Tests/QtAutogen/Complex/targetObjectsTest.cpp index 766b7751b..766b7751b 100644 --- a/Tests/QtAutogen/complex/targetObjectsTest.cpp +++ b/Tests/QtAutogen/Complex/targetObjectsTest.cpp diff --git a/Tests/QtAutogen/complex/test.qrc b/Tests/QtAutogen/Complex/test.qrc index c3d4e3cdb..c3d4e3cdb 100644 --- a/Tests/QtAutogen/complex/test.qrc +++ b/Tests/QtAutogen/Complex/test.qrc diff --git a/Tests/QtAutogen/complex/widget1.ui b/Tests/QtAutogen/Complex/widget1.ui index 8fce81a9a..8fce81a9a 100644 --- a/Tests/QtAutogen/complex/widget1.ui +++ b/Tests/QtAutogen/Complex/widget1.ui diff --git a/Tests/QtAutogen/complex/widget2.ui b/Tests/QtAutogen/Complex/widget2.ui index 1f411b9fb..1f411b9fb 100644 --- a/Tests/QtAutogen/complex/widget2.ui +++ b/Tests/QtAutogen/Complex/widget2.ui diff --git a/Tests/QtAutogen/complex/xyz.cpp b/Tests/QtAutogen/Complex/xyz.cpp index e46c9d3ed..e46c9d3ed 100644 --- a/Tests/QtAutogen/complex/xyz.cpp +++ b/Tests/QtAutogen/Complex/xyz.cpp diff --git a/Tests/QtAutogen/complex/xyz.h b/Tests/QtAutogen/Complex/xyz.h index 8b813fd3a..8b813fd3a 100644 --- a/Tests/QtAutogen/complex/xyz.h +++ b/Tests/QtAutogen/Complex/xyz.h diff --git a/Tests/QtAutogen/complex/yaf.cpp b/Tests/QtAutogen/Complex/yaf.cpp index 70e26aa95..10448c1bc 100644 --- a/Tests/QtAutogen/complex/yaf.cpp +++ b/Tests/QtAutogen/Complex/yaf.cpp @@ -1,10 +1,11 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "yaf.h" -#include "yaf_p.h" #include <stdio.h> +#include "yaf_p.h" + Yaf::Yaf() { } diff --git a/Tests/QtAutogen/complex/yaf.h b/Tests/QtAutogen/Complex/yaf.h index f27106199..f27106199 100644 --- a/Tests/QtAutogen/complex/yaf.h +++ b/Tests/QtAutogen/Complex/yaf.h diff --git a/Tests/QtAutogen/complex/yaf_p.h b/Tests/QtAutogen/Complex/yaf_p.h index ea5eed69c..48fdd301c 100644 --- a/Tests/QtAutogen/complex/yaf_p.h +++ b/Tests/QtAutogen/Complex/yaf_p.h @@ -3,10 +3,10 @@ #ifndef YAF_P_H #define YAF_P_H -#include <QObject> - #include <stdio.h> +#include <QObject> + class YafP : public QObject { Q_OBJECT diff --git a/Tests/QtAutogen/DefinesTest/CMakeLists.txt b/Tests/QtAutogen/DefinesTest/CMakeLists.txt new file mode 100644 index 000000000..3761dd842 --- /dev/null +++ b/Tests/QtAutogen/DefinesTest/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.10) +project(DefinesTest) + +# Qt4 only definitions test +if(NOT QT_TEST_VERSION EQUAL 4) + message(ERROR "Invalid Qt test version. This test is for Qt4 only.") +endif() + +find_package(Qt4 REQUIRED) + +add_executable(DefinesTest defines_test.cpp) +set_target_properties(DefinesTest PROPERTIES AUTOMOC TRUE) +target_link_libraries(DefinesTest Qt4::QtGui) diff --git a/Tests/QtAutogen/defines_test/defines_test.cpp b/Tests/QtAutogen/DefinesTest/defines_test.cpp index cf4e9cb5b..a5336221d 100644 --- a/Tests/QtAutogen/defines_test/defines_test.cpp +++ b/Tests/QtAutogen/DefinesTest/defines_test.cpp @@ -2,7 +2,7 @@ #include <QObject> #ifdef QT_GUI_LIB -#include <QTextDocument> +# include <QTextDocument> class SomeDocument : public QTextDocument { diff --git a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt new file mode 100644 index 000000000..81fd8db27 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt @@ -0,0 +1,126 @@ +cmake_minimum_required(VERSION 3.12) +project(GlobalAutogenTarget) +include("../AutogenCoreTest.cmake") + +# This tests +# CMAKE_GLOBAL_AUTOGEN_TARGET, +# CMAKE_GLOBAL_AUTORCC_TARGET, +# CMAKE_GLOBAL_AUTOGEN_TARGET_NAME and +# CMAKE_GLOBAL_AUTORCC_TARGET_NAME +# for the latter two with different values in different subdirectories. + +# Directories +set(GAT_SDIR "${CMAKE_CURRENT_SOURCE_DIR}/GAT") +set(GAT_BDIR "${CMAKE_CURRENT_BINARY_DIR}/GAT") +# Files +set(MCA "sda/sda_autogen/mocs_compilation.cpp") +set(MCB "sdb/sdb_autogen/mocs_compilation.cpp") +set(MCC "sdc/sdc_autogen/mocs_compilation.cpp") +set(MCG "gat_autogen/mocs_compilation.cpp") + +set(DRA "sda/sda_autogen/*qrc_data.cpp") +set(DRB "sdb/sdb_autogen/*qrc_data.cpp") +set(DRC "sdc/sdc_autogen/*qrc_data.cpp") +set(DRG "gat_autogen/*qrc_data.cpp") + +# -- Utility macros +macro(GAT_FIND_FILES VAR NAME) + file(GLOB_RECURSE ${VAR} ${GAT_BDIR}/*${NAME}) +endmacro() + +macro(GAT_FIND_FILE NAME) + GAT_FIND_FILES(LST ${NAME}) + if(LST) + message("Good find ${LST}") + else() + message(SEND_ERROR "Expected to find ${GAT_BDIR}/${NAME}") + endif() + unset(LST) +endmacro() + +macro(GAT_FIND_FILE_NOT NAME) + GAT_FIND_FILES(LST ${NAME}) + if(LST) + message(SEND_ERROR "Not expected to find ${GAT_BDIR}/${NAME}") + else() + message("Good not find ${GAT_BDIR}/${NAME}") + endif() + unset(LST) +endmacro() + +macro(GAT_BUILD_TARGET NAME) + message("___ Building GAT ${NAME} target ___") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build "${GAT_BDIR}" --target ${NAME} + WORKING_DIRECTORY "${GAT_BDIR}" + RESULT_VARIABLE result) + if (result) + message(SEND_ERROR "Building of GAT ${NAME} target failed") + endif() +endmacro() + + +# -- Remove and recreate build directory +file(REMOVE_RECURSE ${GAT_BDIR}) +file(MAKE_DIRECTORY ${GAT_BDIR}) + + +# -- Configure project +message("___ Configuring GAT project ___") +execute_process( + COMMAND "${CMAKE_COMMAND}" "${GAT_SDIR}" + -G "${CMAKE_GENERATOR}" + -A "${CMAKE_GENERATOR_PLATFORM}" + -T "${CMAKE_GENERATOR_TOOLSET}" + "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + WORKING_DIRECTORY "${GAT_BDIR}" + OUTPUT_VARIABLE output + RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Configuring of GAT project failed") +else() + message("Configuring of GAT project succeeded") + message("${output}") +endif() + + +# -- Build autogen subtargets +GAT_BUILD_TARGET("autogen") +GAT_FIND_FILE("${MCA}") +GAT_FIND_FILE_NOT("${MCB}") +GAT_FIND_FILE_NOT("${MCC}") +GAT_FIND_FILE("${MCG}") + +GAT_BUILD_TARGET("global_autogen_sdb") +GAT_FIND_FILE("${MCA}") +GAT_FIND_FILE("${MCB}") +GAT_FIND_FILE_NOT("${MCC}") +GAT_FIND_FILE("${MCG}") + +GAT_BUILD_TARGET("all_autogen") +GAT_FIND_FILE("${MCA}") +GAT_FIND_FILE("${MCB}") +GAT_FIND_FILE("${MCC}") +GAT_FIND_FILE("${MCG}") + + +# -- Build autorcc subtargets +GAT_BUILD_TARGET("autorcc") +GAT_FIND_FILE("${DRA}") +GAT_FIND_FILE_NOT("${DRB}") +GAT_FIND_FILE_NOT("${DRC}") +GAT_FIND_FILE("${DRG}") + +GAT_BUILD_TARGET("global_autorcc_sdb") +GAT_FIND_FILE("${DRA}") +GAT_FIND_FILE("${DRB}") +GAT_FIND_FILE_NOT("${DRC}") +GAT_FIND_FILE("${DRG}") + +GAT_BUILD_TARGET("all_autorcc") +GAT_FIND_FILE("${DRA}") +GAT_FIND_FILE("${DRB}") +GAT_FIND_FILE("${DRC}") +GAT_FIND_FILE("${DRG}") diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt new file mode 100644 index 000000000..3925197fe --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.12) +project(GAT) +include("../../AutogenCoreTest.cmake") + +# Include directories +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +# Enable AUTOMOC/UIC/RCC +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +# Disable ORIGN_DEPENDS and enable AUTOGEN global targets +set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF) +set(CMAKE_GLOBAL_AUTOGEN_TARGET ON) +set(CMAKE_GLOBAL_AUTORCC_TARGET ON) + +add_subdirectory(sda) +add_subdirectory(sdb) +add_subdirectory(sdc) + +# Add custom target that depends on all autogen/autorcc targets +add_custom_target(all_autogen DEPENDS autogen global_autogen_sdb global_autogen_sdc) +add_custom_target(all_autorcc DEPENDS autorcc global_autorcc_sdb global_autorcc_sdc) + +# Main target +add_executable(gat data.qrc item.cpp main.cpp) +target_link_libraries(gat ${QT_LIBRARIES}) +target_link_libraries(gat sda sdb sdc) diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc b/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc new file mode 100644 index 000000000..68d02c9eb --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp new file mode 100644 index 000000000..3d1fbe7cf --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp @@ -0,0 +1,20 @@ +#include "item.hpp" +// Include ui_view.h in source and header +#include <ui_view.h> + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_View ui; + MocLocal obj; +} + +#include "item.moc" diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp new file mode 100644 index 000000000..75e83f483 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp @@ -0,0 +1,15 @@ +#ifndef ITEM_HPP +#define ITEM_HPP + +#include <QObject> +// Include ui_view.h in source and header +#include <ui_view.h> + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp new file mode 100644 index 000000000..79c00b407 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp @@ -0,0 +1,15 @@ +#include "item.hpp" +#include "sda/sda.hpp" +#include "sdb/sdb.hpp" +#include "sdc/sdc.hpp" + +int main(int argv, char** args) +{ + // Object instances + Item item; + // Library calls + sda(); + sdb(); + sdc(); + return 0; +} diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt new file mode 100644 index 000000000..795e91e97 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(sda ../item.cpp ../data.qrc sda.cpp) +target_link_libraries(sda ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp new file mode 100644 index 000000000..ec4dec88a --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp @@ -0,0 +1,6 @@ +#include <item.hpp> + +void sda() +{ + Item item; +} diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp new file mode 100644 index 000000000..89ac744b3 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp @@ -0,0 +1,6 @@ +#ifndef SDA_HPP +#define SDA_HPP + +void sda(); + +#endif diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt new file mode 100644 index 000000000..5c686fec4 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt @@ -0,0 +1,5 @@ +set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdb") +set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdb") + +add_library(sdb ../item.cpp ../data.qrc sdb.cpp) +target_link_libraries(sdb ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp new file mode 100644 index 000000000..e32c46709 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp @@ -0,0 +1,6 @@ +#include <item.hpp> + +void sdb() +{ + Item item; +} diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp new file mode 100644 index 000000000..a5b0f62f9 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp @@ -0,0 +1,6 @@ +#ifndef SDB_HPP +#define SDB_HPP + +void sdb(); + +#endif diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt new file mode 100644 index 000000000..2698bda6b --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt @@ -0,0 +1,5 @@ +set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdc") +set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdc") + +add_library(sdc ../item.cpp ../data.qrc sdc.cpp) +target_link_libraries(sdc ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp new file mode 100644 index 000000000..a97cd4276 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp @@ -0,0 +1,6 @@ +#include <item.hpp> + +void sdc() +{ + Item item; +} diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp new file mode 100644 index 000000000..7e9217902 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp @@ -0,0 +1,6 @@ +#ifndef SDC_HPP +#define SDC_HPP + +void sdc(); + +#endif diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui b/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui new file mode 100644 index 000000000..2ffe7344c --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt b/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt new file mode 100644 index 000000000..e1af3d863 --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt @@ -0,0 +1,16 @@ +# Use a low minimum version +cmake_minimum_required(VERSION 3.0) +project(LowMinimumVersion) +include("../AutogenGuiTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +add_executable(lowMinimumVersion + main.cpp + item.hpp + item.cpp + view.ui + someText.txt + example.qrc) +target_link_libraries(lowMinimumVersion ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/LowMinimumVersion/example.qrc b/Tests/QtAutogen/LowMinimumVersion/example.qrc new file mode 100644 index 000000000..551ecc815 --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/example.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="Example"> + <file>someText.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/LowMinimumVersion/item.cpp b/Tests/QtAutogen/LowMinimumVersion/item.cpp new file mode 100644 index 000000000..511a1caa8 --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/item.cpp @@ -0,0 +1,20 @@ +#include "item.hpp" + +#include <ui_view.h> + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_View ui; + MocLocal obj; +} + +#include "item.moc" diff --git a/Tests/QtAutogen/sameName/item.hpp b/Tests/QtAutogen/LowMinimumVersion/item.hpp index 91bba3b4d..01255d480 100644 --- a/Tests/QtAutogen/sameName/item.hpp +++ b/Tests/QtAutogen/LowMinimumVersion/item.hpp @@ -6,6 +6,8 @@ class Item : public QObject { Q_OBJECT + +public: Q_SLOT void go(); }; diff --git a/Tests/QtAutogen/LowMinimumVersion/main.cpp b/Tests/QtAutogen/LowMinimumVersion/main.cpp new file mode 100644 index 000000000..9f225a4aa --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/main.cpp @@ -0,0 +1,10 @@ +#include "item.hpp" + +int main(int argc, char* argv[]) +{ + Q_INIT_RESOURCE(example); + Item item; + item.go(); + + return 0; +} diff --git a/Tests/QtAutogen/LowMinimumVersion/someText.txt b/Tests/QtAutogen/LowMinimumVersion/someText.txt new file mode 100644 index 000000000..750dae3a1 --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/someText.txt @@ -0,0 +1 @@ +Hello world, you're an interesting place. diff --git a/Tests/QtAutogen/LowMinimumVersion/view.ui b/Tests/QtAutogen/LowMinimumVersion/view.ui new file mode 100644 index 000000000..2ffe7344c --- /dev/null +++ b/Tests/QtAutogen/LowMinimumVersion/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/MacOsFW/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/CMakeLists.txt new file mode 100644 index 000000000..c08efc47a --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.10) +project(MacOsFW) +include("../AutogenGuiTest.cmake") + +find_package(Qt5Test REQUIRED) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) +set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib) + +if(POLICY CMP0042) # in CMake 3.0.0+ + set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default +endif(POLICY CMP0042) + +if(POLICY CMP0068) # in CMake 3.9+ + cmake_policy(SET CMP0068 NEW) +endif(POLICY CMP0068) + +add_subdirectory(src) +add_subdirectory(test) diff --git a/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt new file mode 100644 index 000000000..a02be00c5 --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt @@ -0,0 +1,33 @@ +set(MACOS_FW_LIB_VERSION "0.1") +set(MACOS_FW_LIB_SRCS + macos_fw_lib.cpp +) +set(MACOS_FW_LIB_HDRS + macos_fw_lib.h +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${Qt5Core_INCLUDE_DIRS} +) + +add_library(macos_fw_lib SHARED + ${MACOS_FW_LIB_SRCS} + ${MACOS_FW_LIB_HDRS} +) +set_target_properties(macos_fw_lib PROPERTIES AUTOMOC TRUE) +set_target_properties(macos_fw_lib PROPERTIES + CLEAN_DIRECT_OUTPUT 1 + FRAMEWORK 1 + FRAMEWORK_VERSION ${MACOS_FW_LIB_VERSION} + VERSION ${MACOS_FW_LIB_VERSION} + SOVERSION ${MACOS_FW_LIB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MACOS_FW_LIB_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.macos.fw_lib + POSITION_INDEPENDENT_CODE ON + PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}" +) +target_link_libraries(macos_fw_lib + Qt5::Core +) diff --git a/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp new file mode 100644 index 000000000..881a8c9b6 --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp @@ -0,0 +1,17 @@ +#include "macos_fw_lib.h" + +#include <QString> +#include <QtGlobal> + +MacosFWLib::MacosFWLib() +{ +} + +MacosFWLib::~MacosFWLib() +{ +} + +QString MacosFWLib::qtVersionString() const +{ + return QString(qVersion()); +} diff --git a/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h new file mode 100644 index 000000000..e66e0ea6c --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h @@ -0,0 +1,18 @@ +#ifndef MACOSFWLIB_H +#define MACOSFWLIB_H + +#include <QObject> +#include <QString> + +class __attribute__((visibility("default"))) MacosFWLib : public QObject +{ + Q_OBJECT + +public: + explicit MacosFWLib(); + ~MacosFWLib(); + + QString qtVersionString() const; +}; + +#endif // MACOSFWLIB_H diff --git a/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt new file mode 100644 index 000000000..521c18450 --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt @@ -0,0 +1,19 @@ +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../src +) +include_directories(SYSTEM + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} +) + +set(testname AutomocMacosFWLib) +add_executable(${testname} testMacosFWLib.cpp) +set_target_properties(${testname} PROPERTIES AUTOMOC TRUE) +target_link_libraries(${testname} + Qt5::Core + Qt5::Widgets + Qt5::Test + macos_fw_lib +) diff --git a/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp new file mode 100644 index 000000000..edc93764a --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp @@ -0,0 +1,43 @@ +#include "testMacosFWLib.h" + +#include <QObject> +#include <QString> + +#include "macos_fw_lib.h" + +class TestMacosFWLib : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + void init() {} + void cleanup() {} + + void testQtVersion(); +}; + +void TestMacosFWLib::initTestCase() +{ +} + +void TestMacosFWLib::cleanupTestCase() +{ +} + +void TestMacosFWLib::testQtVersion() +{ + MacosFWLib* testLib = new MacosFWLib(); + QVERIFY(testLib->qtVersionString().contains("5.")); + testLib->deleteLater(); +} + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv, false); + MacosFWLib testObject; + return QTest::qExec(&testObject, argc, argv); +} + +#include "testMacosFWLib.moc" diff --git a/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h new file mode 100644 index 000000000..1fe8dae65 --- /dev/null +++ b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h @@ -0,0 +1,7 @@ +#ifndef TESTMACOSFWLIB_H +#define TESTMACOSFWLIB_H + +#include "qapplication.h" +#include <QtTest/QtTest> + +#endif // TESTMACOSFWLIB_H diff --git a/Tests/QtAutogen/ManySources/CMakeLists.txt b/Tests/QtAutogen/ManySources/CMakeLists.txt new file mode 100644 index 000000000..df8a2a662 --- /dev/null +++ b/Tests/QtAutogen/ManySources/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.10) +project(ManySources) +include("../AutogenGuiTest.cmake") + +# Test AUTOMOC and AUTOUIC on many source files to stress the concurrent +# parsing and processing framework. + +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) + +set(SRCS main.cpp) +set(MAIN_INCLUDES "\n// Item includes\n") +set(MAIN_ITEMS "\n// Items\n") + +set(NUM 24) +foreach(III RANGE 1 ${NUM}) + configure_file(${CSD}/object.h.in ${CBD}/object_${III}.h) + configure_file(${CSD}/item.h.in ${CBD}/item_${III}.h) + configure_file(${CSD}/item.cpp.in ${CBD}/item_${III}.cpp) + configure_file(${CSD}/view.ui.in ${CBD}/view_${III}.ui) + configure_file(${CSD}/data.qrc.in ${CBD}/data_${III}.qrc) + + list(APPEND SRCS ${CBD}/item_${III}.cpp) + list(APPEND SRCS ${CBD}/data_${III}.qrc) + + string(APPEND MAIN_INCLUDES "#include \"item_${III}.h\"\n") + string(APPEND MAIN_ITEMS "Item_${III} item_${III};\n") + string(APPEND MAIN_ITEMS "item_${III}.TheSlot();\n") +endforeach() + +configure_file(${CSD}/main.cpp.in ${CBD}/main.cpp) + +add_executable(manySources ${SRCS} ${CBD}/main.cpp) +target_link_libraries(manySources ${QT_LIBRARIES}) +set_target_properties(manySources PROPERTIES AUTOMOC 1 AUTOUIC 1 AUTORCC 1) diff --git a/Tests/QtAutogen/ManySources/data.qrc.in b/Tests/QtAutogen/ManySources/data.qrc.in new file mode 100644 index 000000000..870d48631 --- /dev/null +++ b/Tests/QtAutogen/ManySources/data.qrc.in @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>object_@III@.h</file> + <file>item_@III@.h</file> + <file>item_@III@.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/ManySources/item.cpp.in b/Tests/QtAutogen/ManySources/item.cpp.in new file mode 100644 index 000000000..c34ad16d0 --- /dev/null +++ b/Tests/QtAutogen/ManySources/item.cpp.in @@ -0,0 +1,27 @@ +#include "item_@III@.h" +#include "object_@III@.h" +// AUTOUIC include +#include <ui_view_@III@.h> + +class LocalObject_@III@ : public QObject +{ + Q_OBJECT; + +public: + LocalObject_@III@() = default; + ~LocalObject_@III@() = default; +}; + +void Item_@III@ ::TheSlot() +{ + LocalObject_@III@ localObject; + Object_@III@ obj; + obj.ObjectSlot(); + + Ui_View_@III@ ui_view; +} + +// AUTOMOC includes +#include "item_@III@.moc" +#include "moc_item_@III@.cpp" +#include "moc_object_@III@.cpp" diff --git a/Tests/QtAutogen/ManySources/item.h.in b/Tests/QtAutogen/ManySources/item.h.in new file mode 100644 index 000000000..67ad79435 --- /dev/null +++ b/Tests/QtAutogen/ManySources/item.h.in @@ -0,0 +1,15 @@ +#ifndef ITEM_@III@HPP +#define ITEM_@III@HPP + +#include <QObject> + +class Item_@III@ : public QObject +{ + Q_OBJECT + +public: + Q_SLOT + void TheSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/ManySources/main.cpp.in b/Tests/QtAutogen/ManySources/main.cpp.in new file mode 100644 index 000000000..e1dda40b7 --- /dev/null +++ b/Tests/QtAutogen/ManySources/main.cpp.in @@ -0,0 +1,7 @@ +@MAIN_INCLUDES@ + +int main(int argv, char** args) +{ + @MAIN_ITEMS@ + return 0; +} diff --git a/Tests/QtAutogen/ManySources/object.h.in b/Tests/QtAutogen/ManySources/object.h.in new file mode 100644 index 000000000..a747cbcfa --- /dev/null +++ b/Tests/QtAutogen/ManySources/object.h.in @@ -0,0 +1,15 @@ +#ifndef OBJECT_@III@H +#define OBJECT_@III@H + +#include <QObject> + +class Object_@III@ : public QObject +{ + Q_OBJECT + +public: + Q_SLOT + void ObjectSlot(){}; +}; + +#endif diff --git a/Tests/QtAutogen/ManySources/view.ui.in b/Tests/QtAutogen/ManySources/view.ui.in new file mode 100644 index 000000000..6901fe3de --- /dev/null +++ b/Tests/QtAutogen/ManySources/view.ui.in @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View_@III@</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/MocCMP0071/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt new file mode 100644 index 000000000..5c58a8278 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.10) +project(MocCMP0071) +include("../AutogenCoreTest.cmake") + +add_subdirectory(OLD) +add_subdirectory(NEW) diff --git a/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt new file mode 100644 index 000000000..954fe3dc1 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +cmake_policy(SET CMP0071 NEW) + +# *Generate* files +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_command( + OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp) + +add_executable(mocCMP0071New ${CBD}/Obj.cpp ${CBD}/main.cpp) +target_link_libraries(mocCMP0071New ${QT_LIBRARIES}) +set_target_properties(mocCMP0071New PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt new file mode 100644 index 000000000..68fa06708 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.10) +cmake_policy(SET CMP0071 OLD) + +# *Generate* files +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_command( + OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp) + +# Generate moc files externally +qtx_wrap_cpp(mocCMP0071OldMoc ${CBD}/Obj.hpp ${CBD}/Obj_p.h) +add_executable(mocCMP0071Old ${CBD}/Obj.cpp ${CBD}/main.cpp ${mocCMP0071OldMoc}) +target_link_libraries(mocCMP0071Old ${QT_LIBRARIES}) +set_target_properties(mocCMP0071Old PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/MocCMP0071/Obj.cpp b/Tests/QtAutogen/MocCMP0071/Obj.cpp new file mode 100644 index 000000000..25a291d31 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/Obj.cpp @@ -0,0 +1,21 @@ +#include "Obj.hpp" + +#include "Obj_p.h" + +ObjPrivate::ObjPrivate() +{ +} + +ObjPrivate::~ObjPrivate() +{ +} + +Obj::Obj() + : d(new ObjPrivate) +{ +} + +Obj::~Obj() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocCMP0071/Obj.hpp b/Tests/QtAutogen/MocCMP0071/Obj.hpp new file mode 100644 index 000000000..f064e4793 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/Obj.hpp @@ -0,0 +1,19 @@ +#ifndef OBJ_HPP +#define OBJ_HPP + +#include <QObject> + +// Object source comes without any _moc/.moc includes +class ObjPrivate; +class Obj : public QObject +{ + Q_OBJECT +public: + Obj(); + ~Obj(); + +private: + ObjPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0071/Obj_p.h b/Tests/QtAutogen/MocCMP0071/Obj_p.h new file mode 100644 index 000000000..cb1e5df71 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/Obj_p.h @@ -0,0 +1,14 @@ +#ifndef OBJ_P_HPP +#define OBJ_P_HPP + +#include <QObject> + +class ObjPrivate : public QObject +{ + Q_OBJECT +public: + ObjPrivate(); + ~ObjPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0071/main.cpp b/Tests/QtAutogen/MocCMP0071/main.cpp new file mode 100644 index 000000000..3887840ba --- /dev/null +++ b/Tests/QtAutogen/MocCMP0071/main.cpp @@ -0,0 +1,7 @@ +#include "Obj.hpp" + +int main(int argv, char** args) +{ + Obj obj; + return 0; +} diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt new file mode 100644 index 000000000..04c8bafb7 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 3.15) +project(MocInclude) +get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) +include("${CS_REAL}/../AutogenCoreTest.cmake") + +# Test moc include patterns + +set(COM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Common") + +macro(addCopyCommand from to) + add_custom_command( + OUTPUT ${to} + COMMAND ${CMAKE_COMMAND} -E copy ${from} ${to} + DEPENDS ${from}) +endmacro() + +# Create an executable +function(makeExecutable TARGET_NAME) + # Utility variables + set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + # Copy directory + file(REMOVE_RECURSE "${CB_DIR}/InIncludes") + file(COPY "${COM_DIR}/InIncludes.in" DESTINATION "${CB_DIR}") + file(RENAME "${CB_DIR}/InIncludes.in" "${CB_DIR}/InIncludes") + + # Generate .moc file from the header externally and + # enabled SKIP_AUTOMOC on the source file + qtx_wrap_cpp(ExternDotMOC ${COM_DIR}/ExternDot.hpp OPTIONS "-p" "./") + addCopyCommand(${ExternDotMOC} + ${CB_DIR}/ExternDot.moc) + set_property( + SOURCE ${COM_DIR}/ExternDot.cpp + PROPERTY SKIP_AUTOMOC ON) + + # Generate .moc file from the GENERATED header externally + # and enabled SKIP_AUTOMOC on the source file + addCopyCommand(${COM_DIR}/ExternDotGenerated.hpp.in + ${CB_DIR}/ExternDotGenerated.hpp) + addCopyCommand(${COM_DIR}/ExternDotGenerated.cpp.in + ${CB_DIR}/ExternDotGenerated.cpp) + qtx_wrap_cpp(ExternDotGeneratedMOC + ${CB_DIR}/ExternDotGenerated.hpp + OPTIONS "-p" "./") + addCopyCommand(${ExternDotGeneratedMOC} + ${CB_DIR}/ExternDotGenerated.moc) + set_property( + SOURCE ${CB_DIR}/ExternDotGenerated.cpp + PROPERTY SKIP_AUTOMOC ON) + + # Generate header moc file externally with a custom name + # and enabled SKIP_AUTOMOC on the header + qtx_wrap_cpp(MixedCustomMOC + ${COM_DIR}/MixedCustom.hpp + OPTIONS "-p" "./") + addCopyCommand(${MixedCustomMOC} + ${CB_DIR}/MixedCustom_extMoc.cpp) + set_property( + SOURCE ${COM_DIR}/MixedCustom.hpp + PROPERTY SKIP_AUTOMOC ON) + # Custom target to depend on + add_custom_target("${TARGET_NAME}_MixedCustom" + DEPENDS ${CB_DIR}/MixedCustom_extMoc.cpp + BYPRODUCTS ${CB_DIR}/moc_MixedCustom.cpp + COMMAND ${CMAKE_COMMAND} -E copy + ${COM_DIR}/moc_MixedCustom.cpp.in + ${CB_DIR}/moc_MixedCustom.cpp) + + add_executable(${TARGET_NAME} + # Test own "*.moc" and "moc_*.cpp" includes + ${COM_DIR}/None.cpp + ${COM_DIR}/OwnDot.cpp + ${COM_DIR}/OwnUnderscore.cpp + ${COM_DIR}/OwnDotUnderscore.cpp + + # Test "moc_*.cpp" includes of other files + ${COM_DIR}/OtherUnderscore.cpp + ${COM_DIR}/OtherUnderscoreExtra.cpp + ${COM_DIR}/OtherUnderscoreSub.cpp + ${COM_DIR}/OtherUnderscoreSubDir/SubExtra.cpp + + # Test relative ../../ path for moc includes + ${COM_DIR}/DualSub/Second/Second.cpp + ${COM_DIR}/DualSubMocked.cpp + + # Test externally generated moc files + ${COM_DIR}/ExternDot.cpp + ${CB_DIR}/ExternDot.moc + + # Test externally generated moc files for GENERATED source + ${CB_DIR}/ExternDotGenerated.cpp + ${CB_DIR}/ExternDotGenerated.moc + + # Test externally generated moc files and SKIP_AUTOMOC enabled header + ${COM_DIR}/MixedSkipped.cpp + ${COM_DIR}/MixedCustom.hpp + ${COM_DIR}/MixedCustom.cpp + + # Test sources in a subdirectory + ${CB_DIR}/InIncludes/SubOwnDot.cpp + ${COM_DIR}/InIncludesMoc.cpp + ) + add_dependencies(${TARGET_NAME} "${TARGET_NAME}_MixedCustom") + target_include_directories(${TARGET_NAME} PRIVATE "${COM_DIR}") + target_include_directories(${TARGET_NAME} PRIVATE "${CB_DIR}") + target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES}) + set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON) +endfunction() + +add_subdirectory(Strict) +add_subdirectory(Relaxed) diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp new file mode 100644 index 000000000..453add117 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp @@ -0,0 +1,11 @@ +#include "Second.hpp" + +Second::Second() +{ +} + +Second::~Second() +{ +} + +#include "../../moc_DualSubMocked.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp new file mode 100644 index 000000000..e1f3eac16 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp @@ -0,0 +1,14 @@ +#ifndef Second_HPP +#define Second_HPP + +#include <QObject> + +class Second : public QObject +{ + Q_OBJECT +public: + Second(); + ~Second(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp new file mode 100644 index 000000000..1d4658dcb --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp @@ -0,0 +1,9 @@ +#include "DualSubMocked.hpp" + +DualSubMocked::DualSubMocked() +{ +} + +DualSubMocked::~DualSubMocked() +{ +} diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp new file mode 100644 index 000000000..58cb571dd --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp @@ -0,0 +1,15 @@ +#ifndef DualSubMocked_HPP +#define DualSubMocked_HPP + +#include <QObject> + +// Header moc file is included by DualSub/Second/Second.cpp +class DualSubMocked : public QObject +{ + Q_OBJECT +public: + DualSubMocked(); + ~DualSubMocked(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp new file mode 100644 index 000000000..2495aa794 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp @@ -0,0 +1,11 @@ +#include "ExternDot.hpp" + +ExternDot::ExternDot() +{ +} + +ExternDot::~ExternDot() +{ +} + +#include "ExternDot.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp new file mode 100644 index 000000000..7eaab2afb --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp @@ -0,0 +1,15 @@ +#ifndef ExternDot_HPP +#define ExternDot_HPP + +#include <QObject> + +// Object source includes externally generated .moc file +class ExternDot : public QObject +{ + Q_OBJECT +public: + ExternDot(); + ~ExternDot(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in new file mode 100644 index 000000000..09ce5cdba --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in @@ -0,0 +1,11 @@ +#include "ExternDotGenerated.hpp" + +ExternDotGenerated::ExternDotGenerated() +{ +} + +ExternDotGenerated::~ExternDotGenerated() +{ +} + +#include "ExternDotGenerated.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in new file mode 100644 index 000000000..21c69be06 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in @@ -0,0 +1,15 @@ +#ifndef ExternDotGenerated_HPP +#define ExternDotGenerated_HPP + +#include <QObject> + +// GENERATED Object source includes externally generated .moc file +class ExternDotGenerated : public QObject +{ + Q_OBJECT +public: + ExternDotGenerated(); + ~ExternDotGenerated(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp new file mode 100644 index 000000000..275754dbb --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp @@ -0,0 +1,44 @@ +#include "SubOwnDot.hpp" + +#include "SubOwnDot_p.hpp" + +namespace InIncludes { + +class SubOwnDotLocal : public QObject +{ + Q_OBJECT +public: + SubOwnDotLocal(); + ~SubOwnDotLocal(); +}; + +SubOwnDotLocal::SubOwnDotLocal() +{ +} + +SubOwnDotLocal::~SubOwnDotLocal() +{ +} + +SubOwnDotPrivate::SubOwnDotPrivate() +{ +} + +SubOwnDotPrivate::~SubOwnDotPrivate() +{ +} + +SubOwnDot::SubOwnDot() +{ + SubOwnDotPrivate privateObj; + SubOwnDotLocal localObj; +} + +SubOwnDot::~SubOwnDot() +{ +} + +} // End of namespace + +// For the local QObject +#include "SubOwnDot.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp new file mode 100644 index 000000000..038ddfaa4 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp @@ -0,0 +1,17 @@ +#ifndef InIncludes_SubOwnDot_HPP +#define InIncludes_SubOwnDot_HPP + +#include <QObject> + +namespace InIncludes { + +class SubOwnDot : public QObject +{ + Q_OBJECT +public: + SubOwnDot(); + ~SubOwnDot(); +}; +} + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp new file mode 100644 index 000000000..626a9a86c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp @@ -0,0 +1,18 @@ +#ifndef InIncludes_SubOwnDot_P_HPP +#define InIncludes_SubOwnDot_P_HPP + +#include <QObject> + +namespace InIncludes { + +class SubOwnDotPrivate : public QObject +{ + Q_OBJECT +public: + SubOwnDotPrivate(); + ~SubOwnDotPrivate(); +}; + +} // End of namespace + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp new file mode 100644 index 000000000..88f53a445 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp @@ -0,0 +1,4 @@ + +// Moc a header that is not in the sources but in a directory that +// is in the list of include directories. +#include "InIncludes/moc_SubOwnDot.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp new file mode 100644 index 000000000..557cc62e1 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp @@ -0,0 +1,32 @@ +#include "MixedCustom.hpp" + +class MixedCustomLocal : public QObject +{ + Q_OBJECT + +public: + MixedCustomLocal(); + ~MixedCustomLocal(); +}; + +MixedCustomLocal::MixedCustomLocal() +{ +} + +MixedCustomLocal::~MixedCustomLocal() +{ +} + +MixedCustom::MixedCustom() +{ + MixedCustomLocal local; +} + +MixedCustom::~MixedCustom() +{ +} + +// AUTOMOC generated source moc +#include "MixedCustom.moc" +// Externally generated header moc +#include "MixedCustom_extMoc.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp new file mode 100644 index 000000000..6e8ff8865 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp @@ -0,0 +1,20 @@ +#ifndef MixedCustom_HPP +#define MixedCustom_HPP + +#include <QObject> + +// Object source includes +// - externally generated header moc file +// - AUTOMOC generated source .moc file +class MixedCustom : public QObject +{ + Q_OBJECT +public: + MixedCustom(); + ~MixedCustom(); +}; + +// Function forward declaration +void moc_MixedCustom(MixedCustom const& arg); + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp new file mode 100644 index 000000000..6919ebcf2 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp @@ -0,0 +1,40 @@ +#include "MixedSkipped.hpp" + +#include "MixedCustom.hpp" + +class MixedSkippedLocal : public QObject +{ + Q_OBJECT + +public: + MixedSkippedLocal(); + ~MixedSkippedLocal(); +}; + +MixedSkippedLocal::MixedSkippedLocal() +{ +} + +MixedSkippedLocal::~MixedSkippedLocal() +{ +} + +MixedSkipped::MixedSkipped() +{ + MixedSkippedLocal local; + MixedCustom externCutom; + // Call moc named function + moc_MixedCustom(externCutom); +} + +MixedSkipped::~MixedSkipped() +{ +} + +// Include AUTOMOC generated moc files +#include "MixedSkipped.moc" +#include "moc_MixedSkipped.cpp" + +// Include externally generated moc_ named file that is not a moc file +// and for which the relevant header is SKIP_AUTOMOC enabled +#include "moc_MixedCustom.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp new file mode 100644 index 000000000..5f6c6644f --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp @@ -0,0 +1,17 @@ +#ifndef MixedSkipped_HPP +#define MixedSkipped_HPP + +#include <QObject> + +// Object source includes +// - Own moc_ and .moc files. +// - externally generated moc_ file from a SKIP_AUTOMOC enabled header +class MixedSkipped : public QObject +{ + Q_OBJECT +public: + MixedSkipped(); + ~MixedSkipped(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/None.cpp b/Tests/QtAutogen/MocInclude/Common/None.cpp new file mode 100644 index 000000000..286ddb6cc --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None.cpp @@ -0,0 +1,21 @@ +#include "None.hpp" + +#include "None_p.h" + +NonePrivate::NonePrivate() +{ +} + +NonePrivate::~NonePrivate() +{ +} + +None::None() + : d(new NonePrivate) +{ +} + +None::~None() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/None.hpp b/Tests/QtAutogen/MocInclude/Common/None.hpp new file mode 100644 index 000000000..ca0713ec4 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None.hpp @@ -0,0 +1,19 @@ +#ifndef None_HPP +#define None_HPP + +#include <QObject> + +// Object source comes without any _moc/.moc includes +class NonePrivate; +class None : public QObject +{ + Q_OBJECT +public: + None(); + ~None(); + +private: + NonePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/None_p.h b/Tests/QtAutogen/MocInclude/Common/None_p.h new file mode 100644 index 000000000..e209aebbd --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None_p.h @@ -0,0 +1,14 @@ +#ifndef None_P_HPP +#define None_P_HPP + +#include <QObject> + +class NonePrivate : public QObject +{ + Q_OBJECT +public: + NonePrivate(); + ~NonePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp new file mode 100644 index 000000000..df1c428a1 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp @@ -0,0 +1,45 @@ +#include "OtherUnderscore.hpp" + +#include "OtherUnderscoreExtra.hpp" +#include "OtherUnderscore_p.hpp" + +class OtherUnderscoreLocal : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreLocal(); + ~OtherUnderscoreLocal(); +}; + +OtherUnderscoreLocal::OtherUnderscoreLocal() +{ +} + +OtherUnderscoreLocal::~OtherUnderscoreLocal() +{ +} + +OtherUnderscorePrivate::OtherUnderscorePrivate() +{ + OtherUnderscoreLocal localObj; + OtherUnderscoreExtra extraObj; +} + +OtherUnderscorePrivate::~OtherUnderscorePrivate() +{ +} + +OtherUnderscore::OtherUnderscore() + : d(new OtherUnderscorePrivate) +{ +} + +OtherUnderscore::~OtherUnderscore() +{ + delete d; +} + +// For OtherUnderscoreLocal +#include "OtherUnderscore.moc" +// - Not the own header +#include "moc_OtherUnderscoreExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp new file mode 100644 index 000000000..a4ff603cf --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef OtherUnderscore_HPP +#define OtherUnderscore_HPP + +#include <QObject> + +// Sources includes a moc_ includes of an extra object +class OtherUnderscorePrivate; +class OtherUnderscore : public QObject +{ + Q_OBJECT +public: + OtherUnderscore(); + ~OtherUnderscore(); + +private: + OtherUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp new file mode 100644 index 000000000..11ebd8104 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp @@ -0,0 +1,21 @@ +#include "OtherUnderscoreExtra.hpp" + +#include "OtherUnderscoreExtra_p.hpp" + +OtherUnderscoreExtraPrivate::OtherUnderscoreExtraPrivate() +{ +} + +OtherUnderscoreExtraPrivate::~OtherUnderscoreExtraPrivate() +{ +} + +OtherUnderscoreExtra::OtherUnderscoreExtra() + : d(new OtherUnderscoreExtraPrivate) +{ +} + +OtherUnderscoreExtra::~OtherUnderscoreExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp new file mode 100644 index 000000000..5afe48cf8 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp @@ -0,0 +1,18 @@ +#ifndef OtherUnderscoreEXTRA_HPP +#define OtherUnderscoreEXTRA_HPP + +#include <QObject> + +class OtherUnderscoreExtraPrivate; +class OtherUnderscoreExtra : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreExtra(); + ~OtherUnderscoreExtra(); + +private: + OtherUnderscoreExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp new file mode 100644 index 000000000..2066ac305 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscoreEXTRA_P_HPP +#define OtherUnderscoreEXTRA_P_HPP + +#include <QObject> + +class OtherUnderscoreExtraPrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreExtraPrivate(); + ~OtherUnderscoreExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp new file mode 100644 index 000000000..712c540c3 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp @@ -0,0 +1,46 @@ +#include "OtherUnderscoreSub.hpp" + +#include "OtherUnderscoreSubDir/SubExtra.hpp" +#include "OtherUnderscoreSub_p.hpp" + +class OtherUnderscoreSubLocal : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSubLocal(); + ~OtherUnderscoreSubLocal(); +}; + +OtherUnderscoreSubLocal::OtherUnderscoreSubLocal() +{ +} + +OtherUnderscoreSubLocal::~OtherUnderscoreSubLocal() +{ +} + +OtherUnderscoreSubPrivate::OtherUnderscoreSubPrivate() +{ + OtherUnderscoreSubLocal localObj; + SubExtra extraObj; +} + +OtherUnderscoreSubPrivate::~OtherUnderscoreSubPrivate() +{ +} + +OtherUnderscoreSub::OtherUnderscoreSub() + : d(new OtherUnderscoreSubPrivate) +{ +} + +OtherUnderscoreSub::~OtherUnderscoreSub() +{ + delete d; +} + +// For OtherUnderscoreSubLocal +#include "OtherUnderscoreSub.moc" +// - Not the own header +// - in a subdirectory +#include "OtherUnderscoreSubDir/moc_SubExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp new file mode 100644 index 000000000..7feaa46f1 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp @@ -0,0 +1,19 @@ +#ifndef OtherUnderscoreSub_HPP +#define OtherUnderscoreSub_HPP + +#include <QObject> + +// Sources includes a moc_ includes of an extra object in a subdirectory +class OtherUnderscoreSubPrivate; +class OtherUnderscoreSub : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSub(); + ~OtherUnderscoreSub(); + +private: + OtherUnderscoreSubPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp new file mode 100644 index 000000000..22501e44d --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp @@ -0,0 +1,21 @@ +#include "SubExtra.hpp" + +#include "SubExtra_p.hpp" + +SubExtraPrivate::SubExtraPrivate() +{ +} + +SubExtraPrivate::~SubExtraPrivate() +{ +} + +SubExtra::SubExtra() + : d(new SubExtraPrivate) +{ +} + +SubExtra::~SubExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp new file mode 100644 index 000000000..5700634a0 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp @@ -0,0 +1,18 @@ +#ifndef SubExtra_HPP +#define SubExtra_HPP + +#include <QObject> + +class SubExtraPrivate; +class SubExtra : public QObject +{ + Q_OBJECT +public: + SubExtra(); + ~SubExtra(); + +private: + SubExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp new file mode 100644 index 000000000..5a14a2d38 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp @@ -0,0 +1,14 @@ +#ifndef SubExtra_P_HPP +#define SubExtra_P_HPP + +#include <QObject> + +class SubExtraPrivate : public QObject +{ + Q_OBJECT +public: + SubExtraPrivate(); + ~SubExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp new file mode 100644 index 000000000..7d5999ca4 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscoreSub_P_HPP +#define OtherUnderscoreSub_P_HPP + +#include <QObject> + +class OtherUnderscoreSubPrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSubPrivate(); + ~OtherUnderscoreSubPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp new file mode 100644 index 000000000..96906cfc2 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscore_P_HPP +#define OtherUnderscore_P_HPP + +#include <QObject> + +class OtherUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscorePrivate(); + ~OtherUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp new file mode 100644 index 000000000..b7b7d854c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp @@ -0,0 +1,40 @@ +#include "OwnDot.hpp" + +#include "OwnDot_p.h" + +class OwnDotLocal : public QObject +{ + Q_OBJECT +public: + OwnDotLocal(); + ~OwnDotLocal(); +}; + +OwnDotLocal::OwnDotLocal() +{ +} + +OwnDotLocal::~OwnDotLocal() +{ +} + +OwnDotPrivate::OwnDotPrivate() +{ + OwnDotLocal localObj; +} + +OwnDotPrivate::~OwnDotPrivate() +{ +} + +OwnDot::OwnDot() + : d(new OwnDotPrivate) +{ +} + +OwnDot::~OwnDot() +{ + delete d; +} + +#include "OwnDot.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp new file mode 100644 index 000000000..6f49f12ba --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp @@ -0,0 +1,19 @@ +#ifndef OwnDot_HPP +#define OwnDot_HPP + +#include <QObject> + +// Object source comes with a .moc include +class OwnDotPrivate; +class OwnDot : public QObject +{ + Q_OBJECT +public: + OwnDot(); + ~OwnDot(); + +private: + OwnDotPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp new file mode 100644 index 000000000..056c0db84 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp @@ -0,0 +1,41 @@ +#include "OwnDotUnderscore.hpp" + +#include "OwnDotUnderscore_p.h" + +class OwnDotUnderscoreLocal : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscoreLocal(); + ~OwnDotUnderscoreLocal(); +}; + +OwnDotUnderscoreLocal::OwnDotUnderscoreLocal() +{ +} + +OwnDotUnderscoreLocal::~OwnDotUnderscoreLocal() +{ +} + +OwnDotUnderscorePrivate::OwnDotUnderscorePrivate() +{ + OwnDotUnderscoreLocal localObj; +} + +OwnDotUnderscorePrivate::~OwnDotUnderscorePrivate() +{ +} + +OwnDotUnderscore::OwnDotUnderscore() + : d(new OwnDotUnderscorePrivate) +{ +} + +OwnDotUnderscore::~OwnDotUnderscore() +{ + delete d; +} + +#include "OwnDotUnderscore.moc" +#include "moc_OwnDotUnderscore.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp new file mode 100644 index 000000000..478955c30 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef LOwnDotUnderscore_HPP +#define LOwnDotUnderscore_HPP + +#include <QObject> + +// Object source comes with a .moc and a _moc include +class OwnDotUnderscorePrivate; +class OwnDotUnderscore : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscore(); + ~OwnDotUnderscore(); + +private: + OwnDotUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h new file mode 100644 index 000000000..6950b7f13 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h @@ -0,0 +1,14 @@ +#ifndef OwnDotUnderscore_P_HPP +#define OwnDotUnderscore_P_HPP + +#include <QObject> + +class OwnDotUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscorePrivate(); + ~OwnDotUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h new file mode 100644 index 000000000..f3aff32ff --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h @@ -0,0 +1,14 @@ +#ifndef OwnDot_P_HPP +#define OwnDot_P_HPP + +#include <QObject> + +class OwnDotPrivate : public QObject +{ + Q_OBJECT +public: + OwnDotPrivate(); + ~OwnDotPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp new file mode 100644 index 000000000..cb8f12c9b --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp @@ -0,0 +1,23 @@ +#include "OwnUnderscore.hpp" + +#include "OwnUnderscore_p.h" + +OwnUnderscorePrivate::OwnUnderscorePrivate() +{ +} + +OwnUnderscorePrivate::~OwnUnderscorePrivate() +{ +} + +OwnUnderscore::OwnUnderscore() + : d(new OwnUnderscorePrivate) +{ +} + +OwnUnderscore::~OwnUnderscore() +{ + delete d; +} + +#include "moc_OwnUnderscore.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp new file mode 100644 index 000000000..e6a6a6eb8 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef OwnUnderscore_HPP +#define OwnUnderscore_HPP + +#include <QObject> + +// Object source comes with a _moc include +class OwnUnderscorePrivate; +class OwnUnderscore : public QObject +{ + Q_OBJECT +public: + OwnUnderscore(); + ~OwnUnderscore(); + +private: + OwnUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h new file mode 100644 index 000000000..a3a6b0062 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h @@ -0,0 +1,14 @@ +#ifndef OwnUnderscore_P_HPP +#define OwnUnderscore_P_HPP + +#include <QObject> + +class OwnUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OwnUnderscorePrivate(); + ~OwnUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/common.cpp.in b/Tests/QtAutogen/MocInclude/Common/common.cpp.in new file mode 100644 index 000000000..b53e93dd6 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/common.cpp.in @@ -0,0 +1,32 @@ +#include "DualSub/Second/Second.hpp" +#include "DualSubMocked.hpp" +#include "ExternDot.hpp" +#include "ExternDotGenerated.hpp" +#include "None.hpp" +#include "OtherUnderscore.hpp" +#include "OtherUnderscoreSub.hpp" +#include "OwnDot.hpp" +#include "OwnDotUnderscore.hpp" +#include "OwnUnderscore.hpp" +#include "InIncludes/SubOwnDot.hpp" + +bool @COMMON_FUNCTION_NAME@() +{ + None objNone; + OwnUnderscore objOwnUnderscore; + OwnDot objOwnDot; + OwnDotUnderscore objOwnDotUnderscore; + + OtherUnderscore objOtherUnderscore; + OtherUnderscoreSub objOtherUnderscoreSub; + + Second second; + DualSubMocked dualSubMocked; + + ExternDot objExternDot; + ExternDotGenerated objGeneratedExternDot; + + InIncludes::SubOwnDot subOwnDot; + + return true; +} diff --git a/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in new file mode 100644 index 000000000..6c44793a8 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in @@ -0,0 +1,5 @@ + +void moc_MixedCustom(MixedCustom const & arg) +{ + (void)arg; +} diff --git a/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt new file mode 100644 index 000000000..048b79cb7 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt @@ -0,0 +1,17 @@ +# Enable relaxed mode +set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) + +# Common test +set(COMMON_FUNCTION_NAME commonRelaxed) +configure_file( + "${COM_DIR}/common.cpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp") + +makeExecutable(libRelaxed) +target_sources(libRelaxed PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp" + RObjA.cpp + RObjB.cpp + RObjC.cpp + relaxed.cpp + ) diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp new file mode 100644 index 000000000..2e2cf6a48 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp @@ -0,0 +1,12 @@ +#include "RObjA.hpp" + +RObjA::RObjA() +{ +} + +RObjA::~RObjA() +{ +} + +// Relaxed include should moc the header instead +#include "RObjA.moc" diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp new file mode 100644 index 000000000..597418773 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJA_HPP +#define ROBJA_HPP + +#include <QObject> + +class RObjA : public QObject +{ + Q_OBJECT +public: + RObjA(); + ~RObjA(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp new file mode 100644 index 000000000..57d7daf16 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp @@ -0,0 +1,23 @@ +#include "RObjB.hpp" + +#include "RObjBExtra.hpp" + +RObjBExtra::RObjBExtra() +{ +} + +RObjBExtra::~RObjBExtra() +{ +} + +RObjB::RObjB() +{ + RObjBExtra extraObject; +} + +RObjB::~RObjB() +{ +} + +// Relaxed mode should run moc on RObjBExtra.hpp instead +#include "RObjBExtra.moc" diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp new file mode 100644 index 000000000..d6d0474ad --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJB_HPP +#define ROBJB_HPP + +#include <QObject> + +class RObjB : public QObject +{ + Q_OBJECT +public: + RObjB(); + ~RObjB(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp new file mode 100644 index 000000000..5d6be752f --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJBEXTRA_HPP +#define ROBJBEXTRA_HPP + +#include <QObject> + +class RObjBExtra : public QObject +{ + Q_OBJECT +public: + RObjBExtra(); + ~RObjBExtra(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp new file mode 100644 index 000000000..327521666 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp @@ -0,0 +1,31 @@ +#include "RObjC.hpp" + +#include <QObject> + +class RObjCPrivate : public QObject +{ + Q_OBJECT +public: + RObjCPrivate(); + ~RObjCPrivate(); +}; + +RObjCPrivate::RObjCPrivate() +{ +} + +RObjCPrivate::~RObjCPrivate() +{ +} + +RObjC::RObjC() +{ + RObjCPrivate privateObject; +} + +RObjC::~RObjC() +{ +} + +// Relaxed include should moc this source instead of the header +#include "moc_RObjC.cpp" diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp new file mode 100644 index 000000000..5552ede4a --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJC_HPP +#define ROBJC_HPP + +#include <QObject> + +class RObjC : public QObject +{ + Q_OBJECT +public: + RObjC(); + ~RObjC(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp new file mode 100644 index 000000000..5a511b673 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp @@ -0,0 +1,21 @@ +// AUTOMOC relaxed mode objects +#include "RObjA.hpp" +#include "RObjB.hpp" +#include "RObjC.hpp" + +// Forward declaration +bool commonRelaxed(); + +int main(int argv, char** args) +{ + // Common tests + if (!commonRelaxed()) { + return -1; + } + + // Relaxed tests + RObjA rObjA; + RObjB rObjB; + RObjC rObjC; + return 0; +} diff --git a/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt new file mode 100644 index 000000000..12c503faf --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt @@ -0,0 +1,14 @@ +# Disable relaxed mode +set(CMAKE_AUTOMOC_RELAXED_MODE FALSE) + +# Common test +set(COMMON_FUNCTION_NAME commonStrict) +configure_file( + "${COM_DIR}/common.cpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp") + +makeExecutable(libStrict) +target_sources(libStrict PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp" + strict.cpp + ) diff --git a/Tests/QtAutogen/MocInclude/Strict/strict.cpp b/Tests/QtAutogen/MocInclude/Strict/strict.cpp new file mode 100644 index 000000000..dd24bb0d4 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Strict/strict.cpp @@ -0,0 +1,7 @@ +// Forward declaration +bool commonStrict(); + +int main(int argv, char** args) +{ + return commonStrict() ? 0 : -1; +} diff --git a/Tests/QtAutogen/MocInclude/main.cpp b/Tests/QtAutogen/MocInclude/main.cpp new file mode 100644 index 000000000..371c5fdad --- /dev/null +++ b/Tests/QtAutogen/MocInclude/main.cpp @@ -0,0 +1,9 @@ + +// Forward declaration +bool libStrict(); +bool libRelaxed(); + +int main(int argv, char** args) +{ + return (libStrict() && libRelaxed()) ? 0 : -1; +} diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt new file mode 100644 index 000000000..1627b394f --- /dev/null +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.15) +project(MocIncludeSymlink) +include("../AutogenCoreTest.cmake") + +# +# Tests if MocInclude can be build when +# - The source directory is a symbolic link +# - The build directory is a symbolic link +# + +# -- Utility variables +set(CS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}") + +# Absolute MocInclude path +get_filename_component(MocIncludePath "../MocInclude" ABSOLUTE) +message("MocIncludePath: ${MocIncludePath}") + +# Use nested subdirectories to ensure relatives paths are correct as well +set(BUILD_DIR_NORMAL "${CB_DIR}/Build/Normal") +set(BUILD_DIR_LINKED "${CB_DIR}/Build/Linked") + +set(SL_SOURCE_DIR "${CB_DIR}/SL_Source") +set(SL_BUILD_DIR "${CB_DIR}/SL_Build") + +# -- Utility macros +function(makeSymLink origin link) + message("Creating symbolic link\n Link: ${link}\n To: ${origin}") + file(CREATE_LINK ${origin} ${link} RESULT res SYMBOLIC) + if(NOT (${res} STREQUAL "0")) + message("Symlink creation failed.\n Link: ${link}\n To: ${origin}\n Result: ${res}") + endif() +endfunction() + +# -- Make source directory symlink +makeSymLink(${MocIncludePath} ${SL_SOURCE_DIR} linkResult) +if(NOT EXISTS ${SL_SOURCE_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + +# -- Make normal build directory +file(REMOVE_RECURSE ${BUILD_DIR_NORMAL}) +file(MAKE_DIRECTORY ${BUILD_DIR_NORMAL}) + +# -- Make linked build directory and symlink +file(REMOVE_RECURSE ${BUILD_DIR_LINKED}) +file(MAKE_DIRECTORY ${BUILD_DIR_LINKED}) +makeSymLink(${BUILD_DIR_LINKED} ${SL_BUILD_DIR} linkResult) +if(NOT EXISTS ${SL_BUILD_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + + +# -- Building +macro(buildMocInclude sourceDir binaryDir) + message("Building MocInclude\n - source dir: ${sourceDir}\n - binary dir: ${binaryDir}\n") + try_compile(result + "${binaryDir}" + "${sourceDir}" + MocInclude + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output + ) + if (result) + message(STATUS "--- Build success. ---") + else() + message(STATUS "\n### Building MocInclude failed. ###\n\n--- Output ---\n${output}") + message(FATAL_ERROR "--- Building MocInclude failed. End of output. ---") + endif() +endmacro() + +message("\nTry building with\n - symbolic link source dir\n - non symbolic build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${BUILD_DIR_NORMAL}) + +message("\nTry building with\n - symbolic link source dir\n - symbolic link build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${SL_BUILD_DIR}) diff --git a/Tests/QtAutogen/MocMacroName/CMakeLists.txt b/Tests/QtAutogen/MocMacroName/CMakeLists.txt new file mode 100644 index 000000000..bf13d187d --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) +project(MocMacroName) +include("../AutogenCoreTest.cmake") + +# Test CMAKE_AUTOMOC_MACRO_NAMES and AUTOMOC_MACRO_NAMES +list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "QO1_ALIAS") + +add_executable(mocMacroName + main.cpp + Gadget.cpp + Object.cpp + Object1Aliased.cpp + Object2Aliased.cpp +) +set_property(TARGET mocMacroName PROPERTY AUTOMOC ON) +set_property(TARGET mocMacroName APPEND PROPERTY AUTOMOC_MACRO_NAMES "QO2_ALIAS") +target_link_libraries(mocMacroName ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocMacroName/CustomMacros.hpp b/Tests/QtAutogen/MocMacroName/CustomMacros.hpp new file mode 100644 index 000000000..93e5bfdc1 --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/CustomMacros.hpp @@ -0,0 +1,8 @@ +#ifndef CUSTOM_MACROS_HPP +#define CUSTOM_MACROS_HPP + +#include <QObject> +#define QO1_ALIAS Q_OBJECT +#define QO2_ALIAS Q_OBJECT + +#endif diff --git a/Tests/QtAutogen/MocMacroName/Gadget.cpp b/Tests/QtAutogen/MocMacroName/Gadget.cpp new file mode 100644 index 000000000..d7cb51590 --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Gadget.cpp @@ -0,0 +1,6 @@ +#include "Gadget.hpp" + +Gadget::Gadget() + : _test(0) +{ +} diff --git a/Tests/QtAutogen/MocMacroName/Gadget.hpp b/Tests/QtAutogen/MocMacroName/Gadget.hpp new file mode 100644 index 000000000..cab792edc --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Gadget.hpp @@ -0,0 +1,19 @@ +#ifndef GADGET_HPP +#define GADGET_HPP + +#include <QMetaType> + +class Gadget +{ + Q_GADGET + Q_PROPERTY(int test READ getTest) +public: + Gadget(); + + int getTest() { return _test; } + +private: + int _test; +}; + +#endif diff --git a/Tests/QtAutogen/MocMacroName/Object.cpp b/Tests/QtAutogen/MocMacroName/Object.cpp new file mode 100644 index 000000000..800ebf3da --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object.cpp @@ -0,0 +1,10 @@ +#include "Object.hpp" + +Object::Object() + : _test(0) +{ +} + +void Object::aSlot() +{ +} diff --git a/Tests/QtAutogen/MocMacroName/Object.hpp b/Tests/QtAutogen/MocMacroName/Object.hpp new file mode 100644 index 000000000..aadae1f6d --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object.hpp @@ -0,0 +1,22 @@ +#ifndef OBJECT_HPP +#define OBJECT_HPP + +#include <QObject> + +class Object : public QObject +{ + Q_OBJECT + Q_PROPERTY(int test READ getTest) +public: + Object(); + + int getTest() { return _test; } + + Q_SLOT + void aSlot(); + +private: + int _test; +}; + +#endif diff --git a/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp b/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp new file mode 100644 index 000000000..b8b4806c6 --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp @@ -0,0 +1,9 @@ +#include "Object1Aliased.hpp" + +Object1Aliased::Object1Aliased() +{ +} + +void Object1Aliased::aSlot() +{ +} diff --git a/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp b/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp new file mode 100644 index 000000000..6c6bb4088 --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp @@ -0,0 +1,20 @@ +#ifndef OBJECTALIASED_HPP +#define OBJECTALIASED_HPP + +#include "CustomMacros.hpp" + +// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES) +class Object1Aliased : public QObject +{ + QO1_ALIAS +public: + Object1Aliased(); + +signals: + void aSignal(); + +public slots: + void aSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp b/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp new file mode 100644 index 000000000..4b09dd1bc --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp @@ -0,0 +1,9 @@ +#include "Object2Aliased.hpp" + +Object2Aliased::Object2Aliased() +{ +} + +void Object2Aliased::aSlot() +{ +} diff --git a/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp b/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp new file mode 100644 index 000000000..b9bdc126f --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp @@ -0,0 +1,20 @@ +#ifndef OBJECT2ALIASED_HPP +#define OBJECT2ALIASED_HPP + +#include "CustomMacros.hpp" + +// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES) +class Object2Aliased : public QObject +{ + QO2_ALIAS +public: + Object2Aliased(); + +signals: + void aSignal(); + +public slots: + void aSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/MocMacroName/main.cpp b/Tests/QtAutogen/MocMacroName/main.cpp new file mode 100644 index 000000000..3b45d042d --- /dev/null +++ b/Tests/QtAutogen/MocMacroName/main.cpp @@ -0,0 +1,13 @@ +#include "Gadget.hpp" +#include "Object.hpp" +#include "Object1Aliased.hpp" +#include "Object2Aliased.hpp" + +int main(int argv, char** args) +{ + Gadget gadget; + Object object; + Object1Aliased object1Aliased; + Object2Aliased object2Aliased; + return 0; +} diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt new file mode 100644 index 000000000..e109154aa --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) +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 +) +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/IncA.cpp b/Tests/QtAutogen/MocOnly/IncA.cpp new file mode 100644 index 000000000..94610cd48 --- /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 000000000..ecc889f9d --- /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 000000000..bd441a978 --- /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 000000000..8331ea2b7 --- /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 000000000..ced1dd151 --- /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 000000000..5ba0a8768 --- /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 000000000..bec6c1c36 --- /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 000000000..86abaa8c9 --- /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 000000000..ec8da214e --- /dev/null +++ b/Tests/QtAutogen/MocOnly/main.cpp @@ -0,0 +1,19 @@ +#include <iostream> + +#include "IncA.hpp" +#include "IncB.hpp" +#include "StyleA.hpp" +#include "StyleB.hpp" + +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; +} diff --git a/Tests/QtAutogen/MocOptions/CMakeLists.txt b/Tests/QtAutogen/MocOptions/CMakeLists.txt new file mode 100644 index 000000000..19ee6587e --- /dev/null +++ b/Tests/QtAutogen/MocOptions/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocOptions) +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) +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 000000000..ad109f14c --- /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 000000000..e7a614200 --- /dev/null +++ b/Tests/QtAutogen/MocOptions/Object.hpp @@ -0,0 +1,13 @@ +#ifndef Object_HPP +#define Object_HPP + +#include <QObject> + +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 000000000..7aeab1a89 --- /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/MocOsMacros/CMakeLists.txt b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt new file mode 100644 index 000000000..b0125f6c3 --- /dev/null +++ b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.11) +project(MocOsMacros) +include("../AutogenCoreTest.cmake") + +# Tests if moc processes Q_OS_XXX macros + +message( "Qt5Core_VERSION: ${Qt5Core_VERSION}" ) +message( + "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND: " + ${CMAKE_CXX_COMPILER_PREDEFINES_COMMAND} ) + +# On some platforms (e.g. MAC) Q_OS_XXX requires moc to include moc_predefs.h +# which is supported since Qt 5.8 and requires +# CMAKE_CXX_COMPILER_PREDEFINES_COMMAND to be defined. +if( ( ${Qt5Core_VERSION} VERSION_GREATER_EQUAL "5.8" ) AND + DEFINED CMAKE_CXX_COMPILER_PREDEFINES_COMMAND +) + message( "Test enabled!" ) + message( + "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: " + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ) + + set(CMAKE_AUTOMOC True) + add_executable(mocOsMacros + main.cpp + TestClass.cpp + TestClass.hpp + ) + target_link_libraries(mocOsMacros PRIVATE ${QT_QTCORE_TARGET}) +else() + message( "Test disabled!" ) +endif() diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.cpp b/Tests/QtAutogen/MocOsMacros/TestClass.cpp new file mode 100644 index 000000000..babc08b12 --- /dev/null +++ b/Tests/QtAutogen/MocOsMacros/TestClass.cpp @@ -0,0 +1,83 @@ +#include "TestClass.hpp" + +#include <iostream> + +void TestClass::open() +{ + std::cout << "open\n"; +} + +// -- Mac +#ifndef Q_OS_MAC +void TestClass::MacNotDef() +{ + std::cout << "MacNotDef\n"; +} +#else +void TestClass::MacNotDefElse() +{ + std::cout << "MacNotDefElse\n"; +} +#endif + +#ifdef Q_OS_MAC +void TestClass::MacDef() +{ + std::cout << "MacDef\n"; +} +#else +void TestClass::MacDefElse() +{ + std::cout << "MacDefElse\n"; +} +#endif + +// -- Unix +#ifndef Q_OS_UNIX +void TestClass::UnixNotDef() +{ + std::cout << "UnixNotDef\n"; +} +#else +void TestClass::UnixNotDefElse() +{ + std::cout << "UnixNotDefElse\n"; +} +#endif + +#ifdef Q_OS_UNIX +void TestClass::UnixDef() +{ + std::cout << "UnixDef\n"; +} +#else +void TestClass::UnixDefElse() +{ + std::cout << "UnixDefElse\n"; +} +#endif + +// -- Windows +#ifndef Q_OS_WIN +void TestClass::WindowsNotDef() +{ + std::cout << "WindowsNotDef\n"; +} +#else +void TestClass::WindowsNotDefElse() +{ + std::cout << "WindowsNotDefElse\n"; +} +#endif + +#ifdef Q_OS_WIN +void TestClass::WindowsDef() +{ + std::cout << "WindowsDef\n"; +} +#else +void TestClass::WindowsDefElse() +{ + std::cout << "WindowsDefElse\n"; +} +#endif diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.hpp b/Tests/QtAutogen/MocOsMacros/TestClass.hpp new file mode 100644 index 000000000..87fd49478 --- /dev/null +++ b/Tests/QtAutogen/MocOsMacros/TestClass.hpp @@ -0,0 +1,57 @@ +#ifndef TestClass_hpp +#define TestClass_hpp + +#include <QObject> +#include <QtGlobal> +// include qplatformdefs.h for #18669 +#include <qplatformdefs.h> + +class TestClass : public QObject +{ + Q_OBJECT +public Q_SLOTS: + + // Method named "open" to test if #18669 is fixed + void open(); + +// -- Mac +#ifndef Q_OS_MAC + void MacNotDef(); +#else + void MacNotDefElse(); +#endif + +#ifdef Q_OS_MAC + void MacDef(); +#else + void MacDefElse(); +#endif + +// -- Unix +#ifndef Q_OS_UNIX + void UnixNotDef(); +#else + void UnixNotDefElse(); +#endif + +#ifdef Q_OS_UNIX + void UnixDef(); +#else + void UnixDefElse(); +#endif + +// -- Windows +#ifndef Q_OS_WIN + void WindowsNotDef(); +#else + void WindowsNotDefElse(); +#endif + +#ifdef Q_OS_WIN + void WindowsDef(); +#else + void WindowsDefElse(); +#endif +}; + +#endif /* TestClass_hpp */ diff --git a/Tests/QtAutogen/MocOsMacros/main.cpp b/Tests/QtAutogen/MocOsMacros/main.cpp new file mode 100644 index 000000000..c427345be --- /dev/null +++ b/Tests/QtAutogen/MocOsMacros/main.cpp @@ -0,0 +1,33 @@ +#include <QtGlobal> + +#include "TestClass.hpp" + +int main() +{ + TestClass a; +#ifdef Q_OS_MAC + a.MacNotDefElse(); + a.MacDef(); +#else + a.MacNotDef(); + a.MacDefElse(); +#endif + +#ifdef Q_OS_UNIX + a.UnixNotDefElse(); + a.UnixDef(); +#else + a.UnixNotDef(); + a.UnixDefElse(); +#endif + +#ifdef Q_OS_WIN + a.WindowsNotDefElse(); + a.WindowsDef(); +#else + a.WindowsNotDef(); + a.WindowsDefElse(); +#endif + + return 0; +} diff --git a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt new file mode 100644 index 000000000..454e896e8 --- /dev/null +++ b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.10) +project(MocSkipSource) +include("../AutogenCoreTest.cmake") + +# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target + +# Generate header mocs manually +qtx_wrap_cpp(skipMocWrapMoc + qItemA.hpp + qItemB.hpp + qItemC.hpp + qItemD.hpp +) +set(skipMocSources + skipMoc.cpp + qItemA.cpp + qItemB.cpp + qItemC.cpp + 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 qItemA.cpp PROPERTY SKIP_AUTOMOC ON) +set_property(SOURCE qItemB.cpp PROPERTY SKIP_AUTOGEN ON) +# When hpp files are skipped, the cpp still get processed. +set_property(SOURCE qItemC.hpp PROPERTY SKIP_AUTOMOC ON) +set_property(SOURCE qItemD.hpp PROPERTY SKIP_AUTOGEN ON) +# AUTOMOC enabled only +add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocA PROPERTY AUTOMOC ON) +target_link_libraries(skipMocA ${QT_LIBRARIES}) +# AUTOMOC and AUTOUIC enabled +add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocB PROPERTY AUTOMOC ON) +set_property(TARGET skipMocB PROPERTY AUTOUIC ON) +target_link_libraries(skipMocB ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/skipSource/qItemA.cpp b/Tests/QtAutogen/MocSkipSource/qItemA.cpp index 522c2c758..522c2c758 100644 --- a/Tests/QtAutogen/skipSource/qItemA.cpp +++ b/Tests/QtAutogen/MocSkipSource/qItemA.cpp diff --git a/Tests/QtAutogen/skipSource/qItemA.hpp b/Tests/QtAutogen/MocSkipSource/qItemA.hpp index d295faf3a..d295faf3a 100644 --- a/Tests/QtAutogen/skipSource/qItemA.hpp +++ b/Tests/QtAutogen/MocSkipSource/qItemA.hpp diff --git a/Tests/QtAutogen/skipSource/qItemB.cpp b/Tests/QtAutogen/MocSkipSource/qItemB.cpp index 636e15dfe..636e15dfe 100644 --- a/Tests/QtAutogen/skipSource/qItemB.cpp +++ b/Tests/QtAutogen/MocSkipSource/qItemB.cpp diff --git a/Tests/QtAutogen/skipSource/qItemB.hpp b/Tests/QtAutogen/MocSkipSource/qItemB.hpp index 177591525..177591525 100644 --- a/Tests/QtAutogen/skipSource/qItemB.hpp +++ b/Tests/QtAutogen/MocSkipSource/qItemB.hpp diff --git a/Tests/QtAutogen/MocSkipSource/qItemC.cpp b/Tests/QtAutogen/MocSkipSource/qItemC.cpp new file mode 100644 index 000000000..622f2829e --- /dev/null +++ b/Tests/QtAutogen/MocSkipSource/qItemC.cpp @@ -0,0 +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/qItemC.hpp b/Tests/QtAutogen/MocSkipSource/qItemC.hpp index f06bda269..f06bda269 100644 --- a/Tests/QtAutogen/skipSource/qItemC.hpp +++ b/Tests/QtAutogen/MocSkipSource/qItemC.hpp diff --git a/Tests/QtAutogen/MocSkipSource/qItemD.cpp b/Tests/QtAutogen/MocSkipSource/qItemD.cpp new file mode 100644 index 000000000..fe0f4e4da --- /dev/null +++ b/Tests/QtAutogen/MocSkipSource/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/MocSkipSource/qItemD.hpp b/Tests/QtAutogen/MocSkipSource/qItemD.hpp new file mode 100644 index 000000000..99e0acbed --- /dev/null +++ b/Tests/QtAutogen/MocSkipSource/qItemD.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMD_HPP +#define QITEMD_HPP + +#include <QObject> + +class QItemD : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/MocSkipSource/skipMoc.cpp b/Tests/QtAutogen/MocSkipSource/skipMoc.cpp new file mode 100644 index 000000000..c91533410 --- /dev/null +++ b/Tests/QtAutogen/MocSkipSource/skipMoc.cpp @@ -0,0 +1,16 @@ + +#include "qItemA.hpp" +#include "qItemB.hpp" +#include "qItemC.hpp" +#include "qItemD.hpp" + +int main(int, char**) +{ + QItemA itemA; + QItemB itemB; + QItemC itemC; + QItemD itemD; + + // Fails to link if the symbol is not present. + return 0; +} diff --git a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt new file mode 100644 index 000000000..ec204e775 --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.10) +project(ObjectLibrary) +include("../AutogenCoreTest.cmake") + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) + +# Object library a defined in a subdirectory +add_subdirectory(a) + +# Object library b defined locally +include_directories(b) +add_library(b OBJECT b/classb.cpp) +target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES}) + +# Executable with OBJECT library generator expressions +add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>) +target_link_libraries(someProgram ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt new file mode 100644 index 000000000..fe76ac32c --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(a OBJECT classa.cpp) +target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES}) diff --git a/Tests/QtAutogen/ObjectLibrary/a/classa.cpp b/Tests/QtAutogen/ObjectLibrary/a/classa.cpp new file mode 100644 index 000000000..a548652dd --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/a/classa.cpp @@ -0,0 +1,8 @@ +#include "classa.h" + +#include <QDebug> + +void ClassA::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/ObjectLibrary/a/classa.h b/Tests/QtAutogen/ObjectLibrary/a/classa.h new file mode 100644 index 000000000..fa5fed941 --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/a/classa.h @@ -0,0 +1,23 @@ +#ifndef CLASSA_H +#define CLASSA_H + +#include <QObject> +#include <QString> + +class ClassA : public QObject +{ + Q_OBJECT +public: + ClassA() + : m_member("Hello A") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/ObjectLibrary/b/classb.cpp b/Tests/QtAutogen/ObjectLibrary/b/classb.cpp new file mode 100644 index 000000000..e5cc2e77e --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/b/classb.cpp @@ -0,0 +1,8 @@ +#include "classb.h" + +#include <QDebug> + +void ClassB::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/ObjectLibrary/b/classb.h b/Tests/QtAutogen/ObjectLibrary/b/classb.h new file mode 100644 index 000000000..783bb48ce --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/b/classb.h @@ -0,0 +1,23 @@ +#ifndef CLASSB_H +#define CLASSB_H + +#include <QObject> +#include <QString> + +class ClassB : public QObject +{ + Q_OBJECT +public: + ClassB() + : m_member("Hello B") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/ObjectLibrary/main.cpp b/Tests/QtAutogen/ObjectLibrary/main.cpp new file mode 100644 index 000000000..cacf0fdae --- /dev/null +++ b/Tests/QtAutogen/ObjectLibrary/main.cpp @@ -0,0 +1,13 @@ +#include "a/classa.h" +#include "b/classb.h" + +int main(int argc, char** argv) +{ + ClassA a; + a.slotDoSomething(); + + ClassB b; + b.slotDoSomething(); + + return 0; +} diff --git a/Tests/QtAutogen/Parallel/CMakeLists.txt b/Tests/QtAutogen/Parallel/CMakeLists.txt new file mode 100644 index 000000000..299bcbfd7 --- /dev/null +++ b/Tests/QtAutogen/Parallel/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(Parallel) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallel ${PARALLEL_SRC}) +set_target_properties(parallel PROPERTIES AUTOGEN_PARALLEL "") +target_link_libraries(parallel ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/sameName/aaa/bbb/data.qrc b/Tests/QtAutogen/Parallel/aaa/bbb/data.qrc index 0ea353756..0ea353756 100644 --- a/Tests/QtAutogen/sameName/aaa/bbb/data.qrc +++ b/Tests/QtAutogen/Parallel/aaa/bbb/data.qrc diff --git a/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp b/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp new file mode 100644 index 000000000..850206f6b --- /dev/null +++ b/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" + +namespace aaa { +namespace bbb { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + MocLocal obj; +} +} +} + +#include "aaa/bbb/item.moc" diff --git a/Tests/QtAutogen/sameName/aaa/bbb/item.hpp b/Tests/QtAutogen/Parallel/aaa/bbb/item.hpp index 085504385..085504385 100644 --- a/Tests/QtAutogen/sameName/aaa/bbb/item.hpp +++ b/Tests/QtAutogen/Parallel/aaa/bbb/item.hpp diff --git a/Tests/QtAutogen/sameName/aaa/data.qrc b/Tests/QtAutogen/Parallel/aaa/data.qrc index 379af60c8..379af60c8 100644 --- a/Tests/QtAutogen/sameName/aaa/data.qrc +++ b/Tests/QtAutogen/Parallel/aaa/data.qrc diff --git a/Tests/QtAutogen/Parallel/aaa/item.cpp b/Tests/QtAutogen/Parallel/aaa/item.cpp new file mode 100644 index 000000000..e35d3d128 --- /dev/null +++ b/Tests/QtAutogen/Parallel/aaa/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" +// Include ui_view.h only in header + +namespace aaa { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewAAA ui; + MocLocal obj; +} +} + +#include "aaa/item.moc" diff --git a/Tests/QtAutogen/sameName/aaa/item.hpp b/Tests/QtAutogen/Parallel/aaa/item.hpp index b63466f6d..875f72fdb 100644 --- a/Tests/QtAutogen/sameName/aaa/item.hpp +++ b/Tests/QtAutogen/Parallel/aaa/item.hpp @@ -2,6 +2,8 @@ #define AAA_ITEM_HPP #include <QObject> +// Include ui_view.h only in header +#include <aaa/ui_view.h> namespace aaa { diff --git a/Tests/QtAutogen/Parallel/aaa/view.ui b/Tests/QtAutogen/Parallel/aaa/view.ui new file mode 100644 index 000000000..0f0998006 --- /dev/null +++ b/Tests/QtAutogen/Parallel/aaa/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewAAA</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/bbb/aaa/data.qrc b/Tests/QtAutogen/Parallel/bbb/aaa/data.qrc index da980091a..da980091a 100644 --- a/Tests/QtAutogen/sameName/bbb/aaa/data.qrc +++ b/Tests/QtAutogen/Parallel/bbb/aaa/data.qrc diff --git a/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp b/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp new file mode 100644 index 000000000..7ad01c3ef --- /dev/null +++ b/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" + +namespace bbb { +namespace aaa { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + MocLocal obj; +} +} +} + +#include "bbb/aaa/item.moc" diff --git a/Tests/QtAutogen/sameName/bbb/aaa/item.hpp b/Tests/QtAutogen/Parallel/bbb/aaa/item.hpp index be07ca84c..be07ca84c 100644 --- a/Tests/QtAutogen/sameName/bbb/aaa/item.hpp +++ b/Tests/QtAutogen/Parallel/bbb/aaa/item.hpp diff --git a/Tests/QtAutogen/sameName/bbb/data.qrc b/Tests/QtAutogen/Parallel/bbb/data.qrc index 5b080f5fa..5b080f5fa 100644 --- a/Tests/QtAutogen/sameName/bbb/data.qrc +++ b/Tests/QtAutogen/Parallel/bbb/data.qrc diff --git a/Tests/QtAutogen/Parallel/bbb/item.cpp b/Tests/QtAutogen/Parallel/bbb/item.cpp new file mode 100644 index 000000000..9ef128ed0 --- /dev/null +++ b/Tests/QtAutogen/Parallel/bbb/item.cpp @@ -0,0 +1,23 @@ +#include "item.hpp" +// Include ui_view.h only in source +#include <bbb/ui_view.h> + +namespace bbb { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewBBB ui; + MocLocal obj; +} +} + +#include "bbb/item.moc" diff --git a/Tests/QtAutogen/sameName/bbb/item.hpp b/Tests/QtAutogen/Parallel/bbb/item.hpp index 5b7f9850b..d39a9d711 100644 --- a/Tests/QtAutogen/sameName/bbb/item.hpp +++ b/Tests/QtAutogen/Parallel/bbb/item.hpp @@ -2,6 +2,7 @@ #define BBB_ITEM_HPP #include <QObject> +// Include ui_view.h only in source namespace bbb { diff --git a/Tests/QtAutogen/Parallel/bbb/view.ui b/Tests/QtAutogen/Parallel/bbb/view.ui new file mode 100644 index 000000000..a8f506e88 --- /dev/null +++ b/Tests/QtAutogen/Parallel/bbb/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewBBB</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/ccc/data.qrc b/Tests/QtAutogen/Parallel/ccc/data.qrc index f934c39b9..f934c39b9 100644 --- a/Tests/QtAutogen/sameName/ccc/data.qrc +++ b/Tests/QtAutogen/Parallel/ccc/data.qrc diff --git a/Tests/QtAutogen/Parallel/ccc/item.cpp b/Tests/QtAutogen/Parallel/ccc/item.cpp new file mode 100644 index 000000000..ab8a2817b --- /dev/null +++ b/Tests/QtAutogen/Parallel/ccc/item.cpp @@ -0,0 +1,25 @@ +#include "item.hpp" +// Include ui_view.h in source and header +#include <ccc/ui_view.h> + +namespace ccc { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewCCC ui; + MocLocal obj; +} +} + +// Include own moc files +#include "ccc/item.moc" +#include "moc_item.cpp" diff --git a/Tests/QtAutogen/sameName/ccc/item.hpp b/Tests/QtAutogen/Parallel/ccc/item.hpp index 96fcc245c..20d9dd978 100644 --- a/Tests/QtAutogen/sameName/ccc/item.hpp +++ b/Tests/QtAutogen/Parallel/ccc/item.hpp @@ -2,6 +2,8 @@ #define CCC_ITEM_HPP #include <QObject> +// Include ui_view.h in source and header +#include <ccc/ui_view.h> namespace ccc { diff --git a/Tests/QtAutogen/Parallel/ccc/view.ui b/Tests/QtAutogen/Parallel/ccc/view.ui new file mode 100644 index 000000000..7989c6973 --- /dev/null +++ b/Tests/QtAutogen/Parallel/ccc/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewCCC</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/data.qrc b/Tests/QtAutogen/Parallel/data.qrc index 4ce0b4ec1..4ce0b4ec1 100644 --- a/Tests/QtAutogen/sameName/data.qrc +++ b/Tests/QtAutogen/Parallel/data.qrc diff --git a/Tests/QtAutogen/Parallel/item.cpp b/Tests/QtAutogen/Parallel/item.cpp new file mode 100644 index 000000000..3d1fbe7cf --- /dev/null +++ b/Tests/QtAutogen/Parallel/item.cpp @@ -0,0 +1,20 @@ +#include "item.hpp" +// Include ui_view.h in source and header +#include <ui_view.h> + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_View ui; + MocLocal obj; +} + +#include "item.moc" diff --git a/Tests/QtAutogen/Parallel/item.hpp b/Tests/QtAutogen/Parallel/item.hpp new file mode 100644 index 000000000..75e83f483 --- /dev/null +++ b/Tests/QtAutogen/Parallel/item.hpp @@ -0,0 +1,15 @@ +#ifndef ITEM_HPP +#define ITEM_HPP + +#include <QObject> +// Include ui_view.h in source and header +#include <ui_view.h> + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/sameName/main.cpp b/Tests/QtAutogen/Parallel/main.cpp index a4ffcb350..a4ffcb350 100644 --- a/Tests/QtAutogen/sameName/main.cpp +++ b/Tests/QtAutogen/Parallel/main.cpp diff --git a/Tests/QtAutogen/Parallel/parallel.cmake b/Tests/QtAutogen/Parallel/parallel.cmake new file mode 100644 index 000000000..551bcd82b --- /dev/null +++ b/Tests/QtAutogen/Parallel/parallel.cmake @@ -0,0 +1,24 @@ +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + + +set(PBASE ${CMAKE_CURRENT_LIST_DIR}) +set(PARALLEL_SRC + ${PBASE}/aaa/bbb/item.cpp + ${PBASE}/aaa/bbb/data.qrc + ${PBASE}/aaa/item.cpp + ${PBASE}/aaa/data.qrc + + ${PBASE}/bbb/aaa/item.cpp + ${PBASE}/bbb/aaa/data.qrc + ${PBASE}/bbb/item.cpp + ${PBASE}/bbb/data.qrc + + ${PBASE}/ccc/item.cpp + ${PBASE}/ccc/data.qrc + + ${PBASE}/item.cpp + ${PBASE}/data.qrc + ${PBASE}/main.cpp +) diff --git a/Tests/QtAutogen/Parallel/view.ui b/Tests/QtAutogen/Parallel/view.ui new file mode 100644 index 000000000..2ffe7344c --- /dev/null +++ b/Tests/QtAutogen/Parallel/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/Parallel1/CMakeLists.txt b/Tests/QtAutogen/Parallel1/CMakeLists.txt new file mode 100644 index 000000000..5c7d547df --- /dev/null +++ b/Tests/QtAutogen/Parallel1/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(Parallel1) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallel1 ${PARALLEL_SRC}) +set_target_properties(parallel1 PROPERTIES AUTOGEN_PARALLEL 1) +target_link_libraries(parallel1 ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/Parallel2/CMakeLists.txt b/Tests/QtAutogen/Parallel2/CMakeLists.txt new file mode 100644 index 000000000..668aea4bd --- /dev/null +++ b/Tests/QtAutogen/Parallel2/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(Parallel2) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallel2 ${PARALLEL_SRC}) +set_target_properties(parallel2 PROPERTIES AUTOGEN_PARALLEL 2) +target_link_libraries(parallel2 ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/Parallel3/CMakeLists.txt b/Tests/QtAutogen/Parallel3/CMakeLists.txt new file mode 100644 index 000000000..5c50f5ee5 --- /dev/null +++ b/Tests/QtAutogen/Parallel3/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(Parallel3) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallel3 ${PARALLEL_SRC}) +set_target_properties(parallel3 PROPERTIES AUTOGEN_PARALLEL 3) +target_link_libraries(parallel3 ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/Parallel4/CMakeLists.txt b/Tests/QtAutogen/Parallel4/CMakeLists.txt new file mode 100644 index 000000000..2c40c6a67 --- /dev/null +++ b/Tests/QtAutogen/Parallel4/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(Parallel4) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallel4 ${PARALLEL_SRC}) +set_target_properties(parallel4 PROPERTIES AUTOGEN_PARALLEL 4) +target_link_libraries(parallel4 ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt new file mode 100644 index 000000000..cddece37a --- /dev/null +++ b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(ParallelAUTO) +include("../AutogenGuiTest.cmake") + +# Test different values for AUTOGEN_PARALLEL +include("../Parallel/parallel.cmake") + +add_executable(parallelAUTO ${PARALLEL_SRC}) +set_target_properties(parallelAUTO PROPERTIES AUTOGEN_PARALLEL "AUTO") +target_link_libraries(parallelAUTO ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/RccEmpty/CMakeLists.txt b/Tests/QtAutogen/RccEmpty/CMakeLists.txt new file mode 100644 index 000000000..a8e2af1b6 --- /dev/null +++ b/Tests/QtAutogen/RccEmpty/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) +project(RccEmpty) +include("../AutogenCoreTest.cmake") + +# Test AUTORCC on a .qrc file with no resource files +add_executable(rccEmpty rccEmpty.cpp rccEmptyRes.qrc) +set_property(TARGET rccEmpty PROPERTY AUTORCC ON) +target_link_libraries(rccEmpty ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/rccEmpty.cpp b/Tests/QtAutogen/RccEmpty/rccEmpty.cpp index 7f2c52786..7f2c52786 100644 --- a/Tests/QtAutogen/rccEmpty.cpp +++ b/Tests/QtAutogen/RccEmpty/rccEmpty.cpp diff --git a/Tests/QtAutogen/rccEmptyRes.qrc b/Tests/QtAutogen/RccEmpty/rccEmptyRes.qrc index 4ca9cd583..4ca9cd583 100644 --- a/Tests/QtAutogen/rccEmptyRes.qrc +++ b/Tests/QtAutogen/RccEmpty/rccEmptyRes.qrc diff --git a/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt new file mode 100644 index 000000000..61b9601a2 --- /dev/null +++ b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) +project(RccOffMocLibrary) +include("../AutogenCoreTest.cmake") + +# Add not_generated_file.qrc to the source list to get the file-level +# dependency, but don't generate a c++ file from it. Disable the AUTORCC +# feature for this target. This tests that qrc files in the sources don't +# have an effect on generation if AUTORCC is off. +add_library(empty STATIC empty.cpp not_generated_file.qrc) +set_target_properties(empty PROPERTIES AUTORCC OFF) +set_target_properties(empty PROPERTIES AUTOMOC TRUE) +target_link_libraries(empty no_link_language) +add_library(no_link_language STATIC empty.h) +set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) +# Pass Qt compiler features to targets that don't link against Qt +target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) +target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) diff --git a/Tests/QtAutogen/empty.cpp b/Tests/QtAutogen/RccOffMocLibrary/empty.cpp index ab32cf6c8..ab32cf6c8 100644 --- a/Tests/QtAutogen/empty.cpp +++ b/Tests/QtAutogen/RccOffMocLibrary/empty.cpp diff --git a/Tests/QtAutogen/empty.h b/Tests/QtAutogen/RccOffMocLibrary/empty.h index 6bdd2ac89..6bdd2ac89 100644 --- a/Tests/QtAutogen/empty.h +++ b/Tests/QtAutogen/RccOffMocLibrary/empty.h diff --git a/Tests/QtAutogen/not_generated_file.qrc b/Tests/QtAutogen/RccOffMocLibrary/not_generated_file.qrc index c7698343a..c7698343a 100644 --- a/Tests/QtAutogen/not_generated_file.qrc +++ b/Tests/QtAutogen/RccOffMocLibrary/not_generated_file.qrc diff --git a/Tests/QtAutogen/RccOnly/CMakeLists.txt b/Tests/QtAutogen/RccOnly/CMakeLists.txt new file mode 100644 index 000000000..f3776f575 --- /dev/null +++ b/Tests/QtAutogen/RccOnly/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) +project(RccOnly) +include("../AutogenCoreTest.cmake") + +# Test AUTORCC being enabled only +add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc) +set_property(TARGET rccOnly PROPERTY AUTORCC ON) +target_link_libraries(rccOnly ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/rccOnly.cpp b/Tests/QtAutogen/RccOnly/rccOnly.cpp index 61c7bf4ed..61c7bf4ed 100644 --- a/Tests/QtAutogen/rccOnly.cpp +++ b/Tests/QtAutogen/RccOnly/rccOnly.cpp diff --git a/Tests/QtAutogen/rccOnlyRes.qrc b/Tests/QtAutogen/RccOnly/rccOnlyRes.qrc index 555134877..555134877 100644 --- a/Tests/QtAutogen/rccOnlyRes.qrc +++ b/Tests/QtAutogen/RccOnly/rccOnlyRes.qrc diff --git a/Tests/QtAutogen/RccSkipSource/CMakeLists.txt b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt new file mode 100644 index 000000000..42232744f --- /dev/null +++ b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) +project(RccSkipSource) +include("../AutogenCoreTest.cmake") + +# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target +set(skipRccSources + skipRcc.cpp + skipRccBad1.qrc + skipRccBad2.qrc + skipRccGood.qrc +) +set_property(SOURCE skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON) +set_property(SOURCE skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON) +# AUTORCC enabled +add_executable(skipRccA ${skipRccSources}) +set_property(TARGET skipRccA PROPERTY AUTORCC ON) +target_link_libraries(skipRccA ${QT_LIBRARIES}) +# AUTORCC, AUTOUIC and AUTOMOC enabled +add_executable(skipRccB ${skipRccSources}) +set_property(TARGET skipRccB PROPERTY AUTORCC ON) +set_property(TARGET skipRccB PROPERTY AUTOUIC ON) +set_property(TARGET skipRccB PROPERTY AUTOMOC ON) +target_link_libraries(skipRccB ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/skipRcc.cpp b/Tests/QtAutogen/RccSkipSource/skipRcc.cpp index ec5711088..ec5711088 100644 --- a/Tests/QtAutogen/skipRcc.cpp +++ b/Tests/QtAutogen/RccSkipSource/skipRcc.cpp diff --git a/Tests/QtAutogen/skipSource/skipRccBad1.qrc b/Tests/QtAutogen/RccSkipSource/skipRccBad1.qrc index 6cbd9ed18..6cbd9ed18 100644 --- a/Tests/QtAutogen/skipSource/skipRccBad1.qrc +++ b/Tests/QtAutogen/RccSkipSource/skipRccBad1.qrc diff --git a/Tests/QtAutogen/skipSource/skipRccBad2.qrc b/Tests/QtAutogen/RccSkipSource/skipRccBad2.qrc index b32c5896c..b32c5896c 100644 --- a/Tests/QtAutogen/skipSource/skipRccBad2.qrc +++ b/Tests/QtAutogen/RccSkipSource/skipRccBad2.qrc diff --git a/Tests/QtAutogen/skipSource/skipRccGood.qrc b/Tests/QtAutogen/RccSkipSource/skipRccGood.qrc index 21a94b0c5..21a94b0c5 100644 --- a/Tests/QtAutogen/skipSource/skipRccGood.qrc +++ b/Tests/QtAutogen/RccSkipSource/skipRccGood.qrc diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt new file mode 100644 index 000000000..9b32e5951 --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -0,0 +1,102 @@ +cmake_minimum_required(VERSION 3.10) +project(RerunMocBasic) +include("../AutogenCoreTest.cmake") + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") +set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic") +set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic") + +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + + +# Initial build +configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) +try_compile(MOC_RERUN + "${mocBasicBinDir}" + "${mocBasicSrcDir}" + MocBasic + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}") +endif() + +# Get name of the output binary +file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8) +list(GET mocBasicList 0 mocBasicBin) + +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamp(Before) +sleep() +message(STATUS "Touching binary file to ensure a new timestamps") +file(TOUCH_NOCREATE "${mocBasicBin}") +acquire_timestamp(After) +require_change() + + +# - Ensure that the timestamp will change +# - Change header file content +# - Rebuild +acquire_timestamp(Before) +sleep() +message(STATUS "Changing the header content for a MOC re-run") +configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) +sleep() +rebuild(2) +acquire_timestamp(After) +require_change() + + +# - Ensure that the timestamp would change +# - Change nothing +# - Rebuild +acquire_timestamp(Before) +sleep() +message(STATUS "Changing nothing for no MOC re-run") +rebuild(3) +acquire_timestamp(After) +require_change_not() diff --git a/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt new file mode 100644 index 000000000..6a9f5507c --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.10) +project(MocBasic) +include("../../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +# Generated source file +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp +) + +add_executable(mocBasic + ${CMAKE_CURRENT_BINARY_DIR}/test1.h + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + res1.qrc +) +target_include_directories(mocBasic PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(mocBasic ${QT_QTCORE_TARGET}) +# Write target name to text file +add_custom_command(TARGET mocBasic POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocBasic>" > mocBasic.txt +) diff --git a/Tests/QtAutogen/mocRerun/input.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt index da627624b..da627624b 100644 --- a/Tests/QtAutogen/mocRerun/input.txt +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt diff --git a/Tests/QtAutogen/mocRerun/main.cpp.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in index b37ff61e2..9d7ea37ae 100644 --- a/Tests/QtAutogen/mocRerun/main.cpp.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in @@ -1,5 +1,7 @@ #include "test1.h" +extern int qInitResources_res1(); + class Test2 : public QObject { Q_OBJECT @@ -9,6 +11,9 @@ public slots: int main() { + // Fails to link if the rcc generated symbol is not present. + qInitResources_res1(); + Test1 test1; Test2 test2; diff --git a/Tests/QtAutogen/mocRerun/res1.qrc b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc index fb804b5ec..fb804b5ec 100644 --- a/Tests/QtAutogen/mocRerun/res1.qrc +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc diff --git a/Tests/QtAutogen/mocRerun/test1a.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in index a335046ba..a335046ba 100644 --- a/Tests/QtAutogen/mocRerun/test1a.h.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in diff --git a/Tests/QtAutogen/mocRerun/test1b.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in index 6128eeba1..6128eeba1 100644 --- a/Tests/QtAutogen/mocRerun/test1b.h.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in diff --git a/Tests/QtAutogen/RerunMocBasic/dummy.cpp b/Tests/QtAutogen/RerunMocBasic/dummy.cpp new file mode 100644 index 000000000..4837a76b8 --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt new file mode 100644 index 000000000..e1951f1d0 --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -0,0 +1,134 @@ +cmake_minimum_required(VERSION 3.10) +project(RerunMocPlugin) +include("../AutogenCoreTest.cmake") + +# Tests Q_PLUGIN_METADATA and CMAKE_AUTOMOC_DEPEND_FILTERS +# json file change detection + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") +set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin") +set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin") + +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(STATUS "As expected the file ${pl${PLG}File} changed.") + else() + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + endif() +endmacro() + +macro(require_change_not PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + else() + message(STATUS "As expected the file ${pl${PLG}File} did not change.") + endif() +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}") + file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}") + file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}") + file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}") + file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}") +endmacro() + + +# Initial build +try_compile(MOC_PLUGIN + "${mocPlugBinDir}" + "${mocPlugSrcDir}" + MocPlugin + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT MOC_PLUGIN) + message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}") +endif() + +# Get names of the output binaries +find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) + +# To avoid a race condition where the library has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - rebuild library to ensure it has a new timestamp +sleep() +message(STATUS "Rebuilding library files to ensure new timestamps") +rebuild(1) + + +# - Ensure that the timestamp will change. +# - Change the json files referenced by Q_PLUGIN_METADATA +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files.") +configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") +configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") +configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json") +sleep() +rebuild(2) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows: +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) +endif() + + +# - Ensure that the timestamp will change. +# - Change the json files referenced by A_CUSTOM_MACRO +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files") +configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") +configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") +configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json") +sleep() +rebuild(3) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) +endif() diff --git a/Tests/QtAutogen/mocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt index f80aa2934..506828976 100644 --- a/Tests/QtAutogen/mocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt @@ -1,26 +1,24 @@ -cmake_minimum_required(VERSION 3.8) -project(mocPlugin CXX) +cmake_minimum_required(VERSION 3.10) +project(MocPlugin) +include("../../AutogenGuiTest.cmake") + +if (QT_TEST_VERSION LESS 5) + message(SEND_ERROR "Qt 5 or higher required.") +endif() set(CMAKE_AUTOMOC_DEPEND_FILTERS "A_CUSTOM_MACRO" "[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\"" - ) - -if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") -endif() -find_package(Qt5Widgets REQUIRED) - -if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) - add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) -endif() +) configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json) -configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json) +configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json) +configure_file(jsonIn/StyleE.json jsonFiles/StyleE.json) +configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json) -# Enable automoc +# Enable AUTOMOC set(CMAKE_AUTOMOC TRUE) include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles") diff --git a/Tests/QtAutogen/mocPlugin/StyleA.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.cpp index b5e87533c..b5e87533c 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleA.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp index 1b6154d16..e1fdf0bbd 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp @@ -1,13 +1,14 @@ #ifndef STYLEA_HPP #define STYLEA_HPP -#include "StyleCommon.hpp" #include <QStylePlugin> +#include "UtilityMacros.hpp" + class StyleA : public QStylePlugin { Q_OBJECT - // Json file in local directory + // Json file in source local directory Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json") A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg) public: diff --git a/Tests/QtAutogen/mocPlugin/StyleA.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.json index cc3395369..cc3395369 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.json +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.json diff --git a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA_Custom.json index cc3395369..cc3395369 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA_Custom.json diff --git a/Tests/QtAutogen/mocPlugin/StyleB.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.cpp index 17d440035..17d440035 100644 --- a/Tests/QtAutogen/mocPlugin/StyleB.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleB.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp index 163c9b20a..7550d0c3b 100644 --- a/Tests/QtAutogen/mocPlugin/StyleB.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp @@ -1,13 +1,14 @@ #ifndef STYLEB_HPP #define STYLEB_HPP -#include "StyleCommon.hpp" #include <QStylePlugin> +#include "UtilityMacros.hpp" + class StyleB : public QStylePlugin { Q_OBJECT - // Json file in local subdirectory + // Json file in source local subdirectory Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json") A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg) public: diff --git a/Tests/QtAutogen/mocPlugin/StyleC.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.cpp index 37e756487..37e756487 100644 --- a/Tests/QtAutogen/mocPlugin/StyleC.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleC.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp index 52a887acf..ec71becda 100644 --- a/Tests/QtAutogen/mocPlugin/StyleC.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp @@ -1,9 +1,10 @@ #ifndef STYLEC_HPP #define STYLEC_HPP -#include "StyleCommon.hpp" #include <QStylePlugin> +#include "UtilityMacros.hpp" + class StyleC : public QStylePlugin { Q_OBJECT diff --git a/Tests/QtAutogen/mocPlugin/StyleD.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp index 7e4b121fc..7e4b121fc 100644 --- a/Tests/QtAutogen/mocPlugin/StyleD.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleD.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp index df8a4399d..3c093b914 100644 --- a/Tests/QtAutogen/mocPlugin/StyleD.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp @@ -1,9 +1,10 @@ #ifndef STYLED_HPP #define STYLED_HPP -#include "StyleCommon.hpp" #include <QStylePlugin> +#include "UtilityMacros.hpp" + class StyleD : public QStylePlugin { Q_OBJECT diff --git a/Tests/QtAutogen/mocPlugin/StyleE.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp index 8fc9a7f68..344831969 100644 --- a/Tests/QtAutogen/mocPlugin/StyleE.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp @@ -4,3 +4,6 @@ QStyle* StyleE::create(const QString& key) { return 0; } + +// AUTOMOC the StyleEInclude.hpp header +#include "moc_StyleEInclude.cpp" diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp new file mode 100644 index 000000000..a0690343d --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp @@ -0,0 +1,10 @@ +#ifndef STYLEE_HPP +#define STYLEE_HPP + +// The included file is not in the sources list and won't be detected by +// AUTOMOC source file with the same base name. +// It is registered to AUTOMOCed via a moc_<NAME>.cpp include in StyleE.cpp +// though. +#include "StyleEInclude.hpp" + +#endif diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp new file mode 100644 index 000000000..5f10fb4a0 --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp @@ -0,0 +1,18 @@ +#ifndef STYLEE_INCLUDE_HPP +#define STYLEE_INCLUDE_HPP + +#include <QStylePlugin> + +#include "UtilityMacros.hpp" + +class StyleE : public QStylePlugin +{ + Q_OBJECT + // Json files in global root directory + Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json") + A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp index f1a7ec60d..53a4284ee 100644 --- a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp @@ -1,5 +1,5 @@ -#ifndef STYLECOMMON_HPP -#define STYLECOMMON_HPP +#ifndef UTILITYMACROS_HPP +#define UTILITYMACROS_HPP // Empty test macro definition #define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations) diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json new file mode 100644 index 000000000..cd155dc0e --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json @@ -0,0 +1 @@ +{ "Keys": [ "Red", "Green" ] } diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB_Custom.json index 129cac41f..129cac41f 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB_Custom.json diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleC.json index 119aaa4b7..119aaa4b7 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleC.json diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleD.json index 732c547ab..732c547ab 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleD.json diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json new file mode 100644 index 000000000..5412c94f6 --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json @@ -0,0 +1 @@ +{ "Keys": [ "Floor", "Ceiling" ] } diff --git a/Tests/QtAutogen/mocPlugin/main.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/main.cpp index 3ba2ddc6d..3ba2ddc6d 100644 --- a/Tests/QtAutogen/mocPlugin/main.cpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/main.cpp diff --git a/Tests/QtAutogen/RerunMocPlugin/dummy.cpp b/Tests/QtAutogen/RerunMocPlugin/dummy.cpp new file mode 100644 index 000000000..4837a76b8 --- /dev/null +++ b/Tests/QtAutogen/RerunMocPlugin/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt new file mode 100644 index 000000000..33c01acbe --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 3.11.2) +project(RerunRccConfigChange) +include("../AutogenCoreTest.cmake") + +# Tests rcc rebuilding after a configuration change + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt +set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange") +set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange") + +# Rebuild macro +macro(rebuild CFG) + message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}" + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "${CFG} build of rccConfigChange failed.") + else() + message(STATUS "${CFG} build of rccConfigChange finished.") + endif() +endmacro() + +# Initial build +try_compile(RCC_DEPENDS + "${rccDepBD}" + "${rccDepSD}" + RccConfigChange + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT RCC_DEPENDS) + message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}") +endif() + +# Rebuild: Release +rebuild(Release) + +# Rebuild: Debug +rebuild(Debug) diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt new file mode 100644 index 000000000..e2dd0ac38 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.11.2) +project(RccConfigChange) +include("../../AutogenCoreTest.cmake") + +# Enable AUTORCC for all targets +set(CMAKE_AUTORCC ON) + +# Initial resource files setup +configure_file(resGen/input1.txt.in resGen/input1.txt COPYONLY) +configure_file(resGen/input2.txt.in resGen/input2.txt COPYONLY) +configure_file(resGen.qrc.in resGen.qrc COPYONLY) + +# Generated qrc file with dependency +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc +) + +# Target that uses a plain .qrc file +add_executable(rccConfigChangePlain main.cpp resPlain.qrc) +target_link_libraries(rccConfigChangePlain ${QT_QTCORE_TARGET}) + +# Target that uses a GENERATED .qrc file +add_executable(rccConfigChangeGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc ) +target_link_libraries(rccConfigChangeGen ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/rccDepends/main.cpp b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp index 766b7751b..766b7751b 100644 --- a/Tests/QtAutogen/rccDepends/main.cpp +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in new file mode 100644 index 000000000..967477252 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsGenerated"> + <file>resGen/input1.txt</file> + <file>resGen/input2.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc new file mode 100644 index 000000000..e448726a0 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsPlain"> + <file>resPlain/input1.txt</file> + <file>resPlain/input2.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt new file mode 100644 index 000000000..03969c6a5 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt @@ -0,0 +1 @@ +Plain resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt new file mode 100644 index 000000000..03969c6a5 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt @@ -0,0 +1 @@ +Plain resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp new file mode 100644 index 000000000..4837a76b8 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt new file mode 100644 index 000000000..1301550f2 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -0,0 +1,153 @@ +cmake_minimum_required(VERSION 3.10) +project(RerunRccDepends) +include("../AutogenCoreTest.cmake") + +# Tests rcc rebuilding when a resource file changes +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") +set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends") +set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends") + +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}") + file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName} of rccDepends.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} of rccDepends failed.") + else() + message(STATUS "Build ${buildName} of rccDepends finished.") + endif() +endmacro() + +macro(require_change type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.") + else() + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + endif() +endmacro() + +macro(require_change_not type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + else() + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.") + endif() +endmacro() + + +# Initial configuration +configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) +configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) + +# Initial build +try_compile(RCC_DEPENDS + "${rccDepBD}" + "${rccDepSD}" + RccDepends + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT RCC_DEPENDS) + message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}") +endif() + +# Get name of the output binaries +file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8) +file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8) +list(GET targetListPlain 0 rccDepBinPlain) +list(GET targetListGen 0 rccDepBinGenerated) +message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") +message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}") + +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamps(Before) +sleep() +message(STATUS "Touching binary files to ensure new timestamps") +file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}") +acquire_timestamps(After) +require_change(Plain) +require_change(Generated) + + +# - Ensure that the timestamp will change +# - Change a resource files listed in the .qrc file +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a resource file listed in the .qrc file") +file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt") +sleep() +rebuild(2) +acquire_timestamps(After) +# - Test if timestamps changed +require_change(Plain) +require_change(Generated) + + +# - Ensure that the timestamp will change +# - Change the .qrc file +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing the .qrc file") +configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) +configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) +sleep() +rebuild(3) +acquire_timestamps(After) +# - Test if timestamps changed +require_change(Plain) +require_change(Generated) + + +# - Ensure that the timestamp will change +# - Change a newly added resource files listed in the .qrc file +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a newly added resource file listed in the .qrc file") +file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt") +sleep() +rebuild(4) +acquire_timestamps(After) +# - Test if timestamps changed +require_change(Plain) +require_change(Generated) + + +# - Ensure that the timestamp will change +# - Change nothing +# - Rebuild +acquire_timestamps(Before) +sleep() +message(STATUS "Changing nothing in the .qrc file") +rebuild(5) +acquire_timestamps(After) +# - Test if timestamps changed +require_change_not(Plain) +require_change_not(Generated) diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt new file mode 100644 index 000000000..150f849b3 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.10) +project(RccDepends) +include("../../AutogenCoreTest.cmake") + +# Enable AUTORCC for all targets +set(CMAKE_AUTORCC ON) + +# Initial resource files setup +configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY) +configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY) +configure_file(resGen/input.txt.in resGen/input.txt COPYONLY) +configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY) + +# Generated qrc file with dependency +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc +) + +# Target that uses a plain .qrc file +add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc) +target_link_libraries(rccDependsPlain ${QT_QTCORE_TARGET}) +add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt +) + +# Target that uses a GENERATED .qrc file +add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc ) +target_link_libraries(rccDependsGen ${QT_QTCORE_TARGET}) +add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt +) diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp new file mode 100644 index 000000000..766b7751b --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in new file mode 100644 index 000000000..c131a3460 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/TextsGenerated"> + <file>resGen/input.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in new file mode 100644 index 000000000..8c7e64311 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsGenerated"> + <file>resGen/input.txt</file> + <file alias="Added">resGen/inputAdded.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in new file mode 100644 index 000000000..a5e407a17 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in @@ -0,0 +1 @@ +Plaint resource input. diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in new file mode 100644 index 000000000..a5e407a17 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in @@ -0,0 +1 @@ +Plaint resource input. diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in new file mode 100644 index 000000000..c135d85b5 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/TextsPlain"> + <file>resPlain/input.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in new file mode 100644 index 000000000..186b6535a --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsPlain"> + <file>resPlain/input.txt</file> + <file alias="Added">resPlain/inputAdded.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/RerunRccDepends/dummy.cpp b/Tests/QtAutogen/RerunRccDepends/dummy.cpp new file mode 100644 index 000000000..4837a76b8 --- /dev/null +++ b/Tests/QtAutogen/RerunRccDepends/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogen/sameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index 4d2dcd9d2..cd29a2a85 100644 --- a/Tests/QtAutogen/sameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -1,3 +1,7 @@ +cmake_minimum_required(VERSION 3.10) +project(SameName) +include("../AutogenGuiTest.cmake") + # Test AUTOMOC and AUTORCC on source files with the same name # but in different subdirectories @@ -13,19 +17,28 @@ add_executable(sameName ccc/item.cpp ccc/data.qrc item.cpp + object.h + object.h++ + object.hpp + object.hxx + object_upper_ext.H data.qrc main.cpp ) target_link_libraries(sameName ${QT_LIBRARIES}) -set_target_properties(sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE) +set_target_properties(sameName PROPERTIES + AUTOMOC TRUE + AUTOUIC TRUE + AUTORCC TRUE +) # Set different compression levels -if (QT_TEST_VERSION STREQUAL 4) +if (QT_TEST_VERSION EQUAL 4) set(rccCompress "-compress") else() set(rccCompress "--compress") endif() -set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};0" ) -set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" ) -set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" ) -set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" ) +set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" ) +set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" ) +set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" ) +set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};4" ) diff --git a/Tests/QtAutogen/SameName/aaa/bbb/data.qrc b/Tests/QtAutogen/SameName/aaa/bbb/data.qrc new file mode 100644 index 000000000..0ea353756 --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/bbb/data.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="aaa/bbb"> + <file>item.hpp</file> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/aaa/bbb/item.cpp b/Tests/QtAutogen/SameName/aaa/bbb/item.cpp new file mode 100644 index 000000000..850206f6b --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/bbb/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" + +namespace aaa { +namespace bbb { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + MocLocal obj; +} +} +} + +#include "aaa/bbb/item.moc" diff --git a/Tests/QtAutogen/SameName/aaa/bbb/item.hpp b/Tests/QtAutogen/SameName/aaa/bbb/item.hpp new file mode 100644 index 000000000..085504385 --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/bbb/item.hpp @@ -0,0 +1,18 @@ +#ifndef AAA_BBB_ITEM_HPP +#define AAA_BBB_ITEM_HPP + +#include <QObject> + +namespace aaa { +namespace bbb { + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; +} +} + +#endif diff --git a/Tests/QtAutogen/SameName/aaa/data.qrc b/Tests/QtAutogen/SameName/aaa/data.qrc new file mode 100644 index 000000000..379af60c8 --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/data.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="aaa/"> + <file>item.hpp</file> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/aaa/item.cpp b/Tests/QtAutogen/SameName/aaa/item.cpp new file mode 100644 index 000000000..e35d3d128 --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" +// Include ui_view.h only in header + +namespace aaa { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewAAA ui; + MocLocal obj; +} +} + +#include "aaa/item.moc" diff --git a/Tests/QtAutogen/SameName/aaa/item.hpp b/Tests/QtAutogen/SameName/aaa/item.hpp new file mode 100644 index 000000000..875f72fdb --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/item.hpp @@ -0,0 +1,18 @@ +#ifndef AAA_ITEM_HPP +#define AAA_ITEM_HPP + +#include <QObject> +// Include ui_view.h only in header +#include <aaa/ui_view.h> + +namespace aaa { + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; +} + +#endif diff --git a/Tests/QtAutogen/SameName/aaa/view.ui b/Tests/QtAutogen/SameName/aaa/view.ui new file mode 100644 index 000000000..0f0998006 --- /dev/null +++ b/Tests/QtAutogen/SameName/aaa/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewAAA</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/SameName/bbb/aaa/data.qrc b/Tests/QtAutogen/SameName/bbb/aaa/data.qrc new file mode 100644 index 000000000..da980091a --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/aaa/data.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="bbb/aaa/"> + <file>item.hpp</file> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/bbb/aaa/item.cpp b/Tests/QtAutogen/SameName/bbb/aaa/item.cpp new file mode 100644 index 000000000..7ad01c3ef --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/aaa/item.cpp @@ -0,0 +1,22 @@ +#include "item.hpp" + +namespace bbb { +namespace aaa { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + MocLocal obj; +} +} +} + +#include "bbb/aaa/item.moc" diff --git a/Tests/QtAutogen/SameName/bbb/aaa/item.hpp b/Tests/QtAutogen/SameName/bbb/aaa/item.hpp new file mode 100644 index 000000000..be07ca84c --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/aaa/item.hpp @@ -0,0 +1,18 @@ +#ifndef BBB_AAA_ITEM_HPP +#define BBB_AAA_ITEM_HPP + +#include <QObject> + +namespace bbb { +namespace aaa { + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; +} +} + +#endif diff --git a/Tests/QtAutogen/SameName/bbb/data.qrc b/Tests/QtAutogen/SameName/bbb/data.qrc new file mode 100644 index 000000000..5b080f5fa --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/data.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="bbb/"> + <file>item.hpp</file> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/bbb/item.cpp b/Tests/QtAutogen/SameName/bbb/item.cpp new file mode 100644 index 000000000..9ef128ed0 --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/item.cpp @@ -0,0 +1,23 @@ +#include "item.hpp" +// Include ui_view.h only in source +#include <bbb/ui_view.h> + +namespace bbb { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewBBB ui; + MocLocal obj; +} +} + +#include "bbb/item.moc" diff --git a/Tests/QtAutogen/SameName/bbb/item.hpp b/Tests/QtAutogen/SameName/bbb/item.hpp new file mode 100644 index 000000000..d39a9d711 --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/item.hpp @@ -0,0 +1,17 @@ +#ifndef BBB_ITEM_HPP +#define BBB_ITEM_HPP + +#include <QObject> +// Include ui_view.h only in source + +namespace bbb { + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; +} + +#endif diff --git a/Tests/QtAutogen/SameName/bbb/view.ui b/Tests/QtAutogen/SameName/bbb/view.ui new file mode 100644 index 000000000..a8f506e88 --- /dev/null +++ b/Tests/QtAutogen/SameName/bbb/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewBBB</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/SameName/ccc/data.qrc b/Tests/QtAutogen/SameName/ccc/data.qrc new file mode 100644 index 000000000..f934c39b9 --- /dev/null +++ b/Tests/QtAutogen/SameName/ccc/data.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="ccc/"> + <file>item.hpp</file> + <file>item.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/ccc/item.cpp b/Tests/QtAutogen/SameName/ccc/item.cpp new file mode 100644 index 000000000..ab8a2817b --- /dev/null +++ b/Tests/QtAutogen/SameName/ccc/item.cpp @@ -0,0 +1,25 @@ +#include "item.hpp" +// Include ui_view.h in source and header +#include <ccc/ui_view.h> + +namespace ccc { + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_ViewCCC ui; + MocLocal obj; +} +} + +// Include own moc files +#include "ccc/item.moc" +#include "moc_item.cpp" diff --git a/Tests/QtAutogen/SameName/ccc/item.hpp b/Tests/QtAutogen/SameName/ccc/item.hpp new file mode 100644 index 000000000..20d9dd978 --- /dev/null +++ b/Tests/QtAutogen/SameName/ccc/item.hpp @@ -0,0 +1,18 @@ +#ifndef CCC_ITEM_HPP +#define CCC_ITEM_HPP + +#include <QObject> +// Include ui_view.h in source and header +#include <ccc/ui_view.h> + +namespace ccc { + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; +} + +#endif diff --git a/Tests/QtAutogen/SameName/ccc/view.ui b/Tests/QtAutogen/SameName/ccc/view.ui new file mode 100644 index 000000000..7989c6973 --- /dev/null +++ b/Tests/QtAutogen/SameName/ccc/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewCCC</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/SameName/data.qrc b/Tests/QtAutogen/SameName/data.qrc new file mode 100644 index 000000000..4ce0b4ec1 --- /dev/null +++ b/Tests/QtAutogen/SameName/data.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>main.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/SameName/item.cpp b/Tests/QtAutogen/SameName/item.cpp new file mode 100644 index 000000000..3d1fbe7cf --- /dev/null +++ b/Tests/QtAutogen/SameName/item.cpp @@ -0,0 +1,20 @@ +#include "item.hpp" +// Include ui_view.h in source and header +#include <ui_view.h> + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + +void Item::go() +{ + Ui_View ui; + MocLocal obj; +} + +#include "item.moc" diff --git a/Tests/QtAutogen/SameName/item.hpp b/Tests/QtAutogen/SameName/item.hpp new file mode 100644 index 000000000..75e83f483 --- /dev/null +++ b/Tests/QtAutogen/SameName/item.hpp @@ -0,0 +1,15 @@ +#ifndef ITEM_HPP +#define ITEM_HPP + +#include <QObject> +// Include ui_view.h in source and header +#include <ui_view.h> + +class Item : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/SameName/main.cpp b/Tests/QtAutogen/SameName/main.cpp new file mode 100644 index 000000000..19a6f6d1b --- /dev/null +++ b/Tests/QtAutogen/SameName/main.cpp @@ -0,0 +1,29 @@ +#include "aaa/bbb/item.hpp" +#include "aaa/item.hpp" +#include "bbb/aaa/item.hpp" +#include "bbb/item.hpp" +#include "ccc/item.hpp" +#include "item.hpp" +#include "object.h" +#include "object.h++" +#include "object.hpp" +#include "object.hxx" +#include "object_upper_ext.H" + +int main(int argv, char** args) +{ + // Item instances + ::Item item; + ::aaa::Item aaa_item; + ::aaa::bbb::Item aaa_bbb_item; + ::bbb::Item bbb_item; + ::bbb::aaa::Item bbb_aaa_item; + ::ccc::Item ccc_item; + // Object instances + ::Object_h obj_h; + ::Object_hplpl obj_hplpl; + ::Object_hpp obj_hpp; + ::Object_hxx obj_hxx; + ::Object_Upper_Ext_H obj_upper_ext_h; + return 0; +} diff --git a/Tests/QtAutogen/SameName/object.h b/Tests/QtAutogen/SameName/object.h new file mode 100644 index 000000000..86620941a --- /dev/null +++ b/Tests/QtAutogen/SameName/object.h @@ -0,0 +1,13 @@ +#ifndef OBJECT_H +#define OBJECT_H + +#include <QObject> + +class Object_h : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/SameName/object.h++ b/Tests/QtAutogen/SameName/object.h++ new file mode 100644 index 000000000..64222b7ec --- /dev/null +++ b/Tests/QtAutogen/SameName/object.h++ @@ -0,0 +1,13 @@ +#ifndef OBJECT_HPLPL +#define OBJECT_HPLPL + +#include <QObject> + +class Object_hplpl : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/SameName/object.hpp b/Tests/QtAutogen/SameName/object.hpp new file mode 100644 index 000000000..035050ec7 --- /dev/null +++ b/Tests/QtAutogen/SameName/object.hpp @@ -0,0 +1,13 @@ +#ifndef OBJECT_HPP +#define OBJECT_HPP + +#include <QObject> + +class Object_hpp : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/SameName/object.hxx b/Tests/QtAutogen/SameName/object.hxx new file mode 100644 index 000000000..c3c050f13 --- /dev/null +++ b/Tests/QtAutogen/SameName/object.hxx @@ -0,0 +1,13 @@ +#ifndef OBJECT_HXX +#define OBJECT_HXX + +#include <QObject> + +class Object_hxx : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/SameName/object_upper_ext.H b/Tests/QtAutogen/SameName/object_upper_ext.H new file mode 100644 index 000000000..3266087d4 --- /dev/null +++ b/Tests/QtAutogen/SameName/object_upper_ext.H @@ -0,0 +1,13 @@ +#ifndef OBJECT_UPPER_EXT_H +#define OBJECT_UPPER_EXT_H + +#include <QObject> + +class Object_Upper_Ext_H : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/SameName/view.ui b/Tests/QtAutogen/SameName/view.ui new file mode 100644 index 000000000..2ffe7344c --- /dev/null +++ b/Tests/QtAutogen/SameName/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt new file mode 100644 index 000000000..f3536ba2c --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.10) +project(StaticLibraryCycle) +include("../AutogenCoreTest.cmake") + +# Test AUTOMOC on cyclic static libraries + +set(CMAKE_AUTOMOC ON) + +# Cyclic static libraries +add_library(slc_a STATIC a.cpp) +target_link_libraries(slc_a ${QT_LIBRARIES} slc_b) + +add_library(slc_b STATIC b.cpp) +target_link_libraries(slc_b ${QT_LIBRARIES} slc_c) + +add_library(slc_c STATIC c.cpp) +target_link_libraries(slc_c ${QT_LIBRARIES} slc_a) + +add_executable(slc main.cpp) +target_link_libraries(slc ${QT_LIBRARIES} slc_a) diff --git a/Tests/QtAutogen/StaticLibraryCycle/a.cpp b/Tests/QtAutogen/StaticLibraryCycle/a.cpp new file mode 100644 index 000000000..8dd1803f1 --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/a.cpp @@ -0,0 +1,13 @@ +#include "a.h" + +#include "b.h" + +bool A::recursed = false; + +A::A() +{ + if (!A::recursed) { + A::recursed = true; + B b; + } +} diff --git a/Tests/QtAutogen/StaticLibraryCycle/a.h b/Tests/QtAutogen/StaticLibraryCycle/a.h new file mode 100644 index 000000000..f24398e5e --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/a.h @@ -0,0 +1,15 @@ +#ifndef CLASSA_HPP +#define CLASSA_HPP + +#include <QObject> + +class A : public QObject +{ + Q_OBJECT + static bool recursed; + +public: + A(); +}; + +#endif diff --git a/Tests/QtAutogen/StaticLibraryCycle/b.cpp b/Tests/QtAutogen/StaticLibraryCycle/b.cpp new file mode 100644 index 000000000..dee26177a --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/b.cpp @@ -0,0 +1,8 @@ +#include "b.h" + +#include "c.h" + +B::B() +{ + C c; +} diff --git a/Tests/QtAutogen/StaticLibraryCycle/b.h b/Tests/QtAutogen/StaticLibraryCycle/b.h new file mode 100644 index 000000000..ededbd803 --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/b.h @@ -0,0 +1,13 @@ +#ifndef CLASSB_HPP +#define CLASSB_HPP + +#include <QObject> + +class B : public QObject +{ + Q_OBJECT +public: + B(); +}; + +#endif diff --git a/Tests/QtAutogen/StaticLibraryCycle/c.cpp b/Tests/QtAutogen/StaticLibraryCycle/c.cpp new file mode 100644 index 000000000..2871f62f6 --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/c.cpp @@ -0,0 +1,8 @@ +#include "c.h" + +#include "a.h" + +C::C() +{ + A a; +} diff --git a/Tests/QtAutogen/StaticLibraryCycle/c.h b/Tests/QtAutogen/StaticLibraryCycle/c.h new file mode 100644 index 000000000..20f3725e9 --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/c.h @@ -0,0 +1,13 @@ +#ifndef CLASSC_HPP +#define CLASSC_HPP + +#include <QObject> + +class C : public QObject +{ + Q_OBJECT +public: + C(); +}; + +#endif diff --git a/Tests/QtAutogen/StaticLibraryCycle/main.cpp b/Tests/QtAutogen/StaticLibraryCycle/main.cpp new file mode 100644 index 000000000..f5b7fd227 --- /dev/null +++ b/Tests/QtAutogen/StaticLibraryCycle/main.cpp @@ -0,0 +1,8 @@ +#include "a.h" + +int main(int argv, char** args) +{ + // Object instances + A a; + return 0; +} diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake new file mode 100644 index 000000000..0e2718807 --- /dev/null +++ b/Tests/QtAutogen/TestMacros.cmake @@ -0,0 +1,61 @@ +# Autogen build options +set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}") +if(NOT _isMultiConfig) # Set in Tests/CMakeLists.txt + list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") +endif() +list(APPEND Autogen_BUILD_OPTIONS + "-DCMAKE_AUTOGEN_VERBOSE=1" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" +) + +# A macro to add a QtAutogen test +macro(ADD_AUTOGEN_TEST NAME) + if(${ARGC} GREATER 1) + # On Windows there is no RPATH, so while Qt might be available for building, + # the required dlls may not be in the PATH, so we can't run the executables + # on that platform. + if(WIN32) + set(_TestCommand --test-command ${CMAKE_CTEST_COMMAND} -V) + else() + set(_TestCommand --test-command ${ARGN}) + endif() + endif() + + set(_QtXAutogen "Qt${QT_TEST_VERSION}Autogen") + set(_SourceDir "${CMake_SOURCE_DIR}/Tests/QtAutogen/${NAME}") + set(_BuildDir "${CMake_BINARY_DIR}/Tests/${_QtXAutogen}/${NAME}") + add_test(NAME "${_QtXAutogen}.${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}" + --build-and-test + "${_SourceDir}" + "${_BuildDir}" + ${build_generator_args} + --build-project ${NAME} + --build-exe-dir "${_BuildDir}" + --force-new-ctest-process + --build-options ${build_options} ${Autogen_BUILD_OPTIONS} + ${_TestCommand} + ) + list(APPEND TEST_BUILD_DIRS "${_BuildDir}") + unset(_TestCommand) + unset(_QtXAutogen) + unset(_SourceDir) + unset(_BuildDir) +endmacro() + +# Allow using qtx_wrap_cpp and qtx_generate_moc or not +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) + # Qt4 moc does not support utf8 paths in _parameter files generated by + # qtx_wrap_cpp + # https://bugreports.qt.io/browse/QTBUG-35480 + if(QT_TEST_VERSION EQUAL 4) + 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(QT_TEST_ALLOW_QT_MACROS FALSE) + endif() +endif() diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake new file mode 100644 index 000000000..2b001d452 --- /dev/null +++ b/Tests/QtAutogen/Tests.cmake @@ -0,0 +1,48 @@ +# Qt4 and Qt5 tests +ADD_AUTOGEN_TEST(AutogenOriginDependsOff autogenOriginDependsOff) +ADD_AUTOGEN_TEST(AutogenOriginDependsOn) +ADD_AUTOGEN_TEST(AutogenTargetDepends) +ADD_AUTOGEN_TEST(Complex QtAutogen) +ADD_AUTOGEN_TEST(GlobalAutogenTarget) +ADD_AUTOGEN_TEST(LowMinimumVersion lowMinimumVersion) +ADD_AUTOGEN_TEST(ManySources manySources) +ADD_AUTOGEN_TEST(MocOnly mocOnly) +ADD_AUTOGEN_TEST(MocOptions mocOptions) +ADD_AUTOGEN_TEST(ObjectLibrary someProgram) +ADD_AUTOGEN_TEST(Parallel parallel) +ADD_AUTOGEN_TEST(Parallel1 parallel1) +ADD_AUTOGEN_TEST(Parallel2 parallel2) +ADD_AUTOGEN_TEST(Parallel3 parallel3) +ADD_AUTOGEN_TEST(Parallel4 parallel4) +ADD_AUTOGEN_TEST(ParallelAUTO parallelAUTO) +ADD_AUTOGEN_TEST(RccEmpty rccEmpty) +ADD_AUTOGEN_TEST(RccOffMocLibrary) +ADD_AUTOGEN_TEST(RccOnly rccOnly) +ADD_AUTOGEN_TEST(RccSkipSource) +ADD_AUTOGEN_TEST(RerunMocBasic) +ADD_AUTOGEN_TEST(RerunRccConfigChange) +ADD_AUTOGEN_TEST(RerunRccDepends) +ADD_AUTOGEN_TEST(SameName sameName) +ADD_AUTOGEN_TEST(StaticLibraryCycle slc) +ADD_AUTOGEN_TEST(UicInclude uicInclude) +ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface) +ADD_AUTOGEN_TEST(UicNoGui uicNoGui) +ADD_AUTOGEN_TEST(UicOnly uicOnly) +ADD_AUTOGEN_TEST(UicSkipSource) + +if(QT_TEST_ALLOW_QT_MACROS) + ADD_AUTOGEN_TEST(MocCMP0071) + ADD_AUTOGEN_TEST(MocInclude) + ADD_AUTOGEN_TEST(MocIncludeSymlink) + ADD_AUTOGEN_TEST(MocSkipSource) +endif() + +# Qt5 only tests +if(QT_TEST_VERSION GREATER 4) + ADD_AUTOGEN_TEST(MocMacroName mocMacroName) + ADD_AUTOGEN_TEST(MocOsMacros) + ADD_AUTOGEN_TEST(RerunMocPlugin) + if(APPLE) + ADD_AUTOGEN_TEST(MacOsFW) + endif() +endif() diff --git a/Tests/QtAutogen/uicInclude/CMakeLists.txt b/Tests/QtAutogen/UicInclude/CMakeLists.txt index f62ebb039..929868b52 100644 --- a/Tests/QtAutogen/uicInclude/CMakeLists.txt +++ b/Tests/QtAutogen/UicInclude/CMakeLists.txt @@ -1,5 +1,8 @@ -# Test moc include patterns +cmake_minimum_required(VERSION 3.10) +project(UicInclude) +include("../AutogenGuiTest.cmake") +# Test uic include patterns set(CMAKE_AUTOUIC_SEARCH_PATHS "dirA") add_executable(uicInclude main.cpp) diff --git a/Tests/QtAutogen/uicInclude/PageC.ui b/Tests/QtAutogen/UicInclude/PageC.ui index bb2fb5e6a..bb2fb5e6a 100644 --- a/Tests/QtAutogen/uicInclude/PageC.ui +++ b/Tests/QtAutogen/UicInclude/PageC.ui diff --git a/Tests/QtAutogen/uicInclude/PageC2.ui b/Tests/QtAutogen/UicInclude/PageC2.ui index daab86839..daab86839 100644 --- a/Tests/QtAutogen/uicInclude/PageC2.ui +++ b/Tests/QtAutogen/UicInclude/PageC2.ui diff --git a/Tests/QtAutogen/uicInclude/dirA/PageA.ui b/Tests/QtAutogen/UicInclude/dirA/PageA.ui index dd8180292..dd8180292 100644 --- a/Tests/QtAutogen/uicInclude/dirA/PageA.ui +++ b/Tests/QtAutogen/UicInclude/dirA/PageA.ui diff --git a/Tests/QtAutogen/uicInclude/dirB/PageB.ui b/Tests/QtAutogen/UicInclude/dirB/PageB.ui index fa6dfa615..fa6dfa615 100644 --- a/Tests/QtAutogen/uicInclude/dirB/PageB.ui +++ b/Tests/QtAutogen/UicInclude/dirB/PageB.ui diff --git a/Tests/QtAutogen/uicInclude/dirB/PageB2.ui b/Tests/QtAutogen/UicInclude/dirB/PageB2.ui index 2225150b5..2225150b5 100644 --- a/Tests/QtAutogen/uicInclude/dirB/PageB2.ui +++ b/Tests/QtAutogen/UicInclude/dirB/PageB2.ui diff --git a/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui b/Tests/QtAutogen/UicInclude/dirB/subB/PageBsub.ui index 873016ec8..873016ec8 100644 --- a/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui +++ b/Tests/QtAutogen/UicInclude/dirB/subB/PageBsub.ui diff --git a/Tests/QtAutogen/uicInclude/main.cpp b/Tests/QtAutogen/UicInclude/main.cpp index c8e760962..c8e760962 100644 --- a/Tests/QtAutogen/uicInclude/main.cpp +++ b/Tests/QtAutogen/UicInclude/main.cpp diff --git a/Tests/QtAutogen/uicInclude/main.hpp b/Tests/QtAutogen/UicInclude/main.hpp index 58ddc261f..58ddc261f 100644 --- a/Tests/QtAutogen/uicInclude/main.hpp +++ b/Tests/QtAutogen/UicInclude/main.hpp diff --git a/Tests/QtAutogen/uicInclude/subC/PageCsub.ui b/Tests/QtAutogen/UicInclude/subC/PageCsub.ui index 0268326b9..0268326b9 100644 --- a/Tests/QtAutogen/uicInclude/subC/PageCsub.ui +++ b/Tests/QtAutogen/UicInclude/subC/PageCsub.ui diff --git a/Tests/QtAutogen/UicInterface/CMakeLists.txt b/Tests/QtAutogen/UicInterface/CMakeLists.txt new file mode 100644 index 000000000..e0227645b --- /dev/null +++ b/Tests/QtAutogen/UicInterface/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.10) +project(UicInterface) +include("../AutogenGuiTest.cmake") + +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) + +# BEGIN Upstream + +set(CMAKE_VERBOSE_MAKEFILE ON) + +add_library(KI18n klocalizedstring.cpp) +target_link_libraries(KI18n ${QT_QTCORE_TARGET}) + +set(autouic_options + -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n +) +if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0) + list(APPEND autouic_options -include klocalizedstring.h) +endif() + +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS ${autouic_options} +) + +set(domainProp $<TARGET_PROPERTY:TRANSLATION_DOMAIN>) +set(nameLower $<LOWER_CASE:$<MAKE_C_IDENTIFIER:$<TARGET_PROPERTY:NAME>>>) +set(domain_logic + $<$<BOOL:${domainProp}>:${domainProp}>$<$<NOT:$<BOOL:${domainProp}>>:${nameLower}> +) +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS "TRANSLATION_DOMAIN=${domain_logic}" +) + +# END upstream + +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) +set(INC_DIR "include_$<CONFIG>" ) +else() +set(INC_DIR "include" ) +endif() + +add_library(LibWidget libwidget.cpp) +target_link_libraries(LibWidget KI18n ${QT_LIBRARIES}) +set_property(TARGET LibWidget PROPERTY NO_KUIT_SEMANTIC ON) +set_property(TARGET LibWidget PROPERTY TRANSLATION_DOMAIN customdomain) + +add_library(MyWidget mywidget.cpp) +target_link_libraries(MyWidget KI18n ${QT_LIBRARIES}) + +add_executable(QtAutoUicInterface main.cpp) +target_compile_definitions(QtAutoUicInterface + PRIVATE + UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/LibWidget_autogen/${INC_DIR}/ui_libwidget.h" + UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/MyWidget_autogen/${INC_DIR}/ui_mywidget.h" +) diff --git a/Tests/QtAutogen/UicInterface/klocalizedstring.cpp b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp new file mode 100644 index 000000000..b629cd176 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp @@ -0,0 +1,12 @@ + +#include "klocalizedstring.h" + +QString tr2xi18n(const char* text, const char*) +{ + return QLatin1String("TranslatedX") + QString::fromLatin1(text); +} + +QString tr2i18n(const char* text, const char*) +{ + return QLatin1String("Translated") + QString::fromLatin1(text); +} diff --git a/Tests/QtAutogen/UicInterface/klocalizedstring.h b/Tests/QtAutogen/UicInterface/klocalizedstring.h new file mode 100644 index 000000000..6129599dc --- /dev/null +++ b/Tests/QtAutogen/UicInterface/klocalizedstring.h @@ -0,0 +1,17 @@ + +#ifndef KLOCALIZEDSTRING_H +#define KLOCALIZEDSTRING_H + +#include <QString> + +#ifdef _WIN32 +__declspec(dllexport) +#endif + QString tr2xi18n(const char* text, const char* comment = 0); + +#ifdef _WIN32 +__declspec(dllexport) +#endif + QString tr2i18n(const char* text, const char* comment = 0); + +#endif diff --git a/Tests/QtAutogen/UicInterface/libwidget.cpp b/Tests/QtAutogen/UicInterface/libwidget.cpp new file mode 100644 index 000000000..008c22a96 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/libwidget.cpp @@ -0,0 +1,14 @@ + +#include "libwidget.h" + +LibWidget::LibWidget(QWidget* parent) + : QWidget(parent) + , ui(new Ui::LibWidget) +{ + ui->setupUi(this); +} + +LibWidget::~LibWidget() +{ + delete ui; +} diff --git a/Tests/QtAutogen/UicInterface/libwidget.h b/Tests/QtAutogen/UicInterface/libwidget.h new file mode 100644 index 000000000..532ff1db1 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/libwidget.h @@ -0,0 +1,26 @@ + +#ifndef LIBWIDGET_H +#define LIBWIDGET_H + +#include <memory> + +#include <QWidget> + +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) +# include <klocalizedstring.h> +#endif + +#include "ui_libwidget.h" + +class LibWidget : public QWidget +{ + Q_OBJECT +public: + explicit LibWidget(QWidget* parent = 0); + ~LibWidget(); + +private: + Ui::LibWidget* ui; +}; + +#endif diff --git a/Tests/QtAutogen/UicInterface/libwidget.ui b/Tests/QtAutogen/UicInterface/libwidget.ui new file mode 100644 index 000000000..897371e4a --- /dev/null +++ b/Tests/QtAutogen/UicInterface/libwidget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LibWidget</class> + <widget class="QWidget" name="LibWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>180</x> + <y>60</y> + <width>57</width> + <height>15</height> + </rect> + </property> + <property name="text"> + <string>LibLabel</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicInterface/main.cpp b/Tests/QtAutogen/UicInterface/main.cpp new file mode 100644 index 000000000..68bd84363 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/main.cpp @@ -0,0 +1,67 @@ + +#include <fstream> +#include <iostream> +#include <string> + +int main(int argc, char** argv) +{ + std::ifstream f; + f.open(UI_LIBWIDGET_H); + if (!f.is_open()) { + std::cout << "Could not open \"" UI_LIBWIDGET_H "\"." << std::endl; + return -1; + } + + { + bool gotTr2i18n = false; + + while (!f.eof()) { + std::string output; + getline(f, output); + if (!gotTr2i18n) { + gotTr2i18n = output.find("tr2i18n") != std::string::npos; + } + if (output.find("tr2xi18n") != std::string::npos) { + std::cout << "ui_libwidget,h uses tr2xi18n, though it should not." + << std::endl; + return -1; + } + } + + if (!gotTr2i18n) { + std::cout << "Did not find tr2i18n in ui_libwidget.h" << std::endl; + return -1; + } + } + + f.close(); + f.open(UI_MYWIDGET_H); + if (!f.is_open()) { + std::cout << "Could not open \"" UI_MYWIDGET_H "\"." << std::endl; + return -1; + } + + { + bool gotTr2xi18n = false; + + while (!f.eof()) { + std::string output; + getline(f, output); + if (!gotTr2xi18n) { + gotTr2xi18n = output.find("tr2xi18n") != std::string::npos; + } + if (output.find("tr2i18n") != std::string::npos) { + std::cout << "ui_mywidget,h uses tr2i18n, though it should not." + << std::endl; + return -1; + } + } + if (!gotTr2xi18n) { + std::cout << "Did not find tr2xi18n in ui_mywidget.h" << std::endl; + return -1; + } + } + f.close(); + + return 0; +} diff --git a/Tests/QtAutogen/UicInterface/mywidget.cpp b/Tests/QtAutogen/UicInterface/mywidget.cpp new file mode 100644 index 000000000..7cf1a1318 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/mywidget.cpp @@ -0,0 +1,14 @@ + +#include "mywidget.h" + +MyWidget::MyWidget(QWidget* parent) + : QWidget(parent) + , ui(new Ui::MyWidget) +{ + ui->setupUi(this); +} + +MyWidget::~MyWidget() +{ + delete ui; +} diff --git a/Tests/QtAutogen/UicInterface/mywidget.h b/Tests/QtAutogen/UicInterface/mywidget.h new file mode 100644 index 000000000..320d433ba --- /dev/null +++ b/Tests/QtAutogen/UicInterface/mywidget.h @@ -0,0 +1,26 @@ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <memory> + +#include <QWidget> + +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) +# include <klocalizedstring.h> +#endif + +#include "ui_mywidget.h" + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + explicit MyWidget(QWidget* parent = 0); + ~MyWidget(); + +private: + Ui::MyWidget* ui; +}; + +#endif diff --git a/Tests/QtAutogen/UicInterface/mywidget.ui b/Tests/QtAutogen/UicInterface/mywidget.ui new file mode 100644 index 000000000..b2b9cc592 --- /dev/null +++ b/Tests/QtAutogen/UicInterface/mywidget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MyWidget</class> + <widget class="QWidget" name="MyWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QPushButton" name="pushButton"> + <property name="geometry"> + <rect> + <x>110</x> + <y>40</y> + <width>81</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Special button</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicNoGui/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/CMakeLists.txt new file mode 100644 index 000000000..076299db1 --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(UicNoGui) +include("../AutogenCoreTest.cmake") + +# This tests creates a target that has AUTOUIC enabled but does not +# link against QtXWidgets. + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +add_subdirectory(MocOnly) +add_subdirectory(NoQt) + +add_executable(uicNoGui main.cpp) +target_link_libraries(uicNoGui mocOnly noQt) diff --git a/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt new file mode 100644 index 000000000..4fcd75fa0 --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt @@ -0,0 +1,3 @@ +# Library uses QtCore only (no Widgets) +add_library(mocOnly main.cpp) +target_link_libraries(mocOnly ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp b/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp new file mode 100644 index 000000000..3091845ef --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp @@ -0,0 +1,15 @@ +#include <QObject> + +class LocalObject : public QObject +{ + Q_OBJECT +public: + LocalObject(){}; +}; + +void mocOnly() +{ + LocalObject obj; +} + +#include "main.moc" diff --git a/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt new file mode 100644 index 000000000..f2bf3eec1 --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt @@ -0,0 +1,2 @@ +# Library doesn't use or link against Qt at all +add_library(noQt main.cpp) diff --git a/Tests/QtAutogen/UicNoGui/NoQt/main.cpp b/Tests/QtAutogen/UicNoGui/NoQt/main.cpp new file mode 100644 index 000000000..0052cc864 --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/NoQt/main.cpp @@ -0,0 +1,4 @@ + +void noQt() +{ +} diff --git a/Tests/QtAutogen/UicNoGui/main.cpp b/Tests/QtAutogen/UicNoGui/main.cpp new file mode 100644 index 000000000..e90c60aa5 --- /dev/null +++ b/Tests/QtAutogen/UicNoGui/main.cpp @@ -0,0 +1,9 @@ +extern void mocOnly(); +extern void noQt(); + +int main(int argc, char* argv[]) +{ + mocOnly(); + noQt(); + return 0; +} diff --git a/Tests/QtAutogen/UicOnly/CMakeLists.txt b/Tests/QtAutogen/UicOnly/CMakeLists.txt new file mode 100644 index 000000000..b16325438 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) +project(UicOnly) +include("../AutogenGuiTest.cmake") + +# Test AUTOUIC being enabled only +add_executable(uicOnly main.cpp UicOnly.cpp) +set_property(TARGET uicOnly PROPERTY AUTOUIC ON) +target_link_libraries(uicOnly ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/UicOnly/UicOnly.cpp b/Tests/QtAutogen/UicOnly/UicOnly.cpp new file mode 100644 index 000000000..8eee6d213 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/UicOnly.cpp @@ -0,0 +1,18 @@ +#include "ui_uiC.h" +#include "ui_uiD.h" +// AUTOUIC includes on the first two lines of a source file +#include "UicOnly.hpp" + +UicOnly::UicOnly() + : uiA(new Ui::UiA) + , uiB(new Ui::UiB) +{ + Ui::UiC uiC; + Ui::UiD uiD; +} + +UicOnly::~UicOnly() +{ + delete uiB; + delete uiA; +} diff --git a/Tests/QtAutogen/UicOnly/UicOnly.hpp b/Tests/QtAutogen/UicOnly/UicOnly.hpp new file mode 100644 index 000000000..24e1e0b94 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/UicOnly.hpp @@ -0,0 +1,15 @@ +#include "ui_uiA.h" +#include "ui_uiB.h" +// AUTOUIC includes on the first two lines of a header file +#include <QObject> + +class UicOnly : public QObject +{ +public: + UicOnly(); + ~UicOnly(); + +private: + Ui::UiA* uiA; + Ui::UiB* uiB; +}; diff --git a/Tests/QtAutogen/UicOnly/main.cpp b/Tests/QtAutogen/UicOnly/main.cpp new file mode 100644 index 000000000..bdd242ec2 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/main.cpp @@ -0,0 +1,7 @@ +#include "UicOnly.hpp" + +int main(int argc, char* argv[]) +{ + UicOnly uicOnly; + return 0; +} diff --git a/Tests/QtAutogen/UicOnly/uiA.ui b/Tests/QtAutogen/UicOnly/uiA.ui new file mode 100644 index 000000000..4c5762e82 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/uiA.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiA</class> + <widget class="QWidget" name="UiA"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicOnly/uiB.ui b/Tests/QtAutogen/UicOnly/uiB.ui new file mode 100644 index 000000000..6ca77dec3 --- /dev/null +++ b/Tests/QtAutogen/UicOnly/uiB.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiB</class> + <widget class="QWidget" name="UiB"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicOnly/uiC.ui b/Tests/QtAutogen/UicOnly/uiC.ui new file mode 100644 index 000000000..6802550cb --- /dev/null +++ b/Tests/QtAutogen/UicOnly/uiC.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiC</class> + <widget class="QWidget" name="UiC"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicOnly/uiD.ui b/Tests/QtAutogen/UicOnly/uiD.ui new file mode 100644 index 000000000..aad79cf7f --- /dev/null +++ b/Tests/QtAutogen/UicOnly/uiD.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiD</class> + <widget class="QWidget" name="UiD"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/UicSkipSource/CMakeLists.txt b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt new file mode 100644 index 000000000..dc3b7d4eb --- /dev/null +++ b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10) +project(UicSkipSource) +include("../AutogenGuiTest.cmake") + +# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target +set(skipUicSources + skipUic.cpp + skipUicGen.cpp + skipUicNoGen1.cpp + skipUicNoGen2.cpp +) +set_property(SOURCE skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON) +set_property(SOURCE skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON) +# AUTOUIC enabled +add_executable(skipUicA ${skipUicSources}) +set_property(TARGET skipUicA PROPERTY AUTOUIC ON) +target_link_libraries(skipUicA ${QT_LIBRARIES}) +# AUTOUIC and AUTOMOC enabled +add_executable(skipUicB ${skipUicSources}) +set_property(TARGET skipUicB PROPERTY AUTOUIC ON) +set_property(TARGET skipUicB PROPERTY AUTOMOC ON) +target_link_libraries(skipUicB ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/skipUic.cpp b/Tests/QtAutogen/UicSkipSource/skipUic.cpp index 0adf011a7..c4a7ce95b 100644 --- a/Tests/QtAutogen/skipUic.cpp +++ b/Tests/QtAutogen/UicSkipSource/skipUic.cpp @@ -1,7 +1,7 @@ -#include "skipSource/skipUicGen.hpp" -#include "skipSource/skipUicNoGen1.hpp" -#include "skipSource/skipUicNoGen2.hpp" +#include "skipUicGen.hpp" +#include "skipUicNoGen1.hpp" +#include "skipUicNoGen2.hpp" int main(int, char**) { diff --git a/Tests/QtAutogen/skipSource/skipUicGen.cpp b/Tests/QtAutogen/UicSkipSource/skipUicGen.cpp index d2a55a6f1..ab3c454c7 100644 --- a/Tests/QtAutogen/skipSource/skipUicGen.cpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicGen.cpp @@ -1,5 +1,6 @@ #include "skipUicGen.hpp" + #include "ui_uigen2.h" void skipGen() diff --git a/Tests/QtAutogen/skipSource/skipUicGen.hpp b/Tests/QtAutogen/UicSkipSource/skipUicGen.hpp index 3669f0e5b..3669f0e5b 100644 --- a/Tests/QtAutogen/skipSource/skipUicGen.hpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicGen.hpp diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp index f591a42ba..d648d94e7 100644 --- a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp @@ -1,5 +1,6 @@ #include "skipUicNoGen1.hpp" + #include "ui_nogen2.h" void skipNoGen1() diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.hpp index 286469598..286469598 100644 --- a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.hpp diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp index 8c1c3241c..aca58a463 100644 --- a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp @@ -1,5 +1,6 @@ #include "skipUicNoGen2.hpp" + #include "ui_nogen2.h" void skipNoGen2() diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.hpp index 7c381938c..7c381938c 100644 --- a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp +++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.hpp diff --git a/Tests/QtAutogen/skipSource/ui_nogen1.h b/Tests/QtAutogen/UicSkipSource/ui_nogen1.h index a7be52bce..a7be52bce 100644 --- a/Tests/QtAutogen/skipSource/ui_nogen1.h +++ b/Tests/QtAutogen/UicSkipSource/ui_nogen1.h diff --git a/Tests/QtAutogen/skipSource/ui_nogen2.h b/Tests/QtAutogen/UicSkipSource/ui_nogen2.h index 5d547d477..4e500a44d 100644 --- a/Tests/QtAutogen/skipSource/ui_nogen2.h +++ b/Tests/QtAutogen/UicSkipSource/ui_nogen2.h @@ -3,4 +3,4 @@ void ui_nogen2(); -#endif
\ No newline at end of file +#endif diff --git a/Tests/QtAutogen/skipSource/uigen1.ui b/Tests/QtAutogen/UicSkipSource/uigen1.ui index fc7cb8219..fc7cb8219 100644 --- a/Tests/QtAutogen/skipSource/uigen1.ui +++ b/Tests/QtAutogen/UicSkipSource/uigen1.ui diff --git a/Tests/QtAutogen/skipSource/uigen2.ui b/Tests/QtAutogen/UicSkipSource/uigen2.ui index 01f08d2ef..01f08d2ef 100644 --- a/Tests/QtAutogen/skipSource/uigen2.ui +++ b/Tests/QtAutogen/UicSkipSource/uigen2.ui diff --git a/Tests/QtAutogen/defines_test/CMakeLists.txt b/Tests/QtAutogen/defines_test/CMakeLists.txt deleted file mode 100644 index 9ee9a228a..000000000 --- a/Tests/QtAutogen/defines_test/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ - -add_executable(defines_test defines_test.cpp) -set_target_properties(defines_test PROPERTIES AUTOMOC TRUE) -target_link_libraries(defines_test Qt4::QtGui) diff --git a/Tests/QtAutogen/mocInclude/ObjA.cpp b/Tests/QtAutogen/mocInclude/ObjA.cpp deleted file mode 100644 index 1b0311d30..000000000 --- a/Tests/QtAutogen/mocInclude/ObjA.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ObjA.hpp" - -class SubObjA : public QObject -{ - Q_OBJECT - -public: - SubObjA() {} - ~SubObjA() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjA::aSlot() -{ -} - -void ObjA::go() -{ - SubObjA subObj; -} - -#include "ObjA.moc" diff --git a/Tests/QtAutogen/mocInclude/ObjA.hpp b/Tests/QtAutogen/mocInclude/ObjA.hpp deleted file mode 100644 index 281e90d86..000000000 --- a/Tests/QtAutogen/mocInclude/ObjA.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJA_HPP -#define OBJA_HPP - -#include <QObject> - -class ObjA : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/ObjB.cpp b/Tests/QtAutogen/mocInclude/ObjB.cpp deleted file mode 100644 index 5ff315dc7..000000000 --- a/Tests/QtAutogen/mocInclude/ObjB.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ObjB.hpp" - -class SubObjB : public QObject -{ - Q_OBJECT - -public: - SubObjB() {} - ~SubObjB() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjB::aSlot() -{ -} - -void ObjB::go() -{ - SubObjB subObj; -} - -#include "ObjB.moc" -#include "moc_ObjB.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjB.hpp b/Tests/QtAutogen/mocInclude/ObjB.hpp deleted file mode 100644 index 94f3d498c..000000000 --- a/Tests/QtAutogen/mocInclude/ObjB.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJB_HPP -#define OBJB_HPP - -#include <QObject> - -class ObjB : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/ObjC.cpp b/Tests/QtAutogen/mocInclude/ObjC.cpp deleted file mode 100644 index 8ca34cbb4..000000000 --- a/Tests/QtAutogen/mocInclude/ObjC.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ObjC.hpp" - -class SubObjC : public QObject -{ - Q_OBJECT - -public: - SubObjC() {} - ~SubObjC() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjC::aSlot() -{ -} - -void ObjC::go() -{ - SubObjC subObj; -} - -#include "ObjC.moc" -// Not the own header -#include "moc_ObjD.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjC.hpp b/Tests/QtAutogen/mocInclude/ObjC.hpp deleted file mode 100644 index a8e98eb1e..000000000 --- a/Tests/QtAutogen/mocInclude/ObjC.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJC_HPP -#define OBJC_HPP - -#include <QObject> - -class ObjC : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/ObjD.cpp b/Tests/QtAutogen/mocInclude/ObjD.cpp deleted file mode 100644 index c18aec152..000000000 --- a/Tests/QtAutogen/mocInclude/ObjD.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ObjD.hpp" - -class SubObjD : public QObject -{ - Q_OBJECT - -public: - SubObjD() {} - ~SubObjD() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjD::aSlot() -{ -} - -void ObjD::go() -{ - SubObjD subObj; -} - -#include "ObjD.moc" -// Header in subdirectory -#include "subA/moc_SubObjA.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjD.hpp b/Tests/QtAutogen/mocInclude/ObjD.hpp deleted file mode 100644 index b6ee09808..000000000 --- a/Tests/QtAutogen/mocInclude/ObjD.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJD_HPP -#define OBJD_HPP - -#include <QObject> - -class ObjD : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp deleted file mode 100644 index a05f6e37e..000000000 --- a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjA.hpp" - -namespace subA { - -class SubObjA : public QObject -{ - Q_OBJECT - -public: - SubObjA() {} - ~SubObjA() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjA::aSlot() -{ -} - -void ObjA::go() -{ - SubObjA subObj; -} -} - -#include "SubObjA.moc" diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp deleted file mode 100644 index 31a18b618..000000000 --- a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJA_HPP -#define SUBOBJA_HPP - -#include <QObject> - -namespace subA { - -class ObjA : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp deleted file mode 100644 index 1e77639b2..000000000 --- a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjB.hpp" - -namespace subB { - -class SubObjB : public QObject -{ - Q_OBJECT - -public: - SubObjB() {} - ~SubObjB() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjB::aSlot() -{ -} - -void ObjB::go() -{ - SubObjB subObj; -} -} - -#include "SubObjB.moc" diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp deleted file mode 100644 index 3f29fa289..000000000 --- a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJB_HPP -#define SUBOBJB_HPP - -#include <QObject> - -namespace subB { - -class ObjB : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp deleted file mode 100644 index c2d94ef26..000000000 --- a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjC.hpp" - -namespace subC { - -class SubObjC : public QObject -{ - Q_OBJECT - -public: - SubObjC() {} - ~SubObjC() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjC::aSlot() -{ -} - -void ObjC::go() -{ - SubObjC subObj; -} -} - -#include "SubObjC.moc" diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp deleted file mode 100644 index dc251fd61..000000000 --- a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJC_HPP -#define SUBOBJC_HPP - -#include <QObject> - -namespace subC { - -class ObjC : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt deleted file mode 100644 index 6a0829df7..000000000 --- a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Test moc include patterns - -set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) - -include_directories("../mocInclude") - -add_executable(mocIncludeRelaxed - ../mocInclude/ObjA.cpp - ../mocInclude/ObjB.cpp - ../mocInclude/ObjC.cpp - ../mocInclude/ObjD.cpp - ../mocInclude/subA/SubObjA.cpp - ../mocInclude/subB/SubObjB.cpp - ../mocInclude/subC/SubObjC.cpp - main.cpp -) -target_link_libraries(mocIncludeRelaxed ${QT_LIBRARIES}) -set_target_properties(mocIncludeRelaxed PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp b/Tests/QtAutogen/mocIncludeRelaxed/main.cpp deleted file mode 100644 index 142d59e69..000000000 --- a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "ObjA.hpp" -#include "ObjB.hpp" -#include "ObjC.hpp" - -int main(int argv, char** args) -{ - ObjA objA; - ObjB objB; - ObjC objC; - return 0; -} - -// Header in global subdirectory -#include "subB/moc_SubObjB.cpp" diff --git a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt b/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt deleted file mode 100644 index 22e93a8ba..000000000 --- a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Test moc include patterns - -set(CMAKE_AUTOMOC_RELAXED_MODE FALSE) - -include_directories("../mocInclude") - -add_executable(mocIncludeStrict - ../mocInclude/ObjA.cpp - ../mocInclude/ObjB.cpp - ../mocInclude/ObjC.cpp - ../mocInclude/ObjD.cpp - ../mocInclude/subA/SubObjA.cpp - ../mocInclude/subB/SubObjB.cpp - ../mocInclude/subC/SubObjC.cpp - main.cpp -) -target_link_libraries(mocIncludeStrict ${QT_LIBRARIES}) -set_target_properties(mocIncludeStrict PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocIncludeStrict/main.cpp b/Tests/QtAutogen/mocIncludeStrict/main.cpp deleted file mode 100644 index 142d59e69..000000000 --- a/Tests/QtAutogen/mocIncludeStrict/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "ObjA.hpp" -#include "ObjB.hpp" -#include "ObjC.hpp" - -int main(int argv, char** args) -{ - ObjA objA; - ObjB objB; - ObjC objC; - return 0; -} - -// Header in global subdirectory -#include "subB/moc_SubObjB.cpp" diff --git a/Tests/QtAutogen/mocPlugin/StyleE.hpp b/Tests/QtAutogen/mocPlugin/StyleE.hpp deleted file mode 100644 index e7915a8e5..000000000 --- a/Tests/QtAutogen/mocPlugin/StyleE.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEE_HPP -#define STYLEE_HPP - -#include "StyleCommon.hpp" -#include <QStylePlugin> - -class StyleE : public QStylePlugin -{ - Q_OBJECT - // No Json file - Q_PLUGIN_METADATA(IID "org.styles.E") - A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json deleted file mode 100644 index 129cac41f..000000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt deleted file mode 100644 index 14b077b38..000000000 --- a/Tests/QtAutogen/mocRerun/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 3.7) -project(mocRerun CXX) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -# Generated source file -add_custom_command(OUTPUT main.cpp - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - ) - -add_executable(mocRerun - ${CMAKE_CURRENT_BINARY_DIR}/test1.h - ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - res1.qrc - ) -set_property(TARGET mocRerun PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1) -target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(mocRerun ${QT_CORE_TARGET}) -# Write target name to text file -add_custom_command(TARGET mocRerun POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > target1.txt) diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt deleted file mode 100644 index 878ae5d35..000000000 --- a/Tests/QtAutogen/rccDepends/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 3.7) -project(rccDepends) - -set(CMAKE_AUTORCC ON) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() - -configure_file(res/input1.txt.in res1/input.txt COPYONLY) -configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY) -configure_file(res/input2.txt.in res2/input.txt COPYONLY) -configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY) -# Dependency generated qrc file -add_custom_command(OUTPUT res2.qrc - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc - ) - -add_executable(rccDepends - main.cpp - ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc - ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc ) -target_link_libraries(rccDepends ${QT_CORE_TARGET}) -add_custom_command(TARGET rccDepends POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt) diff --git a/Tests/QtAutogen/rccDepends/res/input1.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in deleted file mode 100644 index da627624b..000000000 --- a/Tests/QtAutogen/rccDepends/res/input1.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res1 input. diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in deleted file mode 100644 index 08e14b7bd..000000000 --- a/Tests/QtAutogen/rccDepends/res/input2.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res2 input. diff --git a/Tests/QtAutogen/rccDepends/res1a.qrc.in b/Tests/QtAutogen/rccDepends/res1a.qrc.in deleted file mode 100644 index d111ffbc7..000000000 --- a/Tests/QtAutogen/rccDepends/res1a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/Texts1"> - <file>res1/input.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res1b.qrc.in b/Tests/QtAutogen/rccDepends/res1b.qrc.in deleted file mode 100644 index 4cb3f047c..000000000 --- a/Tests/QtAutogen/rccDepends/res1b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/Texts1"> - <file>res1/input.txt</file> - <file alias="Added">res1/inputAdded.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res2a.qrc.in b/Tests/QtAutogen/rccDepends/res2a.qrc.in deleted file mode 100644 index 19f34ac90..000000000 --- a/Tests/QtAutogen/rccDepends/res2a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/Texts2"> - <file>res2/input.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res2b.qrc.in b/Tests/QtAutogen/rccDepends/res2b.qrc.in deleted file mode 100644 index 19e8ba10c..000000000 --- a/Tests/QtAutogen/rccDepends/res2b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/Texts2"> - <file>res2/input.txt</file> - <file alias="Added">res2/inputAdded.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp b/Tests/QtAutogen/sameName/aaa/bbb/item.cpp deleted file mode 100644 index 20d00445e..000000000 --- a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "item.hpp" - -namespace aaa { -namespace bbb { - -void Item::go() -{ -} -} -} diff --git a/Tests/QtAutogen/sameName/aaa/item.cpp b/Tests/QtAutogen/sameName/aaa/item.cpp deleted file mode 100644 index 95dd3b674..000000000 --- a/Tests/QtAutogen/sameName/aaa/item.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "item.hpp" - -namespace aaa { - -void Item::go() -{ -} -} diff --git a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp b/Tests/QtAutogen/sameName/bbb/aaa/item.cpp deleted file mode 100644 index ac4b2c27b..000000000 --- a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "item.hpp" - -namespace bbb { -namespace aaa { - -void Item::go() -{ -} -} -} diff --git a/Tests/QtAutogen/sameName/bbb/item.cpp b/Tests/QtAutogen/sameName/bbb/item.cpp deleted file mode 100644 index f97a1431e..000000000 --- a/Tests/QtAutogen/sameName/bbb/item.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "item.hpp" - -namespace bbb { - -void Item::go() -{ -} -} diff --git a/Tests/QtAutogen/sameName/ccc/item.cpp b/Tests/QtAutogen/sameName/ccc/item.cpp deleted file mode 100644 index d90b2b8c7..000000000 --- a/Tests/QtAutogen/sameName/ccc/item.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "item.hpp" - -namespace ccc { - -void Item::go() -{ -} - -class MocTest : public QObject -{ - Q_OBJECT; - Q_SLOT - void go(); -}; - -void MocTest::go() -{ -} -} - -// Include own moc files -#include "item.moc" -#include "moc_item.cpp" diff --git a/Tests/QtAutogen/sameName/item.cpp b/Tests/QtAutogen/sameName/item.cpp deleted file mode 100644 index e013cf392..000000000 --- a/Tests/QtAutogen/sameName/item.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "item.hpp" - -void Item::go() -{ -} diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp deleted file mode 100644 index 85305f590..000000000 --- a/Tests/QtAutogen/skipMoc.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -#include "skipSource/qItemA.hpp" -#include "skipSource/qItemB.hpp" -#include "skipSource/qItemC.hpp" - -int main(int, char**) -{ - QItemA itemA; - QItemA itemB; - QItemA itemC; - - // 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 deleted file mode 100644 index 700abd6db..000000000 --- a/Tests/QtAutogen/skipSource/qItemC.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "qItemC.hpp" - -void QItemC::go() -{ -} diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.cpp b/Tests/QtAutogen/uicOnlySource/uiconly.cpp deleted file mode 100644 index 7b91b251f..000000000 --- a/Tests/QtAutogen/uicOnlySource/uiconly.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -#include "uiconly.h" - -UicOnly::UicOnly(QWidget* parent) - : QWidget(parent) - , ui(new Ui::UicOnly) -{ -} - -UicOnly::~UicOnly() -{ - delete ui; -} - -int main() -{ - return 0; -} diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.h b/Tests/QtAutogen/uicOnlySource/uiconly.h deleted file mode 100644 index 8f4eebe1e..000000000 --- a/Tests/QtAutogen/uicOnlySource/uiconly.h +++ /dev/null @@ -1,20 +0,0 @@ - -#ifndef UIC_ONLY_H -#define UIC_ONLY_H - -#include <QWidget> - -#include "ui_uiconly.h" - -class UicOnly : public QWidget -{ - Q_OBJECT -public: - explicit UicOnly(QWidget* parent = 0); - ~UicOnly(); - -private: - Ui::UicOnly* ui; -}; - -#endif diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.ui b/Tests/QtAutogen/uicOnlySource/uiconly.ui deleted file mode 100644 index 13fb832eb..000000000 --- a/Tests/QtAutogen/uicOnlySource/uiconly.ui +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UicOnly</class> - <widget class="QWidget" name="UicOnly"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="treeView"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> |