Fall back to CMake's pkg-config-based search for curses

CMake seems to have trouble finding libraries from multiarch packages
that do not have the compatibility symlink installed to the
arch-independent library directory. Users must either manually supply
the path to the library in question via command-line parameters or we
can fall back to CMake's alternate method of finding packages based off
of pkg-config rather than using the hard-coded `FindCurses` CMake module
specific to the CMake version/distribution installed.
This commit is contained in:
Mahmoud Al-Qudsi 2019-01-02 18:38:55 -06:00
parent 74422e476b
commit 7af0cad23d

View File

@ -1,5 +1,15 @@
# Detect curses.
FIND_PACKAGE(Curses REQUIRED)
# Try using CMake's own logic to locate curses/ncurses
FIND_PACKAGE(Curses)
IF(NOT ${CURSES_FOUND})
# CMake has trouble finding platform-specific system libraries
# installed to multiarch paths (e.g. /usr/lib/x86_64-linux-gnu)
# if not symlinked or passed in as a manual define.
MESSAGE("Falling back to pkg-config for (n)curses detection")
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(CURSES REQUIRED ncurses curses)
SET(CURSES_CURSES_LIBRARY ${CURSES_LIBRARIES})
SET(CURSES_LIBRARY ${CURSES_LIBRARIES})
ENDIF()
# Get threads.
set(THREADS_PREFER_PTHREAD_FLAG ON)