build(sim): fix macOS XQuartz include and library paths for sim:fb

macOS does not ship X11 headers and libraries in the default system
search paths, so sim:fb fails to build unless the XQuartz installation
prefix is detected explicitly. Probe /opt/X11 first and fall back to
/usr/X11 so the simulator can find the required X11 headers and libs on
common macOS setups.

This fixes the sim:fb build failure on macOS hosts that rely on XQuartz
for X11 development files.

Signed-off-by: Peter Bee <bijunda@bytedance.com>
This commit is contained in:
bijunda
2026-04-14 16:54:10 +08:00
committed by Xiang Xiao
parent 29114efb41
commit 333815c594
2 changed files with 18 additions and 2 deletions
+7 -1
View File
@@ -190,7 +190,13 @@ endif
ifeq ($(CONFIG_SIM_X11FB),y)
HOSTSRCS += sim_x11framebuffer.c
ifeq ($(CONFIG_HOST_MACOS),y)
STDLIBS += -L/opt/X11/lib
ifneq ($(wildcard /opt/X11/include/X11/Xlib.h),)
HOSTCFLAGS += -I/opt/X11/include
STDLIBS += -L/opt/X11/lib
else ifneq ($(wildcard /usr/X11/include/X11/Xlib.h),)
HOSTCFLAGS += -I/usr/X11/include
STDLIBS += -L/usr/X11/lib
endif
endif
STDLIBS += -lX11 -lXext
ifeq ($(CONFIG_SIM_TOUCHSCREEN),y)
+11 -1
View File
@@ -190,10 +190,20 @@ endif()
if(CONFIG_SIM_X11FB)
list(APPEND HOSTSRCS sim_x11framebuffer.c)
if(APPLE)
find_package(X11 REQUIRED)
find_package(X11)
if(X11_FOUND)
target_include_directories(nuttx PRIVATE ${X11_INCLUDE_DIR})
target_link_libraries(nuttx PRIVATE ${X11_LIBRARIES})
else()
foreach(x11_prefix /opt/X11 /usr/X11)
if(EXISTS ${x11_prefix}/include/X11/Xlib.h)
target_include_directories(nuttx PRIVATE ${x11_prefix}/include)
target_link_directories(nuttx PRIVATE ${x11_prefix}/lib)
target_link_libraries(nuttx PRIVATE X11 Xext)
break()
endif()
endforeach()
endif()
else()
list(APPEND STDLIBS X11 Xext)