Fix macOS build: use CURSES_INCLUDE_DIRS and enable wide-char decls

Two latent defects broke the kte target on macOS once TerminalInputHandler
switched from getch() to get_wch().

include_directories() referenced CURSES_INCLUDE_DIR, a name FindCurses never
sets (it exports CURSES_INCLUDE_DIRS). The variable expanded to nothing, so
no curses include path was added and the compiler silently fell back to the
macOS SDK's narrow-char header on the default include path.

Both the SDK and Homebrew headers declare get_wch and friends only when
NCURSES_WIDECHAR is set, defaulting it to 0 absent a feature-test macro, so
the build failed with "use of undeclared identifier 'get_wch'". We always
request and link the wide library, so define NCURSES_WIDECHAR=1; redefining
it identically is benign on platforms whose headers already set it.

kte and kge now compile and link against libncursesw, and the app bundle
vendors it. Full test suite passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 10:22:34 -07:00
co-authored by Claude Opus 5
parent 22f7573361
commit 18ce005ec0
+10 -1
View File
@@ -89,7 +89,16 @@ if (APPLE)
endif ()
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
# FindCurses exports CURSES_INCLUDE_DIRS; the singular CURSES_INCLUDE_DIR was
# never set, so this silently expanded to nothing and the compiler fell back
# to whatever curses header happened to be on the default include path.
include_directories(${CURSES_INCLUDE_DIRS})
# The wide-char entry points we rely on (get_wch, etc.) are declared only when
# NCURSES_WIDECHAR is set; the header defaults it to 0 unless a feature-test
# macro says otherwise. We always link the wide library, so ask for them.
add_compile_definitions(NCURSES_WIDECHAR=1)
# On Alpine Linux, CMake's FindCurses looks in wrong paths
# Manually find the correct ncurses library