summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-07-16 14:51:14 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-07-18 16:11:31 (GMT)
commitdca5df16c51dd9426f415ed7943402036e0ad08c (patch)
tree658b847663124c0321ba62f4436c4c604cde691c /Tests/QtAutogen
parentec049641c46eb788b25713e5d96ff32c89f0e819 (diff)
downloadCMake-dca5df16c51dd9426f415ed7943402036e0ad08c.zip
CMake-dca5df16c51dd9426f415ed7943402036e0ad08c.tar.gz
CMake-dca5df16c51dd9426f415ed7943402036e0ad08c.tar.bz2
Autogen: Process GENERATED files. Add CMP0071.
This lets AUTOMOC and AUTOUIC process GENERATED files which used to be ignored before. A new policy CMP0071 ensures that the old behavior of ignoring GENERATED files is enabled when the CMake compatibility version CMAKE_MINIMUM_REQUIRED is < 3.10. Closes #16186
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r--Tests/QtAutogen/CMakeLists.txt15
-rw-r--r--Tests/QtAutogen/complex/CMakeLists.txt2
-rw-r--r--Tests/QtAutogen/mocCMP0071/CMakeLists.txt4
-rw-r--r--Tests/QtAutogen/mocCMP0071/NEW/CMakeLists.txt16
-rw-r--r--Tests/QtAutogen/mocCMP0071/OLD/CMakeLists.txt18
-rw-r--r--Tests/QtAutogen/mocCMP0071/Obj.cpp20
-rw-r--r--Tests/QtAutogen/mocCMP0071/Obj.hpp19
-rw-r--r--Tests/QtAutogen/mocCMP0071/Obj_p.h14
-rw-r--r--Tests/QtAutogen/mocCMP0071/main.cpp7
-rw-r--r--Tests/QtAutogen/mocDepends/CMakeLists.txt7
-rw-r--r--Tests/QtAutogen/mocPlugin/CMakeLists.txt2
-rw-r--r--Tests/QtAutogen/mocRerun/CMakeLists.txt4
-rw-r--r--Tests/QtAutogen/rccDepends/CMakeLists.txt4
13 files changed, 117 insertions, 15 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 89d2b80..9393f1e 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.7)
-
+cmake_minimum_required(VERSION 3.9)
+cmake_policy(SET CMP0071 NEW)
project(QtAutogen)
# Tell find_package(Qt5) where to find Qt.
@@ -304,11 +304,16 @@ add_subdirectory(mocDepends)
# -- Test
# Tests various include moc patterns
-add_subdirectory(mocIncludeStrict)
+if(ALLOW_WRAP_CPP)
+ add_subdirectory(mocIncludeStrict)
+ add_subdirectory(mocIncludeRelaxed)
+endif()
# -- Test
-# Tests various include moc patterns
-add_subdirectory(mocIncludeRelaxed)
+# Tests policy 0071
+if(ALLOW_WRAP_CPP)
+ add_subdirectory(mocCMP0071)
+endif()
# -- Test
# Tests Q_PLUGIN_METADATA json file change detection
diff --git a/Tests/QtAutogen/complex/CMakeLists.txt b/Tests/QtAutogen/complex/CMakeLists.txt
index d48f6cc..2043ccf 100644
--- a/Tests/QtAutogen/complex/CMakeLists.txt
+++ b/Tests/QtAutogen/complex/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.9)
# -- Test: AUTOMOC AUTORCC AUTOUIC
add_definitions(-DFOO -DSomeDefine="Barx")
diff --git a/Tests/QtAutogen/mocCMP0071/CMakeLists.txt b/Tests/QtAutogen/mocCMP0071/CMakeLists.txt
new file mode 100644
index 0000000..003fa08
--- /dev/null
+++ b/Tests/QtAutogen/mocCMP0071/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.9)
+project(mocCMP0071 CXX)
+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 0000000..0237afc
--- /dev/null
+++ b/Tests/QtAutogen/mocCMP0071/NEW/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.9)
+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 0000000..5699433
--- /dev/null
+++ b/Tests/QtAutogen/mocCMP0071/OLD/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.9)
+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 0000000..1ae50ed
--- /dev/null
+++ b/Tests/QtAutogen/mocCMP0071/Obj.cpp
@@ -0,0 +1,20 @@
+#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 0000000..f064e47
--- /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 0000000..cb1e5df
--- /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 0000000..3887840
--- /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/mocDepends/CMakeLists.txt b/Tests/QtAutogen/mocDepends/CMakeLists.txt
index a67dcfe..cd5adf5 100644
--- a/Tests/QtAutogen/mocDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/mocDepends/CMakeLists.txt
@@ -1,5 +1,6 @@
-cmake_minimum_required(VERSION 3.7)
-project(mocDepends)
+cmake_minimum_required(VERSION 3.9)
+cmake_policy(SET CMP0071 NEW)
+project(mocDepends CXX)
if (QT_TEST_VERSION STREQUAL 4)
find_package(Qt4 REQUIRED)
@@ -28,7 +29,6 @@ add_executable(mocDepends1 test1.cpp
)
target_link_libraries(mocDepends1 ${QT_CORE_TARGET})
set_target_properties(mocDepends1 PROPERTIES AUTOMOC TRUE)
-set_property(TARGET mocDepends1 PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1)
# -- Test 2 using generated library
# This tests the dependency of AUTOMOC of mocDepends2 to the
@@ -44,4 +44,3 @@ add_library(SimpleLib STATIC simpleLib.hpp simpleLib.cpp)
add_executable(mocDepends2 test2.cpp )
target_link_libraries(mocDepends2 SimpleLib ${QT_CORE_TARGET})
set_target_properties(mocDepends2 PROPERTIES AUTOMOC TRUE)
-set_property(TARGET mocDepends2 PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1)
diff --git a/Tests/QtAutogen/mocPlugin/CMakeLists.txt b/Tests/QtAutogen/mocPlugin/CMakeLists.txt
index f80aa29..9b224fb 100644
--- a/Tests/QtAutogen/mocPlugin/CMakeLists.txt
+++ b/Tests/QtAutogen/mocPlugin/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.8)
+cmake_minimum_required(VERSION 3.9)
project(mocPlugin CXX)
set(CMAKE_AUTOMOC_DEPEND_FILTERS
diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt
index 14b077b..7380bdd 100644
--- a/Tests/QtAutogen/mocRerun/CMakeLists.txt
+++ b/Tests/QtAutogen/mocRerun/CMakeLists.txt
@@ -1,4 +1,5 @@
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.9)
+cmake_policy(SET CMP0071 NEW)
project(mocRerun CXX)
if (QT_TEST_VERSION STREQUAL 4)
@@ -27,7 +28,6 @@ add_executable(mocRerun
${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
diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt
index 878ae5d..edc0ac3 100644
--- a/Tests/QtAutogen/rccDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.7)
-project(rccDepends)
+cmake_minimum_required(VERSION 3.9)
+project(rccDepends CXX)
set(CMAKE_AUTORCC ON)