Skip to content

Commit a5cd46b

Browse files
tejlmandnashif
authored andcommitted
cmake: support PATH argument in build_info()
Support PATH argument in build_info() function. The PATH argument can be used to provide a list of paths paths and that those paths might be using native style, such as `c:\win\path', and therefore should be converted to CMake style path. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 121cb49 commit a5cd46b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmake/modules/extensions.cmake

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,8 @@ function(topological_sort)
36583658
endfunction()
36593659

36603660
# Usage:
3661-
# build_info(<tag>... VALUE <value>...)
3661+
# build_info(<tag>... VALUE <value>... )
3662+
# build_info(<tag>... PATH <path>... )
36623663
#
36633664
# This function populates updates the build_info.yml info file with exchangable build information
36643665
# related to the current build.
@@ -3675,11 +3676,20 @@ endfunction()
36753676
# <tag>...: One of the pre-defined valid CMake keys supported by build info or vendor-specific.
36763677
# See 'scripts/schemas/build-schema.yml' CMake section for valid tags.
36773678
# VALUE <value>... : value(s) to place in the build_info.yml file.
3679+
# PATH <path>... : path(s) to place in the build_info.yml file. All paths are converted to CMake
3680+
# style. If no conversion is required, for example when paths are already
3681+
# guaranteed to be CMake style, then VALUE can also be used.
36783682
function(build_info)
3683+
set(convert_path FALSE)
36793684
set(arg_list ${ARGV})
36803685
list(FIND arg_list VALUE index)
36813686
if(index EQUAL -1)
3682-
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE")
3687+
list(FIND arg_list PATH index)
3688+
set(convert_path TRUE)
3689+
endif()
3690+
3691+
if(index EQUAL -1)
3692+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE or PATH")
36833693
endif()
36843694

36853695
yaml_context(EXISTS NAME build_info result)
@@ -3697,6 +3707,15 @@ function(build_info)
36973707
list(SUBLIST arg_list ${index} -1 values)
36983708
list(POP_FRONT values)
36993709

3710+
if(convert_path)
3711+
set(converted_values)
3712+
foreach(val ${values})
3713+
cmake_path(SET cmake_path "${val}")
3714+
list(APPEND converted_values "${cmake_path}")
3715+
endforeach()
3716+
set(values "${converted_values}")
3717+
endif()
3718+
37003719
if(ARGV0 STREQUAL "vendor-specific")
37013720
set(type VALUE)
37023721
else()

0 commit comments

Comments
 (0)