summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/cmake/CMakeLists.txt13
-rw-r--r--tests/auto/cmake/test_testlib_definitions/CMakeLists.txt38
-rw-r--r--tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt4
-rw-r--r--tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt4
-rw-r--r--tests/auto/cmake/test_testlib_definitions/main.cpp58
-rw-r--r--tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt4
-rw-r--r--tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt42
-rw-r--r--tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt43
8 files changed, 206 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 55db94db52..d9eb683f1b 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -74,3 +74,16 @@ if (NOT WIN32)
endif()
expect_pass(test_private_includes)
expect_pass(test_modules)
+expect_pass(test_testlib_definitions)
+
+expect_fail(test_testlib_no_link_gui)
+expect_fail(test_testlib_no_link_widgets)
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+ "${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp"
+ "${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_gui/test_testlib_no_link_gui/"
+)
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+ "${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp"
+ "${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_widgets/test_testlib_no_link_widgets/"
+)
diff --git a/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt
new file mode 100644
index 0000000000..c370e8effa
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt
@@ -0,0 +1,38 @@
+
+cmake_minimum_required(VERSION 2.8.3)
+
+project(test_testlib_definitions)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+macro(test_testlib_project _module)
+ find_package(Qt5${_module} REQUIRED)
+ find_package(Qt5Test REQUIRED)
+
+ add_definitions(
+ ${Qt5${_module}_DEFINITIONS}
+ ${Qt5Test_DEFINITIONS}
+ )
+
+ include_directories(
+ ${Qt5${_module}_INCLUDE_DIRS}
+ ${Qt5Test_INCLUDE_DIRS}
+ )
+
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}")
+
+ set(main_file "${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp")
+ set(moc_file "${CMAKE_CURRENT_BINARY_DIR}/main.moc")
+
+ qt5_generate_moc("${main_file}" "${moc_file}")
+
+ add_executable(testapp_${_module} "${main_file}" "${moc_file}")
+ target_link_libraries(testapp_${_module}
+ ${Qt5${_module}_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+ )
+endmacro()
+
+add_subdirectory(core_only)
+add_subdirectory(gui)
+add_subdirectory(widgets)
diff --git a/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt
new file mode 100644
index 0000000000..cc68be18b8
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt
@@ -0,0 +1,4 @@
+
+project(core_only)
+
+test_testlib_project(Core)
diff --git a/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt
new file mode 100644
index 0000000000..528ec7dc4e
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt
@@ -0,0 +1,4 @@
+
+project(gui)
+
+test_testlib_project(Gui)
diff --git a/tests/auto/cmake/test_testlib_definitions/main.cpp b/tests/auto/cmake/test_testlib_definitions/main.cpp
new file mode 100644
index 0000000000..e7e9e57557
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_definitions/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QtTest>
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+public:
+ TestObject(QObject *parent = 0)
+ : QObject(parent)
+ {
+
+ }
+};
+
+QTEST_MAIN(TestObject)
+
+#include "main.moc"
diff --git a/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt
new file mode 100644
index 0000000000..0dbf9139e6
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt
@@ -0,0 +1,4 @@
+
+project(widgets)
+
+test_testlib_project(Widgets)
diff --git a/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt b/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt
new file mode 100644
index 0000000000..5da9f129d7
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt
@@ -0,0 +1,42 @@
+
+project(no_link_gui)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+find_package(Qt5Gui REQUIRED)
+find_package(Qt5Test REQUIRED)
+
+include_directories(
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Test_INCLUDE_DIRS}
+)
+
+add_definitions(
+ ${Qt5Gui_DEFINITIONS}
+ ${Qt5Test_DEFINITIONS}
+)
+
+set(main_file "main.cpp")
+set(moc_file "${CMAKE_CURRENT_BINARY_DIR}/main.moc")
+
+qt5_generate_moc("${main_file}" "${moc_file}")
+
+# The core_test is expected to fail to build because
+# QT_GUI_LIB is defined, which affects the contents of
+# QtTest and the definition of QTEST_MAIN.
+# If running this test manually (ctest -V -R no_link_gui from
+# the tests/auto/cmake/build directory), the core_test is
+# expected to fail to link because of missing symbols from QtGui.
+# The gui_test is expected to build successfully (though it may
+# be necessary to comment out the core_test and re-run cmake)
+add_executable(core_test "${main_file}" "${moc_file}")
+target_link_libraries(core_test
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+)
+
+add_executable(gui_test "${main_file}" "${moc_file}")
+target_link_libraries(gui_test
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+)
diff --git a/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt b/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt
new file mode 100644
index 0000000000..7ae8265980
--- /dev/null
+++ b/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt
@@ -0,0 +1,43 @@
+
+project(no_link_widgets)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+find_package(Qt5Widgets REQUIRED)
+find_package(Qt5Test REQUIRED)
+
+include_directories(
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Test_INCLUDE_DIRS}
+)
+
+add_definitions(
+ ${Qt5Widgets_DEFINITIONS}
+ ${Qt5Test_DEFINITIONS}
+)
+
+set(main_file "main.cpp")
+set(moc_file "${CMAKE_CURRENT_BINARY_DIR}/main.moc")
+
+qt5_generate_moc("${main_file}" "${moc_file}")
+
+# The core_test is expected to fail to build because
+# QT_WIDGETS_LIB is defined, which affects the contents of
+# QtTest and the definition of QTEST_MAIN.
+# If running this test manually (ctest -V -R no_link_widgets from
+# the tests/auto/cmake/build directory), the core_test is
+# expected to fail to link because of missing symbols from QtGui
+# and QtWidgets.
+# The widgets_test is expected to build successfully (though it may
+# be necessary to comment out the core_test and re-run cmake)
+add_executable(core_test "${main_file}" "${moc_file}")
+target_link_libraries(core_test
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+)
+
+add_executable(widgets_test "${main_file}" "${moc_file}")
+target_link_libraries(widgets_test
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+)