CMake: Make sure that explicit plugin.h files depend on the json file

ClangCodeModel plugin was not updating its version number because of
the EXPLICIT_MOC call.

Change-Id: I109d80c93d8af628c8981d49c93dcb0ebe21f1ee
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2019-11-07 14:56:15 +01:00
parent f930fb2b75
commit eebf36adc7

View File

@@ -171,8 +171,12 @@ function(separate_object_libraries libraries REGULAR_LIBS OBJECT_LIBS OBJECT_LIB
endfunction(separate_object_libraries) endfunction(separate_object_libraries)
function(set_explicit_moc target_name file) function(set_explicit_moc target_name file)
unset(file_dependencies)
if (file MATCHES "^.*plugin.h$")
set(file_dependencies DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.json")
endif()
set_property(SOURCE "${file}" PROPERTY SKIP_AUTOMOC ON) set_property(SOURCE "${file}" PROPERTY SKIP_AUTOMOC ON)
qt5_wrap_cpp(file_moc "${file}") qt5_wrap_cpp(file_moc "${file}" ${file_dependencies})
target_sources(${target_name} PRIVATE "${file_moc}") target_sources(${target_name} PRIVATE "${file_moc}")
endfunction() endfunction()