Fix macOS release build: locate Homebrew's wide-char ncurses

CMake 4.x FindCurses with CURSES_NEED_WIDE finds the macOS SDK's
libcurses.tbd but no matching wide-char header, so configure failed with
"Could NOT find Curses (missing: CURSES_INCLUDE_PATH)". Homebrew's
ncurses is keg-only, so it is not on the default search path either.

Existing build directories only worked by accident, via a hand-passed
-DCURSES_INCLUDE_PATH left in their CMakeCache; a clean configure failed,
which broke make-app-release.

Query `brew --prefix ncurses` on APPLE and prepend it to CMAKE_PREFIX_PATH
when present. A clean configure now succeeds with no manual flags and
links the real libncursesw.dylib instead of the SDK's narrow libcurses.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 10:17:34 -07:00
co-authored by Claude Opus 5
parent 96e82cc6dd
commit 22f7573361
+17
View File
@@ -71,6 +71,23 @@ endif ()
# NCurses for terminal mode # NCurses for terminal mode
set(CURSES_NEED_NCURSES TRUE) set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE) set(CURSES_NEED_WIDE TRUE)
# macOS ships only a narrow-char ncurses in the SDK, and Homebrew's wide-char
# build is keg-only, so FindCurses can't see it without a hint.
if (APPLE)
find_program(BREW_EXECUTABLE brew)
if (BREW_EXECUTABLE)
execute_process(COMMAND "${BREW_EXECUTABLE}" --prefix ncurses
OUTPUT_VARIABLE HOMEBREW_NCURSES_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (HOMEBREW_NCURSES_PREFIX AND IS_DIRECTORY "${HOMEBREW_NCURSES_PREFIX}")
message(STATUS "Using Homebrew ncursesw: ${HOMEBREW_NCURSES_PREFIX}")
list(PREPEND CMAKE_PREFIX_PATH "${HOMEBREW_NCURSES_PREFIX}")
endif ()
endif ()
endif ()
find_package(Curses REQUIRED) find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR}) include_directories(${CURSES_INCLUDE_DIR})