[cmake] Fix detecting terminfo library

Copy the fix for determining the correct terminfo library from LLVM --
use distinct variables for check_library_exists() calls.  Otherwise,
the first check (for -ltinfo) populates the variable and no other checks
are performed.  Effectively, systems with other libraries than the first
one listed are presumed not to have terminfo routines at all.

Also sync the check order to include the NetBSD fix from r347156.

This partially fixes undefined symbols when linking XRay tests.  It's
probably not the best solution to the problem there but as long
as the terminfo check stays in config-ix, I thnk it's worth fixing.

Differential Revision: https://reviews.llvm.org/D54641

llvm-svn: 347338
This commit is contained in:
Michal Gorny 2018-11-20 18:41:11 +00:00
parent 1b25ba073f
commit 4b0b84f4bb

View File

@ -121,10 +121,12 @@ check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)
# Look for terminfo library, used in unittests that depend on LLVMSupport.
if(LLVM_ENABLE_TERMINFO)
foreach(library tinfo terminfo curses ncurses ncursesw)
foreach(library terminfo tinfo curses ncurses ncursesw)
string(TOUPPER ${library} library_suffix)
check_library_exists(
${library} setupterm "" COMPILER_RT_HAS_TERMINFO)
if(COMPILER_RT_HAS_TERMINFO)
${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix})
if(COMPILER_RT_HAS_TERMINFO_${library_suffix})
set(COMPILER_RT_HAS_TERMINFO TRUE)
set(COMPILER_RT_TERMINFO_LIB "${library}")
break()
endif()