From 8987ced94fc9897f493b0c3ba5a6f06c5629306e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 31 Jan 2026 16:58:03 +0800 Subject: [PATCH 1/2] cmake: link terminfo to cpptest/tvm_allvisible when required by LLVM/libedit\n\nDetect and link libtinfo explicitly to avoid missing terminfo symbols when llvm-config does not export -ltinfo. This fixes cpptest link failures observed with USE_LLVM=ON on some systems (e.g. LLVM 18 packaged without propagating terminfo).\n\nReproduction: cmake -S . -B build-llvm_ON-hide_OFF -DUSE_LLVM=ON -DHIDE_PRIVATE_SYMBOLS=OFF -DUSE_GTEST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo && cmake --build build-llvm_ON-hide_OFF --target cpptest\n\nVerified: cpptest now links successfully when libtinfo is present on the system and was added as a conditional link target., --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec7bd6c51453..cf355843c7ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -671,6 +671,17 @@ if(GTEST_FOUND) target_link_libraries(cpptest PRIVATE ${LLVM_LIBS}) endif() endif() + # Ensure we link terminfo when required by LLVM / libedit at link time. + if(NOT DEFINED TINFO_LIB) + find_library(TINFO_LIB tinfo) + endif() + if(TINFO_LIB) + message(STATUS "Found terminfo library: ${TINFO_LIB}") + target_link_libraries(cpptest PRIVATE ${TINFO_LIB}) + if(TARGET tvm_allvisible) + target_link_libraries(tvm_allvisible PRIVATE ${TINFO_LIB}) + endif() + endif() set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_ALL 1) set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) target_compile_definitions(cpptest PRIVATE "NDEBUG") From 4c8743f94ebb8ce3c908c9ffad70c8ab75a2ff58 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Feb 2026 11:04:20 +0800 Subject: [PATCH 2/2] 1. move terminfo linkage into the if(DEFINED LLVM_LIBS)\n 2.replace terminfo with Curses --- CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf355843c7ff..c5dfef44fee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -670,18 +670,18 @@ if(GTEST_FOUND) if(DEFINED LLVM_SO OR HIDE_PRIVATE_SYMBOLS) target_link_libraries(cpptest PRIVATE ${LLVM_LIBS}) endif() - endif() - # Ensure we link terminfo when required by LLVM / libedit at link time. - if(NOT DEFINED TINFO_LIB) - find_library(TINFO_LIB tinfo) - endif() - if(TINFO_LIB) - message(STATUS "Found terminfo library: ${TINFO_LIB}") - target_link_libraries(cpptest PRIVATE ${TINFO_LIB}) - if(TARGET tvm_allvisible) - target_link_libraries(tvm_allvisible PRIVATE ${TINFO_LIB}) + + # Ensure we link terminfo when required by LLVM / libedit at link time. + find_package(Curses) + if(CURSES_FOUND) + message(STATUS "Found Curses/terminfo library: ${CURSES_LIBRARIES}") + target_link_libraries(cpptest PRIVATE ${CURSES_LIBRARIES}) + if(TARGET tvm_allvisible) + target_link_libraries(tvm_allvisible PRIVATE ${CURSES_LIBRARIES}) + endif() endif() endif() + set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_ALL 1) set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) target_compile_definitions(cpptest PRIVATE "NDEBUG")