From 9fffb25f1414d7b73c423714feb512de701624ef Mon Sep 17 00:00:00 2001 From: hoijui Date: Thu, 21 Sep 2017 14:24:09 +0200 Subject: [PATCH] add support to build with CMake (a meta build system) use like this: mkdir -p build cd build cmake .. # or #cmake -DCMAKE_INSTALL_PREFIX=/usr .. make --- .gitignore | 1 + .travis.yml | 9 +++++++- CMakeLists.txt | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ cmatrix.c | 2 ++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 3b31dd0..4eb9fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/build config.h Makefile stamp-h diff --git a/.travis.yml b/.travis.yml index 1433c66..6e034e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,14 @@ sudo: required compiler: gcc +env: + - CONFIGURE_CMD=configure + - CONFIGURE_CMD=cmake + script: - - ./configure + - mkdir -p build + - cd build + - if [[ $CONFIGURE_CMD == 'configure' ]]; then export CC=${CC} && ../configure ; fi + - if [[ $CONFIGURE_CMD == 'cmake' ]]; then cmake -DCMAKE_C_COMPILER="${CC}" .. ; fi - make diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1fa2d3e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,58 @@ +# CMake build system for CMatrix + +cmake_minimum_required(VERSION 2.8) + +project(CMatrix LANGUAGES C) +set(VERSION "1.2") + +# These are relative to CMAKE_INSTALL_PREFIX +# which by default is "/usr/local" +set(CONSOLE_FONTS_DIRS "share/consolefonts" "lib/kbd/consolefonts") +set(X_FONTS_DIRS "lib/X11/fonts/misc" "X11R6/lib/X11/fonts/misc" "share/fonts/X11/misc") + +set(MKFONTDIR "/usr/bin/mkfontdir") + +add_definitions(-DEXCLUDE_CONFIG_H) +add_definitions(-DVERSION="${VERSION}") +add_definitions(-DHAVE_SYS_IOCTL_H) +add_definitions(-DHAVE_UNISTD_H) +add_definitions(-DHAVE_TERMIOS_H) +add_definitions(-DHAVE_TERMIO_H) + +Set(CURSES_NEED_NCURSES TRUE) +find_package(Curses) +include_directories(${CURSES_INCLUDE_DIR}) +add_definitions(-DHAVE_NCURSES_H) + +add_executable(cmatrix cmatrix.c) + +target_link_libraries(cmatrix ${CURSES_LIBRARIES}) + +install(TARGETS cmatrix DESTINATION bin) + +if (UNIX) + foreach (CONSOLE_FONTS_DIR ${CONSOLE_FONTS_DIRS}) + if (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${CONSOLE_FONTS_DIR}") + message(STATUS "Installing matrix console fonts to ${CMAKE_INSTALL_PREFIX}/${CONSOLE_FONTS_DIR}") + install(FILES + "${CMAKE_SOURCE_DIR}/matrix.fnt" + "${CMAKE_SOURCE_DIR}/matrix.psf.gz" + DESTINATION "${CONSOLE_FONTS_DIR}") + endif () + endforeach () + foreach (X_FONTS_DIR ${X_FONTS_DIRS}) + if (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${X_FONTS_DIR}") + message(STATUS "Installing matrix X window fonts to ${CMAKE_INSTALL_PREFIX}/${X_FONTS_DIR}") + install(FILES + "${CMAKE_SOURCE_DIR}/mtx.pcf" + DESTINATION "${X_FONTS_DIR}") + install(CODE + "message(STATUS \"Running mkfontdir ${CMAKE_INSTALL_PREFIX}/${X_FONTS_DIR} ...\")") + install(CODE + "execute_process(COMMAND \"${MKFONTDIR}\" \"${CMAKE_INSTALL_PREFIX}/${X_FONTS_DIR}\")") + install(CODE + "message(STATUS \"If this is the first time you have installed CMatrix you will probably have to restart X window in order to use the mtx.pcf font.\")") + endif () + endforeach () +endif () + diff --git a/cmatrix.c b/cmatrix.c index 986c8de..9f14164 100755 --- a/cmatrix.c +++ b/cmatrix.c @@ -32,7 +32,9 @@ #include #include +#ifndef EXCLUDE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_NCURSES_H #include