summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-04-26 15:31:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-04-26 15:31:54 (GMT)
commite69a3287256d5fb7f6f2a150f5e96ff7bcb0d9b7 (patch)
treea88934f93475ff3a0d7efb903d69342ac206ad66 /Tests
parent6aabf2790c4e4f904aeaa166bf6a7abdd2f290e3 (diff)
parent5b0ea5874a3322e57156b329b340bf283673c207 (diff)
downloadCMake-e69a3287256d5fb7f6f2a150f5e96ff7bcb0d9b7.zip
CMake-e69a3287256d5fb7f6f2a150f5e96ff7bcb0d9b7.tar.gz
CMake-e69a3287256d5fb7f6f2a150f5e96ff7bcb0d9b7.tar.bz2
Merge topic 'autogen-moc-version'
5b0ea5874a AutoGen: Retrieve Qt version from moc as fallback Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6027
Diffstat (limited to 'Tests')
-rw-r--r--Tests/QtAutogen/Tests.cmake1
-rw-r--r--Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt16
-rw-r--r--Tests/QtAutogen/WrappedFindPackage/main.cpp19
3 files changed, 36 insertions, 0 deletions
diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake
index ab5686a..a3c57a5 100644
--- a/Tests/QtAutogen/Tests.cmake
+++ b/Tests/QtAutogen/Tests.cmake
@@ -49,6 +49,7 @@ if(QT_TEST_VERSION GREATER 4)
ADD_AUTOGEN_TEST(MocMacroName mocMacroName)
ADD_AUTOGEN_TEST(MocOsMacros)
ADD_AUTOGEN_TEST(RerunMocPlugin)
+ ADD_AUTOGEN_TEST(WrappedFindPackage)
if(APPLE)
ADD_AUTOGEN_TEST(MacOsFW)
endif()
diff --git a/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt b/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt
new file mode 100644
index 0000000..e8f50d5
--- /dev/null
+++ b/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.20)
+project(WrappedFindPackage)
+
+# Wrap the find_package call in a function.
+# Test whether AutoMoc can retrieve the Qt version from the moc executable.
+function(find_qt_package)
+ include("../AutogenCoreTest.cmake")
+ set(QT_LIBRARIES "${QT_LIBRARIES}" PARENT_SCOPE)
+endfunction()
+
+find_qt_package()
+
+set(CMAKE_AUTOMOC ON)
+
+add_executable(wrappedFindPackage main.cpp)
+target_link_libraries(wrappedFindPackage PRIVATE ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/WrappedFindPackage/main.cpp b/Tests/QtAutogen/WrappedFindPackage/main.cpp
new file mode 100644
index 0000000..1e2c63f
--- /dev/null
+++ b/Tests/QtAutogen/WrappedFindPackage/main.cpp
@@ -0,0 +1,19 @@
+#include <qobject.h>
+
+class MyObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyObject(QObject* parent = 0)
+ : QObject(parent)
+ {
+ }
+};
+
+int main()
+{
+ MyObject obj;
+ return 0;
+}
+
+#include "main.moc"