Update add_custom_command and add_custom_target dependencies

If we don't add the executable used by the custom_target and/or
custom_command to list of the command's/target's dependencies
(DEPENDS) the generated file will not update should the executable
change.

Change-Id: Idce30f3dd4f756d9e8f6848c5e16f5dd6c7c8f0a
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Leander Beernaert 2020-01-31 14:44:52 +01:00
parent 4954adea39
commit 465949420a
6 changed files with 55 additions and 20 deletions

View File

@ -129,11 +129,15 @@ function(ecm_add_wayland_client_protocol out_var)
add_custom_command(OUTPUT "${_client_header}"
COMMAND ${WaylandScanner_EXECUTABLE} client-header ${_infile} ${_client_header}
DEPENDS ${_infile} VERBATIM)
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile}
VERBATIM
)
add_custom_command(OUTPUT "${_code}"
COMMAND ${WaylandScanner_EXECUTABLE} code ${_infile} ${_code}
DEPENDS ${_infile} ${_client_header} VERBATIM)
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile} ${_client_header}
VERBATIM
)
list(APPEND ${out_var} "${_client_header}" "${_code}")
set(${out_var} ${${out_var}} PARENT_SCOPE)
@ -160,7 +164,9 @@ function(ecm_add_wayland_server_protocol out_var)
add_custom_command(OUTPUT "${_server_header}"
COMMAND ${WaylandScanner_EXECUTABLE} server-header ${_infile} ${_server_header}
DEPENDS ${_infile} VERBATIM)
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile}
VERBATIM
)
list(APPEND ${out_var} "${_server_header}")
set(${out_var} ${${out_var}} PARENT_SCOPE)

View File

@ -3398,7 +3398,7 @@ function(qt_create_qdbusxml2cpp_command target infile)
add_custom_command(OUTPUT "${header_file}" "${source_file}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
"${header_file}:${source_file}" "${absolute_in_file_path}"
DEPENDS "${absolute_in_file_path}"
DEPENDS "${absolute_in_file_path}" ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM)
@ -3486,6 +3486,7 @@ function(qt_add_docs)
# qtattributionsscanner
add_custom_target(qattributionsscanner_${target}
DEPENDS ${qattributionsscanner_bin}
COMMAND ${qtattributionsscanner_bin}
${PROJECT_SOURCE_DIR}
--filter "QDocModule=${qdoc_target}"
@ -3518,6 +3519,7 @@ function(qt_add_docs)
)
add_custom_target(prepare_docs_${target}
DEPENDS ${qdoc_bin}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
${qdoc_bin}
${prepare_qdoc_args}
@ -3536,6 +3538,7 @@ function(qt_add_docs)
)
add_custom_target(generate_docs_${target}
DEPENDS ${qdoc_bin}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
${qdoc_bin}
${generate_qdocs_args}
@ -3553,6 +3556,7 @@ function(qt_add_docs)
)
add_custom_target(html_docs_${target}
DEPENDS ${qdoc_bin}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
${qdoc_bin}
${html_qdocs_args}
@ -3565,6 +3569,7 @@ function(qt_add_docs)
set(qch_file_path ${qdoc_output_dir}/${qch_file_name})
add_custom_target(qch_docs_${target}
DEPENDS ${qhelpgenerator_bin}
COMMAND ${qhelpgenerator_bin}
"${qdoc_output_dir}/${doc_target}.qhp"
-o "${qch_file_path}"
@ -3885,6 +3890,7 @@ function(qt_process_qlalr consuming_target input_file_list flags)
add_custom_command(
OUTPUT ${cpp_file} ${private_file} ${decl_file} ${impl_file}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr ${flags} ${input_file}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr
MAIN_DEPENDENCY ${input_file}
)
target_sources(${consuming_target} PRIVATE ${cpp_file} ${impl_file})

View File

@ -102,13 +102,15 @@ function(__qt_quick_compiler_process_resources target resource_name)
endif()
add_custom_command(
OUTPUT ${compiled_file}
DEPENDS ${file_absolute}
${QT_TOOL_PATH_SETUP_COMMAND}
COMMAND
@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen
--resource-path ${file_resource_path}
-o ${compiled_file}
${file_absolute}
--resource-path "${file_resource_path}"
-o "${compiled_file}"
"${file_absolute}"
DEPENDS
$<TARGET_FILE:@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen>
"${file_absolute}"
)
target_sources(${target} PRIVATE ${compiled_file})
endforeach()
@ -136,14 +138,16 @@ function(__qt_quick_compiler_process_resources target resource_name)
add_custom_command(
OUTPUT ${qmlcache_loader_file}
DEPENDS ${qmlcache_loader_list}
${QT_TOOL_PATH_SETUP_COMMAND}
COMMAND
@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen
${retained_args}
--resource-name "${resource_name_arg}"
-o ${qmlcache_loader_file}
-o "${qmlcache_loader_file}"
"@${qmlcache_loader_list}"
DEPENDS
$<TARGET_FILE:@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen>
"${qmlcache_loader_list}"
)
__qt_propagate_generated_resource(${target}
@ -293,7 +297,10 @@ function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
add_custom_command(OUTPUT "${generatedSourceCode}"
COMMAND "@QT_CMAKE_EXPORT_NAMESPACE@::rcc"
ARGS ${rccArgs}
DEPENDS ${resource_dependencies} ${generatedResourceFile}
DEPENDS
${resource_dependencies}
${generatedResourceFile}
"@QT_CMAKE_EXPORT_NAMESPACE@::rcc"
COMMENT "RCC ${newResourceName}"
VERBATIM)

View File

@ -270,9 +270,16 @@ function(qt6_add_binary_resources target )
endforeach()
add_custom_command(OUTPUT ${rcc_destination}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles}
DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM)
DEPENDS
${QT_CMAKE_EXPORT_NAMESPACE}::rcc
${rc_depends}
${out_depends}
${infiles}
VERBATIM)
add_custom_target(${target} ALL DEPENDS ${rcc_destination})
endfunction()
@ -324,7 +331,8 @@ function(qt6_add_resources outfiles )
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_rc_depends} "${_out_depends}" VERBATIM)
DEPENDS ${_rc_depends} "${_out_depends}" ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
VERBATIM)
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
list(APPEND ${outfiles} ${outfile})
@ -377,7 +385,8 @@ function(qt6_add_big_resources outfiles )
set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
add_custom_command(OUTPUT ${tmpoutfile}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM)
DEPENDS ${infile} ${_rc_depends} "${out_depends}" ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
VERBATIM)
add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile})
add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile})
set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOMOC OFF)
@ -388,7 +397,7 @@ function(qt6_add_big_resources outfiles )
add_custom_command(OUTPUT ${outfile}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
ARGS ${rcc_options} --name ${outfilename} --pass 2 --temp $<TARGET_OBJECTS:rcc_object_${outfilename}> --output ${outfile} ${infile}
DEPENDS rcc_object_${outfilename}
DEPENDS rcc_object_${outfilename} ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
VERBATIM)
list(APPEND ${outfiles} ${outfile})
endforeach()
@ -745,6 +754,7 @@ function(qt6_generate_meta_types_json_file target)
set(type_list_file "${target_binary_dir}/meta_types/json_file_list.txt")
add_custom_target(${target}_automoc_json_extraction
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser
BYPRODUCTS ${type_list_file}
COMMAND
${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser
@ -771,7 +781,7 @@ function(qt6_generate_meta_types_json_file target)
set(metatypes_dep_file "${target_binary_dir}/meta_types/${metatypes_dep_file_name}")
add_custom_command(OUTPUT ${metatypes_file}
DEPENDS ${type_list_file}
DEPENDS ${type_list_file} ${QT_CMAKE_EXPORT_NAMESPACE}::moc
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc
-o ${metatypes_file}
--collect-json "@${type_list_file}"

View File

@ -59,7 +59,9 @@ function(qt6_add_dbus_interface _sources _interface _basename)
add_custom_command(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${_params} -p ${_basename} ${_infile}
DEPENDS ${_infile} VERBATIM)
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
set_source_files_properties("${_impl}" "${_header}" PROPERTIES SKIP_AUTOMOC TRUE)
@ -134,7 +136,8 @@ function(qt6_generate_dbus_interface _header) # _customName OPTIONS -some -optio
add_custom_command(OUTPUT ${_target}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml ${_DBUS_INTERFACE_OPTIONS} ${_in_file} -o ${_target}
DEPENDS ${_in_file} VERBATIM
DEPENDS ${_in_file} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
endfunction()
@ -168,12 +171,14 @@ function(qt6_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optio
if(_optionalClassName)
add_custom_command(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
DEPENDS ${_infile} VERBATIM
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
else()
add_custom_command(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
DEPENDS ${_infile} VERBATIM
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
endif()

View File

@ -56,6 +56,7 @@ function(qt6_wrap_ui outfiles )
get_filename_component(infile ${it} ABSOLUTE)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
add_custom_command(OUTPUT ${outfile}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::uic
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::uic
ARGS ${ui_options} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} VERBATIM)