From 18ce005ec05dd37eb2498fe8abd1309b43d71cc0 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 3 Aug 2026 10:22:34 -0700 Subject: [PATCH] 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) --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 876ee56..c1c6131 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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