summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDaniel Levin <dendy.ua@gmail.com>2015-01-19 01:18:39 -0500
committerKevin Funk <kevin.funk@kdab.com>2015-12-21 16:05:36 +0000
commita206583da1bee8fdc90b58bbc8d067ba724de203 (patch)
treeb203a7f269cba7403a9701863d31fdd734b1c393 /src/corelib
parent32e4546cc3b38dd8a15eaac07dc79c48acea5ce7 (diff)
Add DEPENDS option to qt5_wrap_cpp()
Currently the moc rule does not support dependency scanning, so after successful moc file generation it will ignore implicit dependencies in the header file. Although this works in most typical scenarios, at least in one case incremental builds become broken: when using Q_PLUGIN_METADATA() with the FILE argument. If FILE refers to a JSON file and latter was updated, then the expected behavior is to regenerate the moc file. Since CMake add_custom_command() does not support late dependency setup, all dependencies should be explicitly listed in a DEPENDS section. This patch adds the DEPENDS multiarg option to qt5_wrap_cpp(), allowing to specify additional dependencies to the moc rule. Task-number: QTBUG-44009 Change-Id: I2052ce23d3cb0c87c6bd99fcb7e8a71a7be9a330 Reviewed-by: Kevin Funk <kevin.funk@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Daniel Levin <dendy.ua@gmail.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreMacros.cmake11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 18563764ad..c441d3ad73 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -94,7 +94,7 @@ endmacro()
# helper macro to set up a moc rule
-macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
+macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends)
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
@@ -131,7 +131,7 @@ macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
set(_moc_extra_parameters_file @${_moc_parameters_file})
add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
- DEPENDS ${infile}
+ DEPENDS ${infile} ${moc_depends}
${_moc_working_dir}
VERBATIM)
endmacro()
@@ -151,7 +151,7 @@ function(QT5_GENERATE_MOC infile outfile )
endif()
set(moc_target ${ARGV3})
endif()
- qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
+ qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
endfunction()
@@ -164,13 +164,14 @@ function(QT5_WRAP_CPP outfiles )
set(options)
set(oneValueArgs TARGET)
- set(multiValueArgs OPTIONS)
+ set(multiValueArgs OPTIONS DEPENDS)
cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
set(moc_options ${_WRAP_CPP_OPTIONS})
set(moc_target ${_WRAP_CPP_TARGET})
+ set(moc_depends ${_WRAP_CPP_DEPENDS})
if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
@@ -178,7 +179,7 @@ function(QT5_WRAP_CPP outfiles )
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
- qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
+ qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)