diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
index db06747ed12c2faf91ad6edca22ee28b948a1fb6..86aa9c3ca6ecd214dc7a4f8e74c8b526163bc338 100644
--- a/tests/auto/cmake/cmake.pro
+++ b/tests/auto/cmake/cmake.pro
@@ -2,6 +2,8 @@
 # Cause make to do nothing.
 TEMPLATE = subdirs
 
-qtHaveModule(widgets): CMAKE_QT_MODULES_UNDER_TEST = designer help uitools
+qtHaveModule(widgets) {
+    CMAKE_QT_MODULES_UNDER_TEST = designer help uitools
 
-CONFIG += ctest_testcase
+    CONFIG += ctest_testcase
+}