From f95d904d0e63846c0ebe71980b2fe75e8c262b40 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 27 Aug 2024 17:18:27 +0300 Subject: [PATCH] Build: Suppress moc warnings when building without tests Many source files have Q_OBJECT inside #ifdef WITH_TESTS. Automoc uses a very basic parser that detects this file as mocable, but moc shows a warning: "No relevant classes found." Just suppress the warning on this case. See also upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/26224 Fixes: QTCREATORBUG-31492 Change-Id: Idea7b05b4faf4011d7e1ecb44495341d73654170 Reviewed-by: Alexandru Croitor Reviewed-by: Orkun Tokdemir Reviewed-by: Eike Ziller --- cmake/QtCreatorAPI.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 5d39157b020..6da6bdbcd15 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -482,6 +482,12 @@ function(add_qtc_plugin target_name) if (WITH_TESTS) set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") + else() + # Many source files have Q_OBJECT inside #ifdef WITH_TESTS. Automoc uses + # a very basic parser that detects this file as mocable, but moc shows a + # warning: "No relevant classes found." + # Just suppress the warning on this case. + set_target_properties(${target_name} PROPERTIES AUTOMOC_MOC_OPTIONS "-nw") endif() if (WITH_SANITIZE)