Skip to content

Commit

Permalink
Fix compilation with older CMake/GCC and link in tinfow
Browse files Browse the repository at this point in the history
The 'if (NCURSESW)' has been removed because ncurses is already compulsory. The REQUIRED option of find_library is not available in older CMake versions, so the only way to trigger an error is to dereference NCURSESW unconditionally.

tinfow has to be linked in systems where both tinfo and tinfow are available. See #11.
  • Loading branch information
magiblot committed Sep 5, 2020
1 parent 37bcd5e commit 7d3eaf1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
25 changes: 19 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required (VERSION 3.5)
cmake_policy(SET CMP0091 NEW)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15.0")
cmake_policy(SET CMP0091 NEW)
endif()

project(tvision)

Expand All @@ -15,7 +17,7 @@ else()
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Static RTL linkage for MSVC.
# Static RTL linkage for MSVC (requires CMake >= 3.15).
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

add_compile_options(
Expand Down Expand Up @@ -67,11 +69,22 @@ add_executable(palette ${PALETTESRC})
set(LIBS tvision)

if (TV_PLATF EQUAL TV_PLATF_UNIX)
find_library(NCURSESW ncursesw REQUIRED)
if (NCURSESW)
list(APPEND LIBS ${NCURSESW})
target_compile_definitions(tvision PRIVATE HAVE_NCURSES)
# ncursesw
find_library(NCURSESW ncursesw)
list(APPEND LIBS ${NCURSESW})
target_compile_definitions(tvision PRIVATE HAVE_NCURSES)

# tinfow (comes with ncurses and is often provided as 'tinfo',
# but we need to link the 'w' version when both are available)
find_library(TINFOW tinfow)
if (TINFOW)
list(APPEND LIBS ${TINFOW})
endif()

if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
list(APPEND LIBS "stdc++fs")
endif()

# Optional dependencies
find_library(GPM gpm)
if (GPM)
Expand Down
1 change: 1 addition & 0 deletions include/tvision/internal/platform.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef PLATFORM_H
#define PLATFORM_H

#include <tvision/tv.h>
#include <memory>
#include <functional>
#include <queue>
Expand Down

0 comments on commit 7d3eaf1

Please sign in to comment.