summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2020-02-03 16:52:18 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2020-02-05 15:18:03 +0000
commit20bb59ca61e6e40e04092771d8f1116dc011f9bc (patch)
tree6d707b75a91257a4a747f0f30092454bcfeab7ca /cmake
parentac38fa11823f4cf020a9481c9de3d61caa8fccdc (diff)
Allow manually specification of moc.json files for metatype generation
qt6_generate_meta_types_json_file() has been extended to allow the generated moc_....cpp.json files to be manually specified. This now enabled the metatype generation to be used without resorting to AUTOMOC. Additionally, Core_qobject declaration order has been temporarily moved as it otherwise does not produce the correct metatypes dependency file for Core. This will be fixed in a follow up patch. Change-Id: I3266ab3073db478458a0c1dbc8b9fbab16622a64 Reviewed-by: Qt CMake Build Bot Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake19
1 files changed, 17 insertions, 2 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 5246f533f5..058a0fde7e 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -3335,8 +3335,9 @@ endfunction()
# Complete manual moc invocation with full control.
# Use AUTOMOC whenever possible.
function(qt_manual_moc result)
- cmake_parse_arguments(arg "" "" "FLAGS" ${ARGN})
+ cmake_parse_arguments(arg "" "OUTPUT_MOC_JSON_FILES" "FLAGS" ${ARGN})
set(moc_files)
+ set(metatypes_json_list)
foreach(infile ${arg_UNPARSED_ARGUMENTS})
qt_make_output_file("${infile}" "moc_" ".cpp"
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" outfile)
@@ -3344,16 +3345,30 @@ function(qt_manual_moc result)
set(moc_parameters_file "${outfile}_parameters$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>")
set(moc_parameters ${arg_FLAGS} -o "${outfile}" "${infile}")
+
+ set(metatypes_byproducts)
+ if (arg_OUTPUT_MOC_JSON_FILES)
+ set(moc_json_file "${outfile}.json")
+ list(APPEND moc_parameters --output-json)
+ list(APPEND metatypes_json_list "${outfile}.json")
+ set(metatypes_byproducts "${outfile}.json")
+ endif()
+
string (REPLACE ";" "\n" moc_parameters "${moc_parameters}")
file(GENERATE OUTPUT "${moc_parameters_file}" CONTENT "${moc_parameters}\n")
- add_custom_command(OUTPUT "${outfile}"
+ add_custom_command(OUTPUT "${outfile}" ${metatypes_byproducts}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc "@${moc_parameters_file}"
DEPENDS "${infile}" ${moc_depends} ${QT_CMAKE_EXPORT_NAMESPACE}::moc
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM)
endforeach()
set("${result}" ${moc_files} PARENT_SCOPE)
+
+ # Register generated json files
+ if (arg_OUTPUT_MOC_JSON_FILES)
+ set(${arg_OUTPUT_MOC_JSON_FILES} "${metatypes_json_list}" PARENT_SCOPE)
+ endif()
endfunction()