This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 333815c5947fca6c68e44ea85caf2c10303cbbe6
Author: bijunda <[email protected]>
AuthorDate: Tue Apr 14 16:54:10 2026 +0800

    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 <[email protected]>
---
 arch/sim/src/Makefile           |  8 +++++++-
 arch/sim/src/sim/CMakeLists.txt | 12 +++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 9cef07a2ae2..0bbc10eb1dd 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -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)
diff --git a/arch/sim/src/sim/CMakeLists.txt b/arch/sim/src/sim/CMakeLists.txt
index b9f4c637e22..a47cc98d5aa 100644
--- a/arch/sim/src/sim/CMakeLists.txt
+++ b/arch/sim/src/sim/CMakeLists.txt
@@ -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)

Reply via email to