CMake: Enable higher compiler warnings for building Qt Creator

The functionality comes from Qt6 and will be enabled only for Qt6 builds.

/w3 level for MSVC, -Wall -Wextra for the rest of compilers.

Change-Id: Ib62a27e50ce37a6a860ba2bfa1bdb80a7ae60ace
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2022-02-24 14:53:36 +01:00
parent 79726e52d6
commit 47667772c7
2 changed files with 8 additions and 1 deletions

View File

@@ -68,10 +68,14 @@ if (Qt5_VERSION VERSION_LESS 6.0.0)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
add_compile_options(-Wno-missing-field-initializers)
endif()
endif()
else()
# Common intermediate directory for QML modules which are defined via qt_add_qml_module()
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml_modules")
# This includes the code that will enable higher compiler warnings level (/W3 for MSVC, -Wall -Wextra for GCC)
# This is controlled by QT_COMPILE_OPTIONS_DISABLE_WARNINGS target property.
include(QtCompilerFlags)
endif()
find_package(Qt5 COMPONENTS LinguistTools QUIET)
find_package(Qt5 COMPONENTS Quick QuickWidgets Designer DesignerComponents Help SerialPort Svg Tools QUIET)

View File

@@ -233,6 +233,7 @@ function(add_qtc_library name)
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
LIBRARY_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_ARCHIVE_PATH}"
QT_COMPILE_OPTIONS_DISABLE_WARNINGS OFF
${_arg_PROPERTIES}
)
@@ -485,6 +486,7 @@ function(add_qtc_plugin target_name)
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
OUTPUT_NAME "${name}"
QT_SKIP_TRANSLATION "${skip_translation}"
QT_COMPILE_OPTIONS_DISABLE_WARNINGS OFF
${_arg_PROPERTIES}
)
@@ -667,6 +669,7 @@ function(add_qtc_executable name)
CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
QT_COMPILE_OPTIONS_DISABLE_WARNINGS OFF
${_arg_PROPERTIES}
)
if (NOT _arg_SKIP_PCH)