Skip to content

Commit

Permalink
add osx build on Travis CI (#39)
Browse files Browse the repository at this point in the history
* add osx builds on Travis CI

* check headers in CMake and only include either of termios.h or termio.h

CMake builds failed on basically 93fd357 [1] on OS X since termio.h
isn't present.

[1]: https://travis-ci.org/livibetter/cmatrix/builds/337114240

cmatrix.c do not need to include both termios.h and termio.h, the latter
is a wrapper on Linux, on POSIX, the former would do.

CMake should check the header files, not defining blindly, although it's
not needed as now cmatrix.c only includes one of the headers, however,
it's a good practice, but it should also halt the build process if
neither is found.
  • Loading branch information
livibetter authored and abishekvashok committed Feb 4, 2018
1 parent 93fd357 commit d4d9881
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: c

os: linux
os:
- linux
- osx

sudo: required

Expand Down
22 changes: 18 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,24 @@ 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)

include(CheckIncludeFiles)
check_include_files("sys/ioctl.h" HAVE_SYS_IOCTL_H)
if (HAVE_SYS_IOCTL_H)
add_definitions(-DHAVE_SYS_IOCTL_H)
endif ()
check_include_files("unistd.h" HAVE_UNISTD_H)
if (HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif ()
check_include_files("termios.h" HAVE_TERMIOS_H)
if (HAVE_TERMIOS_H)
add_definitions(-DHAVE_TERMIOS_H)
endif ()
check_include_files("termio.h" HAVE_TERMIO_H)
if (HAVE_TERMIO_H)
add_definitions(-DHAVE_TERMIO_H)
endif ()

Set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)
Expand Down
4 changes: 1 addition & 3 deletions cmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@

#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif

#ifdef HAVE_TERMIO_H
#elif defined(HAVE_TERMIO_H)
#include <termio.h>
#endif

Expand Down

0 comments on commit d4d9881

Please sign in to comment.