From: Dean Michael Berris Date: Wed, 19 Sep 2018 01:35:52 +0000 (+0000) Subject: [XRay] Detect terminfo library X-Git-Tag: llvmorg-8.0.0-rc1~8439 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff93d3a8aacc97cabc5e783e03ade62db2367940;p=platform%2Fupstream%2Fllvm.git [XRay] Detect terminfo library Instead of assuming `-ltinfo` works, check whether there's terminfo support on the host where LLVMSupport is compiled. Follow-up to D52220. llvm-svn: 342523 --- diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 1c60c3d..cffca98 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -105,6 +105,20 @@ check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL) check_library_exists(rt shm_open "" COMPILER_RT_HAS_LIBRT) check_library_exists(m pow "" COMPILER_RT_HAS_LIBM) 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) + string(TOUPPER ${library} library_suffix) + check_library_exists( + ${library} setupterm "" COMPILER_RT_HAS_TERMINFO) + if(COMPILER_RT_HAS_TERMINFO) + set(COMPILER_RT_TERMINFO_LIB "${library}") + break() + endif() + endforeach() +endif() + if (ANDROID AND COMPILER_RT_HAS_LIBDL) # Android's libstdc++ has a dependency on libdl. list(APPEND CMAKE_REQUIRED_LIBRARIES dl) diff --git a/compiler-rt/lib/xray/tests/CMakeLists.txt b/compiler-rt/lib/xray/tests/CMakeLists.txt index 6e12297..3b33f78 100644 --- a/compiler-rt/lib/xray/tests/CMakeLists.txt +++ b/compiler-rt/lib/xray/tests/CMakeLists.txt @@ -54,6 +54,11 @@ if (NOT APPLE) append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS) append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS) append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread XRAY_UNITTEST_LINK_FLAGS) + + # Needed by LLVMSupport. + append_list_if( + COMPILER_RT_HAS_TERMINFO + -l${COMPILER_RT_TERMINFO_LIB} XRAY_UNITTEST_LINK_FLAGS) endif() macro(add_xray_unittest testname) @@ -75,7 +80,7 @@ macro(add_xray_unittest testname) DEPS gtest xray llvm-xray LLVMXRay LLVMTestingSupport CFLAGS ${XRAY_UNITTEST_CFLAGS} LINK_FLAGS ${TARGET_LINK_FLAGS} ${XRAY_UNITTEST_LINK_FLAGS} - -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport -ltinfo + -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport ) set_target_properties(XRayUnitTests PROPERTIES