Files
gui/ssh/CMakeLists.txt
T
Claude 579fc9a706 Add SSH to the Windows 95 build
The win32-picolibc build (Windows 95, 98, ME, NT 4.0 and later) now has
libssh and mbedTLS, as the other builds do. DMODEM_GUI_SSH is ON for
every build.

- mbedTLS: CryptGenRandom of CryptoAPI, found at run time, in place of
  BCryptGenRandom (Vista) before Vista; picolibc's gmtime_r and the
  Windows zeroize in place of gmtime_s and memset_s.
- libssh: SHGetSpecialFolderPathA (IE4 shell), if_nametoindex (Vista) and
  WSAStringToAddressA (Winsock 2) found at run time before Vista, with
  USERPROFILE and inet_addr in their place; picolibc build flags and a
  <direct.h>.
- gai_strerrorA with FormatMessageA (mingw-w64's calls FormatMessageW).
- agent.c: strcasecmp for _stricmp on picolibc.

The app still imports only DLLs that every Windows 95 has; the 9x and
NT 4.0 import checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRhKGCaYUyYtH7Boap
2026-11-20 10:44:54 +00:00

52 lines
1.9 KiB
CMake

# libdmodemssh: D-Modem's SSH client (dmodemssh.h), on libssh 0.11.
# The system's libssh when it is 0.11 or later (and
# -DDMODEM_SSH_BUNDLED=OFF), else libssh and mbedTLS built here from
# their release tarballs: always for the Windows and macOS apps, which
# ship no libraries of the system's.
if(WIN32 OR APPLE)
set(_bundled ON)
else()
set(_bundled AUTO)
endif()
set(DMODEM_SSH_BUNDLED ${_bundled} CACHE STRING "Build libssh and mbedTLS from source (ON, OFF, AUTO: when the system's is older than 0.11)")
if(NOT DMODEM_SSH_BUNDLED STREQUAL "ON")
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(LIBSSH IMPORTED_TARGET libssh>=0.11)
endif()
endif()
if(LIBSSH_FOUND)
add_library(dmodem_libssh INTERFACE)
target_link_libraries(dmodem_libssh INTERFACE PkgConfig::LIBSSH)
elseif(DMODEM_SSH_BUNDLED STREQUAL "OFF")
message(FATAL_ERROR "libssh 0.11 or later not found (or -DDMODEM_SSH_BUNDLED=AUTO)")
else()
include(${CMAKE_CURRENT_LIST_DIR}/cmake/BundledLibssh.cmake)
endif()
add_library(dmodemssh STATIC src/dmodemssh.c src/ppk.c src/agent.c)
# (the Windows 95 build: a gai_strerrorA with no Unicode call)
if(CLANG_RETRO_CONFIG MATCHES "picolibc")
target_sources(dmodemssh PRIVATE src/gai_strerror.c)
endif()
target_include_directories(dmodemssh PUBLIC include)
target_link_libraries(dmodemssh PUBLIC dmodem_libssh)
if(WIN32)
target_link_libraries(dmodemssh PUBLIC ws2_32 user32 advapi32)
elseif(UNIX)
find_package(Threads REQUIRED)
target_link_libraries(dmodemssh PUBLIC Threads::Threads)
endif()
if(MSVC)
target_compile_options(dmodemssh PRIVATE /W4 /wd4996)
else()
target_compile_options(dmodemssh PRIVATE -Wall -Wextra -Wshadow)
endif()
add_executable(dmodemssh_test test/dmodemssh_test.c)
target_link_libraries(dmodemssh_test PRIVATE dmodemssh)
# (Argon2 is tested too: ppk.h)
target_include_directories(dmodemssh_test PRIVATE src)
add_test(NAME dmodemssh COMMAND dmodemssh_test)