cmake: Fix SIM_TOOLCHAIN using CMake on macOS.

Fix an issue where `SIM_TOOLCHAIN_GCC` was incorrectly set when
configuring `sim:nsh` using CMake on macOS.
Ensure that `nuttx_sethost()` is called before `nuttx_olddefconfig()`.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
This commit is contained in:
Shoji Tokunaga 2026-05-23 04:21:20 +09:00 committed by Alin Jerpelea
parent cdd10a604b
commit 08a2de27cf
3 changed files with 35 additions and 6 deletions

View file

@ -231,9 +231,25 @@ function(nuttx_olddefconfig)
endfunction()
function(nuttx_setconfig)
set(ENV{KCONFIG_CONFIG} ${CMAKE_BINARY_DIR}/.config)
cmake_parse_arguments(SETCONFIG "" "CONFIG_FILE" "SETTINGS" ${ARGN})
if(SETCONFIG_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR
"nuttx_setconfig: unknown arguments: ${SETCONFIG_UNPARSED_ARGUMENTS}")
endif()
if(NOT SETCONFIG_SETTINGS)
message(FATAL_ERROR "nuttx_setconfig: SETTINGS is required")
endif()
if(NOT SETCONFIG_CONFIG_FILE)
set(SETCONFIG_CONFIG_FILE ${CMAKE_BINARY_DIR}/.config)
endif()
set(ENV{KCONFIG_CONFIG} ${SETCONFIG_CONFIG_FILE})
execute_process(
COMMAND setconfig ${ARGN} --kconfig ${NUTTX_DIR}/Kconfig
COMMAND setconfig ${SETCONFIG_SETTINGS} --kconfig ${NUTTX_DIR}/Kconfig
ERROR_VARIABLE KCONFIG_ERROR
OUTPUT_VARIABLE KCONFIG_OUTPUT
RESULT_VARIABLE KCONFIG_STATUS

View file

@ -23,6 +23,18 @@
include(nuttx_kconfig)
function(nuttx_sethost)
set(config_file ${CMAKE_BINARY_DIR}/.config)
cmake_parse_arguments(SETHOST "" "CONFIG_FILE" "" ${ARGN})
if(SETHOST_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR
"nuttx_sethost: unknown arguments: ${SETHOST_UNPARSED_ARGUMENTS}")
endif()
if(SETHOST_CONFIG_FILE)
set(config_file ${SETHOST_CONFIG_FILE})
endif()
if(CMAKE_HOST_WIN32)
# https://learn.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details
@ -104,5 +116,5 @@ function(nuttx_sethost)
endif()
endif()
# message(" nuttx_setconfig: ${NUTTX_SYSTEM_SETHOST}")
nuttx_setconfig("${NUTTX_SYSTEM_SETHOST}")
nuttx_setconfig(CONFIG_FILE ${config_file} SETTINGS ${NUTTX_SYSTEM_SETHOST})
endfunction()