Skip to content

Commit 724df7d

Browse files
tejlmandrlubos
authored andcommitted
[nrf fromtree] 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]> (cherry picked from commit a5cd46b)
1 parent c2097f6 commit 724df7d

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
@@ -3596,7 +3596,8 @@ function(topological_sort)
35963596
endfunction()
35973597

35983598
# Usage:
3599-
# build_info(<tag>... VALUE <value>...)
3599+
# build_info(<tag>... VALUE <value>... )
3600+
# build_info(<tag>... PATH <path>... )
36003601
#
36013602
# This function populates updates the build_info.yml info file with exchangable build information
36023603
# related to the current build.
@@ -3613,11 +3614,20 @@ endfunction()
36133614
# <tag>...: One of the pre-defined valid CMake keys supported by build info or vendor-specific.
36143615
# See 'scripts/schemas/build-schema.yml' CMake section for valid tags.
36153616
# VALUE <value>... : value(s) to place in the build_info.yml file.
3617+
# PATH <path>... : path(s) to place in the build_info.yml file. All paths are converted to CMake
3618+
# style. If no conversion is required, for example when paths are already
3619+
# guaranteed to be CMake style, then VALUE can also be used.
36163620
function(build_info)
3621+
set(convert_path FALSE)
36173622
set(arg_list ${ARGV})
36183623
list(FIND arg_list VALUE index)
36193624
if(index EQUAL -1)
3620-
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE")
3625+
list(FIND arg_list PATH index)
3626+
set(convert_path TRUE)
3627+
endif()
3628+
3629+
if(index EQUAL -1)
3630+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE or PATH")
36213631
endif()
36223632

36233633
yaml_context(EXISTS NAME build_info result)
@@ -3635,6 +3645,15 @@ function(build_info)
36353645
list(SUBLIST arg_list ${index} -1 values)
36363646
list(POP_FRONT values)
36373647

3648+
if(convert_path)
3649+
set(converted_values)
3650+
foreach(val ${values})
3651+
cmake_path(SET cmake_path "${val}")
3652+
list(APPEND converted_values "${cmake_path}")
3653+
endforeach()
3654+
set(values "${converted_values}")
3655+
endif()
3656+
36383657
if(ARGV0 STREQUAL "vendor-specific")
36393658
set(type VALUE)
36403659
else()

0 commit comments

Comments
 (0)