-
Notifications
You must be signed in to change notification settings - Fork 202
add CMake build option #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
scivision
wants to merge
14
commits into
wmcbrine:master
Choose a base branch
from
scivision:cmake
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ab7fc3b
add cmake
scivision 35e5a7e
add CI
scivision 6dca9cf
Update CMakeLists.txt - fixed PDC_WIDE scope
inobelar 311f3c9
ci: add gcc-13
scivision d8590ba
don't require pkgconfig. Define scope
scivision f2fa62f
x11: remove unneeded extra includes
scivision 2ac339e
add DOS Watcom support
scivision 1e14c06
scope compile options
scivision c840055
add self test
scivision 3bab79a
ci/cmake: modernize
scivision 55b11d4
CI use presets
scivision 740aeab
demos/tui: mitigate buffer overflow
scivision 415fda1
correct PDCurses_sdl logic
scivision 149a68a
lint
scivision File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
scivision marked this conversation as resolved.
|
||
|
|
||
| include(cmake/install.cmake) | ||
|
|
||
| # --- auto-ignore build directory | ||
| file(GENERATE OUTPUT .gitignore CONTENT "*") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.