cmake: Unify the set flags between AUTOMOC and qt_wrap_cpp
For AUTOMOC, we were missing the compiler flavor flag, as well as the WIN32 define. While the latter has not caused any known issues yet, the former is rather problematic for implementing __has_include in moc. Note that this only applies in the case where the AUTOMOC flags are set by us in a qt_ function like qt_add_excutable. Plain add_executable won't benefit from it, but we already mention that Qt targets should not use plain CMake functions. This change is (indirectly) tested by the commit adding __has_include support for moc. Task-number: QTBUG-136097 Pick-to: 6.10 6.9 6.8 Change-Id: Ie2beb08a44a3a67e3bc363d9c1ba93b7d6a49133 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
9a7d06f0d4
commit
246b43d581
@ -166,6 +166,9 @@ function(qt_manual_moc result)
|
||||
set(metatypes_byproducts "${outfile}.json")
|
||||
endif()
|
||||
|
||||
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
|
||||
list(APPEND moc_parameters ${flavor_flags})
|
||||
|
||||
if (TARGET Qt::Platform)
|
||||
get_target_property(_abi_tag Qt::Platform qt_libcpp_abi_tag)
|
||||
if (_abi_tag)
|
||||
|
@ -968,3 +968,15 @@ function(_qt_internal_append_cmake_configure_depends)
|
||||
endforeach()
|
||||
set_property(DIRECTORY PROPERTY CMAKE_CONFIGURE_DEPENDS "${configure_depends}")
|
||||
endfunction()
|
||||
|
||||
function(_qt_internal_get_moc_compiler_flavor_flags out_var)
|
||||
set(flags "")
|
||||
if(WIN32)
|
||||
list(APPEND flags -DWIN32)
|
||||
endif()
|
||||
if(MSVC)
|
||||
list(APPEND flags --compiler-flavor=msvc)
|
||||
endif()
|
||||
|
||||
set(${out_var} "${flags}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -195,9 +195,11 @@ function(qt_internal_extend_target target)
|
||||
${private_visibility_option} ${arg_LINK_OPTIONS})
|
||||
|
||||
if(NOT is_interface_lib)
|
||||
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
|
||||
set_property(TARGET "${target}" APPEND PROPERTY
|
||||
AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}"
|
||||
AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}" ${flavor_flags}
|
||||
)
|
||||
|
||||
# Plugin types associated to a module
|
||||
if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x")
|
||||
qt_internal_add_plugin_types("${target}" "${arg_PLUGIN_TYPES}")
|
||||
|
@ -67,12 +67,8 @@ macro(_qt_internal_get_moc_flags _moc_flags)
|
||||
set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
|
||||
endforeach()
|
||||
|
||||
if(WIN32)
|
||||
set(${_moc_flags} ${${_moc_flags}} -DWIN32)
|
||||
endif()
|
||||
if (MSVC)
|
||||
set(${_moc_flags} ${${_moc_flags}} --compiler-flavor=msvc)
|
||||
endif()
|
||||
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
|
||||
set(${_moc_flags} ${${_moc_flags}} ${flavor_flags})
|
||||
endmacro()
|
||||
|
||||
# helper macro to set up a moc rule
|
||||
@ -96,6 +92,9 @@ function(_qt_internal_create_moc_command infile outfile moc_flags moc_options
|
||||
set(${out_json_file} "${extra_output_files}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
|
||||
list(APPEND _moc_parameters ${flavor_flags})
|
||||
|
||||
if(moc_target)
|
||||
set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIG>>:_$<CONFIG>>)
|
||||
set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
|
||||
@ -832,12 +831,16 @@ function(qt6_finalize_target target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(is_immediately_finalized "${target}" _qt_is_immediately_finalized)
|
||||
get_target_property(uses_automoc ${target} AUTOMOC)
|
||||
if(uses_automoc)
|
||||
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
|
||||
set_property(TARGET "${target}" APPEND PROPERTY AUTOMOC_MOC_OPTIONS ${flavor_flags})
|
||||
endif()
|
||||
if(target_type STREQUAL "SHARED_LIBRARY" OR
|
||||
target_type STREQUAL "STATIC_LIBRARY" OR
|
||||
target_type STREQUAL "MODULE_LIBRARY" OR
|
||||
target_type STREQUAL "OBJECT_LIBRARY")
|
||||
get_target_property(is_immediately_finalized "${target}" _qt_is_immediately_finalized)
|
||||
get_target_property(uses_automoc ${target} AUTOMOC)
|
||||
if(uses_automoc AND NOT is_immediately_finalized)
|
||||
qt6_extract_metatypes(${target})
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user