summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r--Tests/QtAutogen/CMakeLists.txt80
-rw-r--r--Tests/QtAutogen/mocOnlySource/StyleA.cpp5
-rw-r--r--Tests/QtAutogen/mocOnlySource/StyleA.hpp15
-rw-r--r--Tests/QtAutogen/mocOnlySource/StyleB.cpp5
-rw-r--r--Tests/QtAutogen/mocOnlySource/StyleB.hpp16
-rw-r--r--Tests/QtAutogen/mocOnlySource/main.cpp9
6 files changed, 102 insertions, 28 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 073c5fd..89d2b80 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -46,6 +46,35 @@ endif()
get_property(QT_COMPILE_FEATURES TARGET ${QT_QTCORE_TARGET} PROPERTY INTERFACE_COMPILE_FEATURES)
+# Qt4 moc does not support utf8 paths in _parameter files generated by
+# qtx_wrap_cpp
+# https://bugreports.qt.io/browse/QTBUG-35480
+# 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((NOT NON_ASCII_BDIR) OR (NOT QT_TEST_VERSION STREQUAL 4))
+ set(ALLOW_WRAP_CPP TRUE)
+endif()
+# On windows qtx_wrap_cpp also fails in Qt5 when used on a path that
+# contains non ASCII characters
+if(NON_ASCII_BDIR AND WIN32)
+ set(ALLOW_WRAP_CPP FALSE)
+endif()
+
+# -- Test
+# MOC only
+add_executable(mocOnly mocOnlySource/main.cpp mocOnlySource/StyleA.cpp mocOnlySource/StyleB.cpp)
+set_property(TARGET mocOnly PROPERTY AUTOMOC ON)
+target_link_libraries(mocOnly ${QT_LIBRARIES})
+
+# -- Test
+# UIC only
+if(ALLOW_WRAP_CPP)
+ 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})
+endif()
+
# -- Test
# RCC only
add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc)
@@ -59,13 +88,6 @@ 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
@@ -100,7 +122,7 @@ 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)
+file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList ENCODING UTF-8)
list(GET targetList 0 rccDependsBin)
file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}")
# Sleep, touch regular qrc input file, rebuild and compare timestamp
@@ -188,7 +210,7 @@ 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)
+file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List ENCODING UTF-8)
list(GET target1List 0 binFile)
file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
# Change file content and rebuild
@@ -209,25 +231,27 @@ 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})
+if(ALLOW_WRAP_CPP)
+ 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})
+endif()
# -- Test
# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target
diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.cpp b/Tests/QtAutogen/mocOnlySource/StyleA.cpp
new file mode 100644
index 0000000..ced1dd1
--- /dev/null
+++ b/Tests/QtAutogen/mocOnlySource/StyleA.cpp
@@ -0,0 +1,5 @@
+#include "StyleA.hpp"
+
+StyleA::StyleA()
+{
+}
diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.hpp b/Tests/QtAutogen/mocOnlySource/StyleA.hpp
new file mode 100644
index 0000000..66735b6
--- /dev/null
+++ b/Tests/QtAutogen/mocOnlySource/StyleA.hpp
@@ -0,0 +1,15 @@
+#ifndef STYLEA_HPP
+#define STYLEA_HPP
+
+#include <QObject>
+
+/// Q_OBJECT on a single new line
+///
+class StyleA : public QObject
+{
+ Q_OBJECT
+public:
+ StyleA();
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.cpp b/Tests/QtAutogen/mocOnlySource/StyleB.cpp
new file mode 100644
index 0000000..bec6c1c
--- /dev/null
+++ b/Tests/QtAutogen/mocOnlySource/StyleB.cpp
@@ -0,0 +1,5 @@
+#include "StyleB.hpp"
+
+StyleB::StyleB()
+{
+}
diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.hpp b/Tests/QtAutogen/mocOnlySource/StyleB.hpp
new file mode 100644
index 0000000..425daf8
--- /dev/null
+++ b/Tests/QtAutogen/mocOnlySource/StyleB.hpp
@@ -0,0 +1,16 @@
+#ifndef STYLEB_HPP
+#define STYLEB_HPP
+
+#include <QObject>
+
+/* clang-format off */
+/// Q_OBJECT behind a brace
+///
+class StyleB : public QObject
+{ Q_OBJECT
+public:
+ StyleB();
+};
+/* clang-format on */
+
+#endif
diff --git a/Tests/QtAutogen/mocOnlySource/main.cpp b/Tests/QtAutogen/mocOnlySource/main.cpp
new file mode 100644
index 0000000..06f8d81
--- /dev/null
+++ b/Tests/QtAutogen/mocOnlySource/main.cpp
@@ -0,0 +1,9 @@
+#include "StyleA.hpp"
+#include "StyleB.hpp"
+
+int main(int argv, char** args)
+{
+ StyleA styleA;
+ StyleB styleB;
+ return 0;
+}