cmake: cater for BSD stat command on MacOS X

MacOS X has a BSD-style `stat`, this commit selects the `stat` command
line arguments based on the host OS.

As a small step towards enabling building the kernel on MacOS X, at
least to the degree that kernel.elf can be produced as needed in
verification.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
This commit is contained in:
Gerwin Klein
2022-01-27 13:36:24 +11:00
committed by Gerwin Klein
parent 4de3d4f5d9
commit 7963343a74

View File

@@ -152,10 +152,15 @@ if(DEFINED KernelDTSList AND (NOT "${KernelDTSList}" STREQUAL ""))
if(error)
message(FATAL_ERROR "Failed to compile DTS to DTB: ${KernelDTBPath}")
endif()
# CMAKE_HOST_APPLE is a built-in CMake variable
if(CMAKE_HOST_APPLE)
set(STAT_ARGS "-f%z")
else()
set(STAT_ARGS "-c '%s'")
endif()
# Track the size of the DTB for downstream tools
execute_process(
COMMAND
${STAT_TOOL} -c '%s' ${KernelDTBPath}
COMMAND ${STAT_TOOL} ${STAT_ARGS} ${KernelDTBPath}
OUTPUT_VARIABLE KernelDTBSize
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE error