From 4a5f0f3a3dc51634cef0c282280e6be2a92804be Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 8 Jul 2020 10:56:20 -0500 Subject: [PATCH] Fix missing references when manually linking against curses When CMake's own curses logic fails to find curses/ncurses, we fall back to pkg-config and manually link the required libraries. Some platforms (RHEL 6, see #6587) require CURSES_EXTRA_LIBRARY=tinfo, so we link against libtinfo if it's found but are happy to continue without it if it doesn't exist. Closes #6587 --- cmake/ConfigureChecks.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 57b43fa7c..9a2205de9 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -33,6 +33,14 @@ if(NOT ${CURSES_FOUND}) set(CURSES_LIBRARY ${CURSES_LIBRARIES}) endif() +# Fix undefined reference to tparm on RHEL 6 and potentially others +# If curses is found via CMake, it also links against tinfo if it exists. But if we use our +# fallback pkg-config logic above, we need to do this manually. +find_library(CURSES_TINFO tinfo) +if (CURSES_TINFO) + set(CURSES_LIBRARY ${CURSES_LIBRARY} ${CURSES_TINFO}) +endif() + # Get threads. set(THREADS_PREFER_PTHREAD_FLAG ON) # FindThreads < 3.4.0 doesn't work for C++-only projects