From 105d47b9a62653609b6c9b928fc26969d82dfa5c Mon Sep 17 00:00:00 2001 From: buxiasen Date: Tue, 22 Oct 2024 02:09:29 +0800 Subject: [PATCH] arch/sim/cmake: remove the host specific -U when HOSTSRCS fix macos compile hostfs.c compile issue. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/_string.h:131:62: error: expected function body after function declarator 131 | char *stpncpy(char *__dst, const char *__src, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); | ^ Signed-off-by: buxiasen --- arch/sim/src/cmake/Toolchain.cmake | 23 +++++++++++++---------- arch/sim/src/sim/CMakeLists.txt | 7 +++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/sim/src/cmake/Toolchain.cmake b/arch/sim/src/cmake/Toolchain.cmake index 76be81168d..132e7c1504 100644 --- a/arch/sim/src/cmake/Toolchain.cmake +++ b/arch/sim/src/cmake/Toolchain.cmake @@ -38,16 +38,19 @@ endif() # macOS is built with __APPLE__. We #undef predefined macros for those possible # host OSes here because the OS APIs this library should use are of NuttX, not # the host OS. -add_compile_options( - -U_AIX - -U_WIN32 - -U__APPLE__ - -U__FreeBSD__ - -U__NetBSD__ - -U__linux__ - -U__sun__ - -U__unix__ - -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) + +set(SIM_NO_HOST_OPTIONS + -U_AIX + -U_WIN32 + -U__APPLE__ + -U__FreeBSD__ + -U__NetBSD__ + -U__linux__ + -U__sun__ + -U__unix__ + -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) + +add_compile_options(${SIM_NO_HOST_OPTIONS}) set(NO_LTO "-fno-lto") diff --git a/arch/sim/src/sim/CMakeLists.txt b/arch/sim/src/sim/CMakeLists.txt index 0607bb8e4d..24ae9bc7e9 100644 --- a/arch/sim/src/sim/CMakeLists.txt +++ b/arch/sim/src/sim/CMakeLists.txt @@ -288,4 +288,11 @@ endforeach() set(HOSTSRCS ${WINHOSTSRCS}) target_sources(nuttx PRIVATE ${HOSTSRCS}) + +get_target_property(HOST_COMPILE_OPTIONS nuttx COMPILE_OPTIONS) +foreach(remove_item IN LISTS SIM_NO_HOST_OPTIONS) + list(REMOVE_ITEM HOST_COMPILE_OPTIONS ${remove_item}) +endforeach() +set_target_properties(nuttx PROPERTIES COMPILE_OPTIONS + "${HOST_COMPILE_OPTIONS}") target_compile_definitions(nuttx PRIVATE ${HOST_DEFINITIONS})