Compare commits
No commits in common. "ae6130f095c50d3681e117f2153851a6e530b201" and "bc76ae227c0985b32e6c0571387916e044ac693e" have entirely different histories.
ae6130f095
...
bc76ae227c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,2 @@
|
|||
build/
|
||||
sandbox/
|
||||
VERSION
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -54,6 +54,5 @@
|
|||
"stdexcept": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"pointers": "cpp"
|
||||
},
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
||||
}
|
||||
}
|
2
App.cpp
2
App.cpp
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
|
||||
#include "App.hpp"
|
||||
#include "Window.hpp"
|
||||
#include "Debug.hpp"
|
||||
#include <NCursesPtyWindow/Window.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <utmp.h>
|
||||
|
|
|
@ -1,62 +1,52 @@
|
|||
##
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
|
||||
cmake_minimum_required(VERSION 3.16.3)
|
||||
|
||||
include("cmake/version.cmake")
|
||||
project(NCursesPtyWindow
|
||||
HOMEPAGE_URL "https://gitea.xndr.de/christian/NCursesPtyWindow"
|
||||
VERSION ${SEMANTIC_VERSION})
|
||||
VERSION 0.1.0
|
||||
HOMEPAGE_URL "https://gitea.xndr.de/christian/shellipt")
|
||||
### 3.16.3 does not pick up the project's homepage URL by itself
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
include(ExternalProject)
|
||||
include("cmake/ncurses.cmake")
|
||||
include("cmake/gsl.cmake")
|
||||
|
||||
add_library(NCursesPtyWindow Window.cpp SingleUserInput.cpp Debug.cpp)
|
||||
|
||||
### path to own system includes
|
||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
### libraries
|
||||
|
||||
include("cmake/ncurses.cmake")
|
||||
target_link_libraries(NCursesPtyWindow ${CURSES_LIBRARIES})
|
||||
|
||||
include("cmake/gsl.cmake")
|
||||
|
||||
include("cmake/libvterm.cmake")
|
||||
if(EXISTS libvtermProject)
|
||||
add_dependencies(NCursesPtyWindow libvtermProject)
|
||||
endif()
|
||||
target_link_libraries(NCursesPtyWindow ${LIBVTERM_LIBRARY})
|
||||
|
||||
find_library(UTIL_LIBRARY util)
|
||||
target_link_libraries(NCursesPtyWindow ${UTIL_LIBRARY})
|
||||
|
||||
target_link_libraries(NCursesPtyWindow ${CURSES_LIBRARIES} ${LIBVTERM_LIBRARY} ${UTIL_LIBRARY})
|
||||
|
||||
### threads
|
||||
set(THREADS_PREFER_PTHREAD_FLAG true)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(NCursesPtyWindow Threads::Threads)
|
||||
|
||||
### demo application
|
||||
add_executable(NCursesPtyApp main.cpp App.cpp)
|
||||
target_link_libraries(NCursesPtyApp NCursesPtyWindow)
|
||||
target_link_libraries(NCursesPtyApp ${CURSES_LIBRARIES} NCursesPtyWindow)
|
||||
|
||||
### installation and packaging
|
||||
set(NCURSES_PTY_WINDOW_SYSTEM_INCLUDE "include/NCursesPtyWindow")
|
||||
set_target_properties(NCursesPtyWindow PROPERTIES PUBLIC_HEADER "${NCURSES_PTY_WINDOW_SYSTEM_INCLUDE}/Window.hpp;${NCURSES_PTY_WINDOW_SYSTEM_INCLUDE}/SingleUserInput.hpp"
|
||||
VERSION "${CMAKE_PROJECT_VERSION}")
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS NCursesPtyWindow ARCHIVE
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/NCursesPtyWindow/")
|
||||
set_target_properties(NCursesPtyWindow PROPERTIES PUBLIC_HEADER "Window.hpp;SingleUserInput.hpp")
|
||||
install(TARGETS NCursesPtyWindow ARCHIVE PUBLIC_HEADER)
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_PACKAGE_CONTACT "Christian Burger <christian@krikkel.de>")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library for a pseudo terminal where the host end is a ncurses window")
|
||||
# 3.16.3 does not pick up the project's homepage URL by itself
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL})
|
||||
|
||||
set(CPACK_GENERATOR "DEB" "TGZ")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libncursesw6 (>=6.2), libvterm0 (>= 0.1.2)")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libncursesw6 (>=6.2), libvterm-dev (>= 0.1.2)")
|
||||
include(CPack)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @author Christian Burger (christian@krikkel.de)
|
||||
*/
|
||||
|
||||
#include <NCursesPtyWindow/SingleUserInput.hpp>
|
||||
#include "SingleUserInput.hpp"
|
||||
#include "Debug.hpp"
|
||||
|
||||
#include <vterm.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @author Christian Burger (christian@krikkel.de)
|
||||
*/
|
||||
|
||||
#include <NCursesPtyWindow/Window.hpp>
|
||||
#include "Window.hpp"
|
||||
#include "Debug.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
##
|
||||
# @brief Includes Microsoft's "C++ Guidelines Standard Library"
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
|
||||
find_path(GSL_INCLUDE_DIR "gsl/gsl" REQUIRED)
|
||||
if(NOT GSL_INCLUDE_DIR)
|
||||
find_path(GSL_INCLUDE_DIR "gsl")
|
||||
if(GSL_INCLUDE_DIR STREQUAL "GSL_INCLUDE_DIR-NOTFOUND")
|
||||
message(SEND_ERROR "Microsoft GSL not found.")
|
||||
else()
|
||||
message(STATUS "Found Microsoft C++ GSL.")
|
||||
message(STATUS "Microsoft GSL found.")
|
||||
include_directories(SYSTEM ${GSL_INCLUDE_DIR})
|
||||
endif()
|
|
@ -1,31 +1,17 @@
|
|||
##
|
||||
# @brief Includes `libvterm` (builds it if not found on the system).
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
# @brief searches for libvterm and builds it if not found
|
||||
#
|
||||
# Provides ${LIBVTERM_LIBRARY} and implicitly adds path for correct
|
||||
# `#include<>`.
|
||||
#
|
||||
# @warning dependency must be added like this:
|
||||
# if(TARGET libvtermProject)
|
||||
# provides LIBVTERM_LIBRARY and include path
|
||||
# dependency must be added like this:
|
||||
# if(EXISTS libvtermProject)
|
||||
# add_dependencies(<targetDependingOn> libvtermProject)
|
||||
# endif()
|
||||
#
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
|
||||
|
||||
find_library(LIBVTERM_LIBRARY NAMES "libvterm.so.0.0.2" "vterm")
|
||||
find_path(LIBVTERM_INCLUDE "vterm.h")
|
||||
find_library(LIBVTERM_LIBRARY NAMES libvterm.so.0.0.2 vterm)
|
||||
|
||||
if(NOT LIBVTERM_LIBRARY)
|
||||
message(STATUS "Did not find `libvterm.so`.")
|
||||
set(LIBVTERM_BUILD_IT TRUE)
|
||||
endif()
|
||||
if(NOT LIBVTERM_INCLUDE)
|
||||
message(STATUS "Did not find `vterm.h`.")
|
||||
set(LIBVTERM_BUILD_IT TRUE)
|
||||
endif()
|
||||
if(LIBVTERM_BUILD_IT)
|
||||
include(ExternalProject)
|
||||
message(STATUS "Did not find libvterm (see previous error) — building it.")
|
||||
if(LIBVTERM_LIBRARY STREQUAL "LIBVTERM_LIBRARY-NOTFOUND")
|
||||
message(STATUS "libvterm not found — building it")
|
||||
ExternalProject_Add(
|
||||
libvtermProject
|
||||
DOWNLOAD_COMMAND URL "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libvterm/0.1.2-2/libvterm_0.1.2.orig.tar.gz"
|
||||
|
@ -36,6 +22,4 @@ if(LIBVTERM_BUILD_IT)
|
|||
ExternalProject_Get_property(libvtermProject SOURCE_DIR)
|
||||
set(LIBVTERM_LIBRARY "${SOURCE_DIR}/.libs/libvterm.a")
|
||||
include_directories(SYSTEM "${SOURCE_DIR}/include")
|
||||
else()
|
||||
message(STATUS "Found vterm library.")
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
##
|
||||
# @brief Includes the UTF-8 C++ version of the `ncurses` library.
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
|
||||
set(CURSES_NEED_NCURSES TRUE)
|
||||
|
@ -8,8 +6,8 @@ find_package(Curses 6.2 REQUIRED)
|
|||
include_directories(SYSTEM ${CURSES_INCLUDE_DIRS})
|
||||
|
||||
# find C++ interface for ncurses with unicode support
|
||||
find_library(CURSES_CPP_WIDE_LIBRARY NAMES ncurses++w)
|
||||
find_library(CURSES_CPP_WIDE_LIBRARY NAMES ncurses++w REQUIRED)
|
||||
if(NOT CURSES_CPP_WIDE_LIBRARY)
|
||||
message(SEND_ERROR "C++ interface for ncurses (wide/unicode) not found.")
|
||||
message(FATAL_ERROR "C++ interface for ncurses (wide/unicode) not found.")
|
||||
endif()
|
||||
list(APPEND CURSES_LIBRARIES ${CURSES_CPP_WIDE_LIBRARY})
|
|
@ -1,77 +0,0 @@
|
|||
##
|
||||
# @brief a ${SEMANTIC_VERSION} based on Git tags (or a `VERSION` file) à la
|
||||
# `v<major>.<minor>.<patch>` is provided
|
||||
#
|
||||
# Versions have the format "v<major>.<minor>.<patch>" in accordance with
|
||||
# Semantic Versioning. If a version is provided by a file named `VERSION`, the
|
||||
# full version must be given. If a version is provided by Git tags, only part of
|
||||
# the version must be given, the format is then: "v<major>.<minor>". The <patch>
|
||||
# version is automatically deduced from the distance in commits to the latest
|
||||
# Git tag. The version set in the file overrides the tags in the Git repository.
|
||||
#
|
||||
# based upon Semantic Versioning: https://semver.org/
|
||||
#
|
||||
# @attention The <patch> version-part is a bit flaky; it gives the distance in
|
||||
# commits to the <major>.<minor> version. Due to the non-linear
|
||||
# nature of the commit history (because of branches), it is ambigous
|
||||
# (i. e. multiple commits can be found at the same distance). On top
|
||||
# of that, it is your job to make sure, that patches only fix bugs
|
||||
# and do not change the API (no new functionalty; or old removed).
|
||||
#
|
||||
# One option to address both issues is: Stay in one branch for
|
||||
# releases — for example named 'release' — and cherry-pick new
|
||||
# versions into the branch (alphas, betas, candidates and releases).
|
||||
# Optional: squash cherry-picked commits, so that the <patch> part of
|
||||
# the version is only incremented by one.
|
||||
# @warning To update the version you have to run CMake again.
|
||||
#
|
||||
# @todo escape/quote paths
|
||||
# @todo test cases for CMake file components?
|
||||
# @todo make variables local (see: unset()) and put them in a "namespace"
|
||||
# @author Christian Burger <christian@krikkel.de>
|
||||
find_package(Git)
|
||||
|
||||
function(get_semantic_version)
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/VERSION")
|
||||
message(STATUS "using file `VERSION` to determine version")
|
||||
file(READ "VERSION" REPOSITORY_VERSION)
|
||||
elseif(GIT_FOUND)
|
||||
message(STATUS "using Git to determine project version")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_SOURCE_DIR} describe --always --match v[0-9]*.[0-9]*
|
||||
OUTPUT_VARIABLE REPOSITORY_VERSION)
|
||||
else()
|
||||
message(WARNING "We need Git or a file \"VERSION\" to determine a version (e. g. \"v1.0\").")
|
||||
endif()
|
||||
|
||||
# test cases
|
||||
#set(REPOSITORY_VERSION "v0.1") # = 0.1.0
|
||||
#set(REPOSITORY_VERSION "v0.1-1-g12345678") # = 0.1.1
|
||||
#set(REPOSITORY_VERSION "v0.1") # = 0.0.0
|
||||
#set(REPOSITORY_VERSION "1234abcd") # = 0.0.0
|
||||
#set(REPOSITORY_VERSION "") # = 0.1.0
|
||||
|
||||
string(REGEX MATCH "^v([0-9]+)\.([0-9]+)([-\\.]([0-9]+))?" SEMANTIC_VERSION_PREPROCESSED "${REPOSITORY_VERSION}")
|
||||
|
||||
if("${SEMANTIC_VERSION_PREPROCESSED}" STREQUAL "")
|
||||
message(STATUS "Found no version tag (e. g. \"v1.0\").")
|
||||
endif()
|
||||
|
||||
set(SEMANTIC_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(SEMANTIC_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(SEMANTIC_VERSION_PATCH ${CMAKE_MATCH_4})
|
||||
|
||||
if("${SEMANTIC_VERSION_MAJOR}" STREQUAL "")
|
||||
set(SEMANTIC_VERSION "0.0.0")
|
||||
else()
|
||||
if("${SEMANTIC_VERSION_PATCH}" STREQUAL "")
|
||||
set(SEMANTIC_VERSION_PATCH "0")
|
||||
endif()
|
||||
set(SEMANTIC_VERSION "${SEMANTIC_VERSION_MAJOR}.${SEMANTIC_VERSION_MINOR}.${SEMANTIC_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Project version is: ${SEMANTIC_VERSION}")
|
||||
|
||||
set(SEMANTIC_VERSION "${SEMANTIC_VERSION}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_semantic_version()
|
Loading…
Reference in a new issue