diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-10-05 15:42:04 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-10-08 14:16:52 +0200 |
commit | 01bfed1d0abf438a7d5cd68cb4755377cd52b08a (patch) | |
tree | 7ffae2fffd51a9758eda13f49522567539dcc41e /cmake | |
parent | 08a0ba5733c0b01d9ff65ccffcc3b9ba77df7af9 (diff) |
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>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtLalrHelpers.cmake | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/cmake/QtLalrHelpers.cmake b/cmake/QtLalrHelpers.cmake index ce6f07007e..7c147b0597 100644 --- a/cmake/QtLalrHelpers.cmake +++ b/cmake/QtLalrHelpers.cmake @@ -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} ) |