Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI for CMake

on:
push:
pull_request:
release:
types: [published]


jobs:

unix:

strategy:
matrix:
os: [ubuntu-latest]
# mac, clang etc. work, just saving CI time

runs-on: ${{ matrix.os }}
timeout-minutes: 5

steps:

- name: install prereqs (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install --no-install-recommends libxt-dev libxaw7-dev libxpm-dev libxmu-dev libx11-dev

- name: install prereqs (macOS)
if: runner.os == 'macOS'
run: brew install libxt libxaw libx11 libxpm libxmu

- &checkout
uses: actions/checkout@v6

- name: CMake build
run: cmake --workflow build

- name: CMake install (for examples)
run: cmake --install build

- name: CMake example build and test
working-directory: demos
run: cmake --workflow default

- &cpack
name: Create package
if: github.event.action == 'published'
run: cpack --config build/CPackConfig.cmake

- &upload_pkg
name: Upload package
if: github.event.action == 'published'
uses: actions/upload-artifact@v7
with:
name: ${{ runner.os }}-pkg
path: build/package


windows:
runs-on: windows-2025-vs2026
timeout-minutes: 10

steps:
- *checkout

- name: CMake build
run: cmake --workflow msvc-build

- name: CMake install (for examples)
run: cmake --install build --config Release

- name: CMake configure examples
working-directory: demos
run: cmake --preset msvc

- *cpack

- *upload_pkg


dos:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- uses: open-watcom/setup-watcom@v1
with:
version: "2.0"
target: "dos"

- *checkout

- name: CMake build
run: cmake --workflow dos

- name: CMake install (for examples)
run: cmake --install build

# cannot build examples, even locally
121 changes: 121 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
cmake_minimum_required(VERSION 3.19...4.3)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Please use out-of-source build
cmake -B build")
endif()

project(PDCurses
LANGUAGES C
VERSION 3.9
DESCRIPTION "PDCurses - a curses library for environments that don't fit the termcap/terminfo model."
HOMEPAGE_URL "https://github.com/wmcbrine/PDCurses")

include(CheckIncludeFile)
include(CheckSymbolExists)

# --- system config
option(PDCurses_WIDE "Enable wide-character support" ON)
option(PDCurses_UTF8 "Enable UTF-8 support")
option(PDCurses_sdl "Use SDL2")
option(PDCurses_xaw3d "Use Xaw3d instead of Xaw")
option(PDCurses_nextaw "Use NeXT Athena widgets instead of Xaw")

include(cmake/compilers.cmake)

add_library(pdcurses pdcurses/addch.c pdcurses/addchstr.c pdcurses/addstr.c
pdcurses/attr.c pdcurses/beep.c pdcurses/bkgd.c pdcurses/border.c pdcurses/clear.c
pdcurses/color.c pdcurses/delch.c pdcurses/deleteln.c pdcurses/getch.c
pdcurses/getstr.c pdcurses/getyx.c pdcurses/inch.c pdcurses/inchstr.c
pdcurses/initscr.c pdcurses/inopts.c pdcurses/insch.c pdcurses/insstr.c
pdcurses/instr.c pdcurses/kernel.c pdcurses/keyname.c pdcurses/mouse.c pdcurses/move.c
pdcurses/outopts.c pdcurses/overlay.c pdcurses/pad.c pdcurses/panel.c pdcurses/printw.c
pdcurses/refresh.c pdcurses/scanw.c pdcurses/scr_dump.c pdcurses/scroll.c
pdcurses/slk.c pdcurses/termattr.c pdcurses/touch.c pdcurses/util.c
pdcurses/window.c pdcurses/debug.c
)
set_property(TARGET pdcurses PROPERTY EXPORT_NAME Curses)
target_include_directories(pdcurses
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
PRIVATE pdcurses
)
target_compile_definitions(pdcurses
PUBLIC
$<$<BOOL:${PDCurses_WIDE}>:PDC_WIDE>
PRIVATE
$<$<BOOL:${PDCurses_UTF8}>:PDC_FORCE_UTF8>
$<$<BOOL:${PDCurses_xaw3d}>:USE_XAW3D>
$<$<BOOL:${PDCurses_nextaw}>:USE_NEXTAW>
$<$<CONFIG:Debug,RelWithDebugInfo>:PDCDEBUG>
)

add_library(Curses::Curses ALIAS pdcurses)

check_symbol_exists("vsnprintf" "stdio.h" HAVE_VSNPRINTF)
check_symbol_exists("vsscanf" "stdio.h" HAVE_VSSCANF)

target_compile_definitions(pdcurses PRIVATE
$<$<BOOL:${HAVE_VSNPRINTF}>:HAVE_VSNPRINTF>
$<$<BOOL:${HAVE_VSSCANF}>:HAVE_VSSCANF>
)

if(PDCurses_sdl)
find_package(SDL2 CONFIG REQUIRED)

target_link_libraries(pdcurses PRIVATE SDL2::SDL2)
target_include_directories(pdcurses PRIVATE sdl2)

target_sources(pdcurses PRIVATE sdl2/pdcclip.c sdl2/pdcdisp.c sdl2/pdcgetsc.c
sdl2/pdckbd.c sdl2/pdcscrn.c sdl2/pdcsetsc.c sdl2/pdcutil.c sdl2/pdcsdl.h
)
elseif(WIN32)
target_compile_definitions(pdcurses PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${BUILD_SHARED_LIBS}>:PDC_DLL_BUILD>
)
target_include_directories(pdcurses PRIVATE wincon)

target_sources(pdcurses PRIVATE wincon/pdcclip.c wincon/pdcdisp.c wincon/pdcgetsc.c
wincon/pdckbd.c wincon/pdcscrn.c wincon/pdcsetsc.c wincon/pdcutil.c wincon/pdcwin.h
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "DOS")
target_sources(pdcurses PRIVATE dos/pdcclip.c dos/pdcdisp.c dos/pdcgetsc.c
dos/pdckbd.c dos/pdcscrn.c dos/pdcsetsc.c dos/pdcutil.c)
target_include_directories(pdcurses PRIVATE dos)
else()
check_include_file("DECkeySym.h" HAVE_DECKEYSYM_H)
check_include_file("Sunkeysym.h" HAVE_SUNKEYSYM_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_symbol_exists("poll" "poll.h" HAVE_POLL)
check_symbol_exists("usleep" "unistd.h" HAVE_USLEEP)

target_compile_definitions(pdcurses PRIVATE
$<$<BOOL:${HAVE_DECKEYSYM_H}>:HAVE_DECKEYSYM_H>
$<$<BOOL:${HAVE_SUNKEYSYM_H}>:HAVE_SUNKEYSYM_H>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H>
$<$<BOOL:${HAVE_POLL}>:HAVE_POLL>
$<$<BOOL:${HAVE_USLEEP}>:HAVE_USLEEP>
)

include(cmake/x11.cmake)

target_compile_definitions(pdcurses PRIVATE XCURSES)

target_include_directories(pdcurses PRIVATE ${X11_INCLUDE_DIR} x11)
target_link_libraries(pdcurses PRIVATE X11::X11 X11::Xaw X11::Xt X11::Xpm X11::Xmu)

target_sources(pdcurses PRIVATE x11/pdcclip.c x11/pdcdisp.c x11/pdcgetsc.c
x11/pdckbd.c x11/pdcscrn.c x11/pdcsetsc.c x11/pdcutil.c x11/sb.c x11/scrlbox.c
x11/pdcx11.h x11/scrlbox.h
)
endif()

install(TARGETS pdcurses EXPORT ${PROJECT_NAME}-targets)
install(FILES curses.h panel.h TYPE INCLUDE)
Comment thread
scivision marked this conversation as resolved.
Comment thread
scivision marked this conversation as resolved.

include(cmake/install.cmake)

# --- auto-ignore build directory
file(GENERATE OUTPUT .gitignore CONTENT "*")
90 changes: 90 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"version": 6,

"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "build",
"installDir": "${fileDir}/build/local",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"CMAKE_LINK_WARNING_AS_ERROR": true
}
},
{ "name": "build", "inherits": "default" },
{ "name": "msvc", "inherits": "default", "generator": "Visual Studio 18 2026" },
{ "name": "msvc-build", "inherits": "msvc" },
{ "name": "dos", "generator": "Watcom WMake", "inherits": "default",
"toolchainFile": "${sourceDir}/cmake/dos.cmake",
"displayName": "OpenWatcom DOS"
}
],
"buildPresets": [
{ "name": "default", "configurePreset": "default", "configuration": "Release" },
{ "name": "build", "configurePreset": "build", "inherits": "default" },
{ "name": "dos", "configurePreset": "dos", "inherits": "default" },
{ "name": "msvc", "configurePreset": "msvc", "configuration": "Release", "inherits": "default" },
{ "name": "msvc-build", "inherits": "msvc" }
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"configuration": "Release",
"output": {
"outputOnFailure": true,
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false,
"jobs": 8,
"$comment": "don't put 0 or ulimit too many open files failures result"
}
},
{ "name": "msvc", "configurePreset": "msvc", "inherits": "default" },
{ "name": "msvc-build", "inherits": "msvc" }
],
"workflowPresets": [
{
"name": "default",
"steps": [
{ "type": "configure", "name": "default" },
{ "type": "build", "name": "default" },
{ "type": "test", "name": "default" }
]
},
{
"name": "build",
"steps": [
{ "type": "configure", "name": "default" },
{ "type": "build", "name": "default" }
]
},
{
"name": "dos",
"steps": [
{ "type": "configure", "name": "dos" },
{ "type": "build", "name": "dos" }
]
},
{
"name": "msvc-build",
"steps": [
{ "type": "configure", "name": "msvc" },
{ "type": "build", "name": "msvc" }
]
},
{
"name": "msvc",
"steps": [
{ "type": "configure", "name": "msvc" },
{ "type": "build", "name": "msvc" },
{ "type": "test", "name": "msvc" }
]
}
]
}
8 changes: 8 additions & 0 deletions cmake/compilers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom")
message(STATUS "OpenWatcom: $ENV{WATCOM}
Host: ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION}
Target: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}
")
# https://wiki.archlinux.org/title/Open_Watcom
add_compile_options(-bt=dos -bcl=dos)
endif()
10 changes: 10 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)

set(PDCurses_X11 @X11_FOUND@)
if(PDCurses_X11)
find_dependency(X11)
endif()

check_required_components(@PROJECT_NAME@)
27 changes: 27 additions & 0 deletions cmake/dos.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(CMAKE_SYSTEM_NAME DOS)

if(NOT DEFINED ENV{WATCOM})
if(WIN32)
set(scr ${CMAKE_CURRENT_LIST_DIR}/dos.ps1)
else()
set(scr ${CMAKE_CURRENT_LIST_DIR}/dos.sh)
endif()
message(FATAL_ERROR "WATCOM environment variable not set. Try running ${scr} first.")
endif()

file(TO_CMAKE_PATH "$ENV{WATCOM}" watcom_root)

set(CMAKE_SYSROOT ${watcom_root})

if(WIN32)
set(bin ${watcom_root}/binnt64 ${watcom_root}/binnt)
else()
set(bin ${watcom_root}/binl64 ${watcom_root}/binl)
endif()

find_program(CMAKE_C_COMPILER
NAMES wcl386
HINTS ${bin}
NO_DEFAULT_PATH
REQUIRED
)
15 changes: 15 additions & 0 deletions cmake/dos.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$watcom = "$Env:SYSTEMDRIVE:\WATCOM"

if (!(Test-Path -Path $watcom)) {
Throw "OpenWatcom not found at $watcom"
}

$env:WATCOM = $watcom
$env:EDPATH = "$watcom\EDDAT"
$env:WHTMLHELP = "$watcom\BINNT\HELP"
$env:WIPFC = "$watcom\WIPFC"

$env:LIBPATH = "$watcom\lib386\"
$env:INCLUDE = "$watcom\H"

$env:Path += ";$watcom\BINNT64;$watcom\BINNT"
15 changes: 15 additions & 0 deletions cmake/dos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

watcom="/opt/watcom/"

if [ ! -d $watcom ]; then
echo "OpenWatcom not found at $watcom" >&2
exit 1
fi

export WATCOM=$watcom
export EDPATH="$watcom/eddat"
export WIPFC="$watcom/wipfc"

export INCLUDE="$watcom/h"
export PATH="$watcom/binl64:$watcom/binl:$PATH"
Loading