File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,15 @@ get_property(CCACHE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
7
7
target_link_options (native_simulator INTERFACE
8
8
"-T ${ZEPHYR_BASE} /boards/native/common/natsim_linker_script.ld" )
9
9
10
+ if (SYSROOT_DIR )
11
+ message (NOTICE "Appending --sysroot=${SYSROOT_DIR} to native_simulator" )
12
+ target_compile_options (native_simulator INTERFACE "--sysroot=${SYSROOT_DIR} " )
13
+ target_link_options (native_simulator INTERFACE "--sysroot=${SYSROOT_DIR} " )
14
+ endif ()
15
+
10
16
set (nsi_config_content
11
17
${nsi_config_content}
18
+ "NSI_AR:=${CMAKE_AR} "
12
19
"NSI_BUILD_OPTIONS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,INTERFACE_COMPILE_OPTIONS>,\ >"
13
20
"NSI_BUILD_PATH:=${zephyr_build_path} /NSI"
14
21
"NSI_CC:=${CCACHE} ${CMAKE_C_COMPILER} "
@@ -21,9 +28,11 @@ set(nsi_config_content
21
28
"NSI_PATH:=${NSI_DIR} /"
22
29
"NSI_N_CPUS:=${CONFIG_NATIVE_SIMULATOR_NUMBER_MCUS} "
23
30
"NSI_LOCALIZE_OPTIONS:=--localize-symbol=CONFIG_* $<JOIN:$<TARGET_PROPERTY:native_simulator,LOCALIZE_EXTRA_OPTIONS>,\ >"
31
+ "NSI_BUILD_VERBOSE:=1"
24
32
)
25
33
26
34
string (REPLACE ";" "\n " nsi_config_content "${nsi_config_content} " )
35
+ message (NOTICE "NSI Config:\n ${nsi_config_content} " )
27
36
28
37
file (GENERATE OUTPUT "${zephyr_build_path} /NSI/nsi_config"
29
38
CONTENT "${nsi_config_content} "
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ endif()
18
18
find_program (CMAKE_C_COMPILER clang ${find_program_clang_args} )
19
19
find_program (CMAKE_CXX_COMPILER clang++ ${find_program_clang_args} )
20
20
21
+ if (SYSROOT_DIR )
22
+ # The toolchain has specified a sysroot dir, pass it to the compiler
23
+ list (APPEND TOOLCHAIN_C_FLAGS "--sysroot=${SYSROOT_DIR} " )
24
+ list (APPEND TOOLCHAIN_LD_FLAGS "--sysroot=${SYSROOT_DIR} " )
25
+ endif ()
26
+
21
27
if (NOT "${ARCH} " STREQUAL "posix" )
22
28
include (${ZEPHYR_BASE} /cmake/gcc-m-cpu.cmake )
23
29
include (${ZEPHYR_BASE} /cmake/gcc-m-fpu.cmake )
@@ -72,7 +78,8 @@ if(NOT "${ARCH}" STREQUAL "posix")
72
78
#
73
79
# Other clang/LLVM distributions may come with other pre-built C libraries.
74
80
# clang/LLVM supports using an alternative C library, either by direct linking,
75
- # or by specifying '--sysroot <path>'.
81
+ # or by specifying '--sysroot <path>'. Sysroot can also be passed using the
82
+ # CMake variable SYSROOT_DIR which will append the '--sysroot <path>' flags.
76
83
#
77
84
# LLVM for Arm provides a 'newlib.cfg' file for newlib C selection.
78
85
# Let us support this principle by looking for a dedicated 'newlib.cfg' or
You can’t perform that action at this time.
0 commit comments