Fix dbusxml2cpp custom command invocation

Use absolute paths for source files, and relative paths plus a correct
working directory for output files.

This is required to work around a limitation of the dbusxml2cpp tool
where it splits a command line option on a colon ":". Windows paths
contain colons, and that breaks the internal logic of the tool when
passing absolute paths.

Change-Id: Ic653f1317ae4f68bb2f488c117fe48c34310c76e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
bb10
Alexandru Croitor 2019-04-16 12:53:24 +02:00
parent 51b7fbb626
commit 5fd882803e
1 changed files with 11 additions and 5 deletions

View File

@ -1161,14 +1161,20 @@ function(qt_create_qdbusxml2cpp_command target infile)
set(file_name ${arg_BASENAME})
endif()
# Use absolute file path for the source file and set the current working directory to the
# current binary directory, because setting an absolute path for the header:source combo option
# does not work. Splitting on ":" breaks inside the dbus tool when running on Windows
# due to ":" being contained in the drive path (e.g C:\foo.h:C:\foo.cpp).
get_filename_component(absolute_in_file_path "${infile}" ABSOLUTE)
set(header_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h")
set(source_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.cpp")
set(header_file "${file_name}.h")
set(source_file "${file_name}.cpp")
add_custom_command(OUTPUT "${header_file}" "${source_file}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}" "${header_file}:${source_file}" "${infile}"
DEPENDS "${infile}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
"${header_file}:${source_file}" "${absolute_in_file_path}"
DEPENDS "${absolute_in_file_path}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM)
target_sources("${target}" PRIVATE "${header_file}" "${source_file}")