Skip to content

Commit 7d3eaf1

Browse files
committed
Fix compilation with older CMake/GCC and link in tinfow
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.
1 parent 37bcd5e commit 7d3eaf1

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

CMakeLists.txt

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required (VERSION 3.5)
2-
cmake_policy(SET CMP0091 NEW)
2+
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15.0")
3+
cmake_policy(SET CMP0091 NEW)
4+
endif()
35

46
project(tvision)
57

@@ -15,7 +17,7 @@ else()
1517
endif()
1618

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

2123
add_compile_options(
@@ -67,11 +69,22 @@ add_executable(palette ${PALETTESRC})
6769
set(LIBS tvision)
6870

6971
if (TV_PLATF EQUAL TV_PLATF_UNIX)
70-
find_library(NCURSESW ncursesw REQUIRED)
71-
if (NCURSESW)
72-
list(APPEND LIBS ${NCURSESW})
73-
target_compile_definitions(tvision PRIVATE HAVE_NCURSES)
72+
# ncursesw
73+
find_library(NCURSESW ncursesw)
74+
list(APPEND LIBS ${NCURSESW})
75+
target_compile_definitions(tvision PRIVATE HAVE_NCURSES)
76+
77+
# tinfow (comes with ncurses and is often provided as 'tinfo',
78+
# but we need to link the 'w' version when both are available)
79+
find_library(TINFOW tinfow)
80+
if (TINFOW)
81+
list(APPEND LIBS ${TINFOW})
7482
endif()
83+
84+
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
85+
list(APPEND LIBS "stdc++fs")
86+
endif()
87+
7588
# Optional dependencies
7689
find_library(GPM gpm)
7790
if (GPM)

include/tvision/internal/platform.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef PLATFORM_H
22
#define PLATFORM_H
33

4+
#include <tvision/tv.h>
45
#include <memory>
56
#include <functional>
67
#include <queue>

0 commit comments

Comments
 (0)