CMake: Generate relative #line directives in qlalr output
When passing an absolute input file name to qlalr, the #line directives in the output will contain absolute paths. For reproducible builds, it's desirable to have relative paths. Pass the input file as relative path to qlalr to produce relative #line directives. Fixes: QTBUG-96267 Change-Id: I4ef1e4d5be7cbaf25a54a34ab7c2dbec06411a1d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
08a0ba5733
commit
01bfed1d0a
@ -39,13 +39,22 @@ function(qt_process_qlalr consuming_target input_file_list flags)
|
||||
qt_qlalr_find_option_in_list("${input_file_lines}" "^%impl(.+)" "impl")
|
||||
get_filename_component(base_file_name ${input_file} NAME_WE)
|
||||
|
||||
# Pass a relative input file path to qlalr to generate relative #line directives.
|
||||
if(IS_ABSOLUTE "${input_file}")
|
||||
set(absolute_input_file "${input_file}")
|
||||
else()
|
||||
get_filename_component(absolute_input_file "${input_file}" ABSOLUTE)
|
||||
endif()
|
||||
file(RELATIVE_PATH relative_input_file "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${absolute_input_file}")
|
||||
|
||||
set(cpp_file "${parser}.cpp")
|
||||
set(private_file "${parser}_p.h")
|
||||
set(decl_file "${decl}")
|
||||
set(impl_file "${impl}")
|
||||
add_custom_command(
|
||||
OUTPUT ${cpp_file} ${private_file} ${decl_file} ${impl_file}
|
||||
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr ${flags} ${input_file}
|
||||
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr ${flags} ${relative_input_file}
|
||||
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr
|
||||
MAIN_DEPENDENCY ${input_file}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user