summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-03-15 17:03:38 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-07 06:33:47 +0000
commit37801c6c537ef8e79094b405e64481a0246330a0 (patch)
treed6f846a3359a4976a70df6ed77f154274df35c0c /tests/auto/cmake
parentc197629f8035023353c2ab678a46e212477f1536 (diff)
CMake: Build minimal subset of tests in desktop static builds
Add new configure option -make minimal-static-tests and CMake option QT_BUILD_MINIMAL_STATIC_TESTS. In conjunction with QT_BUILD_TESTS it will enable building a minimal subset of tests when targeting a static desktop Qt build. In qtbase the minimal subset includes all the auto tests of testlib, tools, corelib and cmake. In particular this will also do cmake build tests and qmake build tests (tst_qmake) Adjust CI instructions to enable building a minimal subset of static tests when a platform configuration is tagged with the MinimalStaticTests feature. Fix and skip a few tests that were failing. Task-number: QTBUG-87580 Task-number: QTBUG-91869 Change-Id: I1fc311b8d5e743ccf05047fb9a7fdb813a645206 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 0e6c4224f00999d4089d7c2ac462bb5a60a14adc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r--tests/auto/cmake/test_interface/CMakeLists.txt20
-rw-r--r--tests/auto/cmake/test_interface/widget_test/CMakeLists.txt12
-rw-r--r--tests/auto/cmake/test_interface/widget_test/main.cpp4
3 files changed, 22 insertions, 14 deletions
diff --git a/tests/auto/cmake/test_interface/CMakeLists.txt b/tests/auto/cmake/test_interface/CMakeLists.txt
index 0cae16668e..d874ac561d 100644
--- a/tests/auto/cmake/test_interface/CMakeLists.txt
+++ b/tests/auto/cmake/test_interface/CMakeLists.txt
@@ -14,23 +14,15 @@ add_executable(test_interface_exe WIN32 main.cpp mainwindow.cpp)
# link explicitly to Qt::WinMain.
target_link_libraries(test_interface_exe Qt::Widgets)
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
- "
-#include <QString>
-#include <QWidget>
-
-int main(int,char**) { QWidget w; w.show(); return 0; }
-"
-)
-
# Fix try_compile to inherit the parent configuration.
set(CMAKE_TRY_COMPILE_CONFIGURATION "${CMAKE_BUILD_TYPE}")
-# The try_compile works because Qt::Widgets is listed in the LINK_LIBRARIES,
-# which causes the includes, defines and appropriate PIC flag to be used.
-try_compile(_TRY_COMPILE_RES "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test"
- "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
- LINK_LIBRARIES Qt::Widgets
+# Can't use source file based try_compile, because it doesn't handle object libraries
+# referenced in generator expressions properly.
+try_compile(_TRY_COMPILE_RES
+ "${CMAKE_CURRENT_BINARY_DIR}/widget_test"
+ "${CMAKE_CURRENT_SOURCE_DIR}/widget_test"
+ widget_test
OUTPUT_VARIABLE TC_OV
)
diff --git a/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
new file mode 100644
index 0000000000..679d01ef63
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.14)
+
+project(test_interface_try_compile)
+
+find_package(Qt6Widgets)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(test_interface_try_compile_exe main.cpp)
+target_link_libraries(test_interface_try_compile_exe Qt::Widgets)
+
diff --git a/tests/auto/cmake/test_interface/widget_test/main.cpp b/tests/auto/cmake/test_interface/widget_test/main.cpp
new file mode 100644
index 0000000000..e6a8ab5fe9
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/main.cpp
@@ -0,0 +1,4 @@
+#include <QString>
+#include <QWidget>
+
+int main(int, char**) { QWidget w; w.show(); return 0; }