From 45cb8be4f9ab2b5b823dda104376b159c9123163 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 18 Jul 2012 22:25:56 +0200 Subject: Add tests of the various testlib definition possibilities. The behavior of QTEST_MAIN depends on whether QT_GUI_LIB or QT_WIDGETS_LIB is defined. It could create a QGuiApplication or QApplication which could cause linking issues if the corresponding library is not linked to. The failure cases are also tested. Change-Id: I61ed0bc760564ef42ce1dbd86c83c06348c860ff Reviewed-by: Rohan McGovern --- .../cmake/test_testlib_no_link_gui/CMakeLists.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt (limited to 'tests/auto/cmake/test_testlib_no_link_gui') 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} +) -- cgit v1.2.3