diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-03-21 16:32:53 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-03-22 15:23:32 +0100 |
commit | 67cc5e56e2012b4dc173a7293089e447ca335bb8 (patch) | |
tree | b572740b34e733c4aa4b2e7ed2b9ebf0b153bba7 /src/qml/Qt6QmlMacros.cmake | |
parent | 18acf564fa04922f482381ac57754c4624c13705 (diff) |
CMake: Fix semicolon warnings for generated qml resources code
Fixes clang warnings when -Wextra-semi or -Wextra-semi-stmt are
enabled.
Sample warnings:
warning: empty expression statement has no effect; remove
unnecessary ';' to silence this warning [-Wextra-semi-stmt]
resourceReferenceKeeper() { QT_KEEP_RESOURCE(qmake_baz); }
warning: extra ';' outside of a function is incompatible with C++98
[-Wc++98-compat-extra-semi]
QT_DECLARE_EXTERN_RESOURCE(qmake_foo);
warning: extra ';' outside of a function is incompatible with C++98
[-Wc++98-compat-extra-semi]
QT_DECLARE_EXTERN_SYMBOL_VOID(qml_register_bar);
Pick-to: 6.7
Fixes: QTBUG-123588
Change-Id: I1d17030f435c1f9eaae25af0cafd0383e79e5e73
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index b6cdbeed0d..e2c706e011 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -822,12 +822,15 @@ endmacro() # Creates a genex that will call a c++ macro on each of the list values. # Handles empty lists. -macro(_qt_internal_genex_get_list_joined_with_macro var input_list macro_name) +macro(_qt_internal_genex_get_list_joined_with_macro var input_list macro_name with_ending_semicolon) set(${var} "${input_list}") set(have_${var} "$<BOOL:${${var}}>") set(_macro_begin "${macro_name}(") - set(_macro_end ");") + set(_macro_end ")") + if(with_ending_semicolon) + string(APPEND _macro_end ";") + endif() set(_macro_glue "${_macro_end}\n${_macro_begin}") string(JOIN "" ${var} @@ -845,9 +848,11 @@ endmacro() # Reads a target property that contains a list of values and creates a genex that will # call a c++ macro on each of the values. # Handles empty properties. -macro(_qt_internal_genex_get_property_joined_with_macro var target property macro_name) +macro(_qt_internal_genex_get_property_joined_with_macro var target property macro_name + with_ending_semicolon) _qt_internal_genex_getproperty(${var} ${target} ${property}) - _qt_internal_genex_get_list_joined_with_macro("${var}" "${${var}}" "${macro_name}") + _qt_internal_genex_get_list_joined_with_macro("${var}" "${${var}}" "${macro_name}" + "${with_ending_semicolon}") endmacro() macro(_qt_internal_genex_getoption var target property) @@ -1680,10 +1685,12 @@ endif() # Get extern declaration for types registration function. function(_qt_internal_qml_get_types_extern_declaration register_types_function_name out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_list_joined_with_macro( content "${register_types_function_name}" "QT_DECLARE_EXTERN_SYMBOL_VOID" + ${with_ending_semicolon} ) string(PREPEND content "\n") @@ -1693,10 +1700,12 @@ endfunction() # Get code block that should reference the types registration function in the plugin constructor. # Ensures the symbol is not discarded when linking. function(_qt_internal_qml_get_types_keep_reference register_types_function_name out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_list_joined_with_macro( content "${register_types_function_name}" "QT_KEEP_SYMBOL" + ${with_ending_semicolon} ) string(PREPEND content "\n") @@ -1705,11 +1714,13 @@ endfunction() # Get extern declaration for cachegen resource. function(_qt_internal_qml_get_cachegen_extern_resource_declaration target out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_property_joined_with_macro( content "${target}" "_qt_cachegen_sanitized_resource_name" "QT_DECLARE_EXTERN_RESOURCE" + ${with_ending_semicolon} ) string(PREPEND content "\n") @@ -1719,11 +1730,13 @@ endfunction() # Get code block that should reference the cachegen resource in the plugin constructor. # Ensures the resource is not discarded when linking. function(_qt_internal_qml_get_cachegen_resource_keep_reference target out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_property_joined_with_macro( content "${target}" "_qt_cachegen_sanitized_resource_name" "QT_KEEP_RESOURCE" + ${with_ending_semicolon} ) string(PREPEND content "\n") @@ -1732,11 +1745,13 @@ endfunction() # Get extern declaration for a regular resource. function(_qt_internal_qml_get_resource_extern_declarations target out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_property_joined_with_macro( content "${target}" "_qt_qml_module_sanitized_resource_names" "QT_DECLARE_EXTERN_RESOURCE" + ${with_ending_semicolon} ) string(PREPEND content "\n") @@ -1746,11 +1761,13 @@ endfunction() # Get code block that should reference regular resources in the plugin constructor. # Ensures the resources are not discarded when linking. function(_qt_internal_qml_get_resource_keep_references target out_var) + set(with_ending_semicolon FALSE) _qt_internal_genex_get_property_joined_with_macro( content "${target}" "_qt_qml_module_sanitized_resource_names" "QT_KEEP_RESOURCE" + ${with_ending_semicolon} ) string(PREPEND content "\n") |