From e5a862303218b6c90ed702cefd20edb759f1c831 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Mon, 18 Jan 2021 17:11:20 +0100 Subject: Add arguments to 'qt_manual_moc' to resolve 'moc' includes 'qt_manual_moc' doesn't provide include paths for 'moc' command to substitute required macros. This change adds the 'INCLUDE_DIRECTORIES' and 'INCLUDE_DIRECTORY_TARGETS' arguments to the 'qt_manual_moc' function. If 'INCLUDE_DIRECTORY_TARGETS' is specified, 'qt_manual_moc' collects 'INTERFACE_INCLUDE_DIRECTORIES' of provided targets and uses them as the 'moc' include directories. Change-Id: I58c8887dae3ca2484574c5e12e2cbd47f5bd3648 Reviewed-by: Craig Scott Reviewed-by: Fabian Kosmale --- cmake/QtAutogenHelpers.cmake | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cmake/QtAutogenHelpers.cmake b/cmake/QtAutogenHelpers.cmake index f028452320..55d04b5c36 100644 --- a/cmake/QtAutogenHelpers.cmake +++ b/cmake/QtAutogenHelpers.cmake @@ -75,8 +75,15 @@ endfunction() # Complete manual moc invocation with full control. # Use AUTOMOC whenever possible. +# INCLUDE_DIRECTORIES specifies a list of include directories used by 'moc'. +# INCLUDE_DIRECTORY_TARGETS specifies a list of targets to extract the INTERFACE_INCLUDE_DIRECTORIES +# property and use it as the 'moc' include directories. function(qt_manual_moc result) - cmake_parse_arguments(arg "" "OUTPUT_MOC_JSON_FILES" "FLAGS" ${ARGN}) + cmake_parse_arguments(arg + "" + "OUTPUT_MOC_JSON_FILES" + "FLAGS;INCLUDE_DIRECTORIES;INCLUDE_DIRECTORY_TARGETS" + ${ARGN}) set(moc_files) set(metatypes_json_list) foreach(infile ${arg_UNPARSED_ARGUMENTS}) @@ -87,6 +94,17 @@ function(qt_manual_moc result) set(moc_parameters_file "${outfile}_parameters$<$>:_$>") set(moc_parameters ${arg_FLAGS} -o "${outfile}" "${infile}") + foreach(dir IN ITEMS ${arg_INCLUDE_DIRECTORIES}) + list(APPEND moc_parameters + "-I\n${dir}") + endforeach() + + foreach(dep IN ITEMS ${arg_INCLUDE_DIRECTORY_TARGETS}) + set(include_expr "$") + list(APPEND moc_parameters + "$<$:-I\n$>") + endforeach() + set(metatypes_byproducts) if (arg_OUTPUT_MOC_JSON_FILES) set(moc_json_file "${outfile}.json") -- cgit v1.2.3