forked from WHC/Hermit
Windows: make the CMake build work with MSYS2's native toolchain
This commit is contained in:
+17
-6
@@ -18,12 +18,17 @@ endif()
|
||||
# Separate archive for MinGW so Linux host builds keep libsashidown.a
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(SASHIDOWN_A "${SD_DIR}/libsashidown-mingw.a")
|
||||
set(_MINGW_AR x86_64-w64-mingw32-ar)
|
||||
# Use whatever archiver CMake found for the active toolchain. Hardcoding
|
||||
# "x86_64-w64-mingw32-ar" only works on cross-build hosts, where binutils
|
||||
# installs prefixed names; MSYS2's mingw-w64 toolchain ships plain ar.exe
|
||||
# and ranlib.exe, so the hardcoded names are not found.
|
||||
set(_MINGW_AR "${CMAKE_AR}")
|
||||
set(_MINGW_RANLIB "${CMAKE_RANLIB}")
|
||||
add_custom_command(
|
||||
OUTPUT "${SASHIDOWN_A}"
|
||||
COMMAND ${CMAKE_MAKE_PROGRAM} -C "${SD_DIR}" clean
|
||||
COMMAND ${CMAKE_MAKE_PROGRAM} -C "${SD_DIR}" libsashidown.a
|
||||
CC=${CMAKE_C_COMPILER} AR=${_MINGW_AR} RANLIB=x86_64-w64-mingw32-ranlib
|
||||
CC=${CMAKE_C_COMPILER} AR=${_MINGW_AR} RANLIB=${_MINGW_RANLIB}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${SD_DIR}/libsashidown.a" "${SASHIDOWN_A}"
|
||||
COMMAND ${CMAKE_MAKE_PROGRAM} -C "${SD_DIR}" clean
|
||||
@@ -111,9 +116,11 @@ endif()
|
||||
if(CST_BUILD_TUI)
|
||||
if(WIN32)
|
||||
# Prefer PDCurses (pdcurses / curses). Users may set PDCurses_ROOT.
|
||||
# PATH_SUFFIXES also covers the layout MSYS2's mingw-w64-pdcurses uses,
|
||||
# which puts the headers under include/pdcurses/ rather than include/.
|
||||
find_path(PDCURSES_INCLUDE_DIR curses.h
|
||||
HINTS ENV PDCurses_ROOT "${PDCurses_ROOT}"
|
||||
PATH_SUFFIXES include)
|
||||
PATH_SUFFIXES include pdcurses include/pdcurses)
|
||||
find_library(PDCURSES_LIBRARY
|
||||
NAMES pdcurses pdcurses.dll curses
|
||||
HINTS ENV PDCurses_ROOT "${PDCurses_ROOT}"
|
||||
@@ -121,7 +128,11 @@ if(CST_BUILD_TUI)
|
||||
if(PDCURSES_INCLUDE_DIR AND PDCURSES_LIBRARY)
|
||||
target_include_directories(cst-agent PRIVATE ${PDCURSES_INCLUDE_DIR})
|
||||
target_link_libraries(cst-agent PRIVATE ${PDCURSES_LIBRARY})
|
||||
target_compile_definitions(cst-agent PRIVATE CST_USE_PDCURSES=1)
|
||||
# PDCurses suffixes its exported symbols with an ABI tag (endwin_u64_4400
|
||||
# etc.). MSYS2 builds the UTF-8 wide variant, so PDC_FORCE_UTF8 has to be
|
||||
# defined or curses.h maps to the w64 names and the link fails.
|
||||
target_compile_definitions(cst-agent PRIVATE
|
||||
CST_USE_PDCURSES=1 PDC_FORCE_UTF8=1)
|
||||
message(STATUS "TUI: PDCurses (${PDCURSES_LIBRARY})")
|
||||
else()
|
||||
message(FATAL_ERROR "CST_BUILD_TUI=ON on Windows requires PDCurses (set PDCurses_ROOT)")
|
||||
@@ -143,9 +154,9 @@ else()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR WIN32)
|
||||
# curl Schannel + networking
|
||||
# curl Schannel + networking; winmm is needed by PDCurses (PlaySoundW)
|
||||
target_link_libraries(cst-agent PRIVATE
|
||||
ws2_32 crypt32 secur32 bcrypt advapi32)
|
||||
ws2_32 crypt32 secur32 bcrypt advapi32 winmm)
|
||||
endif()
|
||||
|
||||
# --- tests ---
|
||||
|
||||
Reference in New Issue
Block a user