From 903a8a01f9a1021337bad5473d3dd1b4af70ca3b Mon Sep 17 00:00:00 2001 From: Jeannot Langlois Date: Sat, 8 Aug 2020 13:16:10 -0400 Subject: [PATCH] Fix Linux-specific libtinfo shared object linker option --- CMakeLists.txt | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50dfde9b7..d877f03cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,10 +113,36 @@ if(BUILD_STATIC) set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") endif(BUILD_STATIC) -find_library(CURSES_LIBRARY NAMES ncursesw cursesw ncurses curses) +find_package(PkgConfig QUIET) # import pkg_check_modules() and friends +if(PKG_CONFIG_FOUND) + pkg_search_module(CURSES_LIBRARY ncursesw cursesw ncurses curses) + if(CURSES_LIBRARY_FOUND) + set(CURSES_LIBRARY ${CURSES_LIBRARY_LIBRARIES}) + endif() + pkg_search_module(TINFO_LIBRARY tinfo) + if(TINFO_LIBRARY_FOUND) + set(TINFO_LIBRARY ${TINFO_LIBRARY_LIBRARIES}) + endif() +endif() +if(NOT CURSES_LIBRARY) + find_library(CURSES_LIBRARY NAMES ncursesw cursesw ncurses curses) +endif() +if(NOT TINFO_LIBRARY) + find_library(TINFO_LIBRARY NAMES tinfo) +endif() if(CURSES_LIBRARY) target_link_libraries(sipp dl ${CURSES_LIBRARY} pthread) target_link_libraries(sipp_unittest dl ${CURSES_LIBRARY} pthread gtest gmock) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(NOT BUILD_STATIC) + if(TINFO_LIBRARY) + target_link_libraries(sipp dl ${TINFO_LIBRARY}) + target_link_libraries(sipp_unittest dl ${TINFO_LIBRARY}) + else() + message(FATAL_ERROR "libtinfo was not found -- please install package") + endif(TINFO_LIBRARY) + endif(NOT BUILD_STATIC) + endif(CMAKE_SYSTEM_NAME STREQUAL "Linux") else() message(FATAL_ERROR "libcurses / libncurses was not found; please install devel package") endif()