MacOS 上使用 clang-15 时 FindTerminfo 中的 CMake 错误

gav*_*n.d 3 macos cmake llvm clang terminfo

我在我的项目中使用 llvm 并使用 cmake 找到它find_package(LLVM REQUIRED CONFIG)

配置失败并显示消息:

[cmake] CMake Error at /Applications/CMake.app/Contents/share/cmake-3.23/Modules/Internal/CheckSourceCompiles.cmake:44 (message):
[cmake]   check_source_compiles: C: needs to be enabled before use.
[cmake] Call Stack (most recent call first):
[cmake]   /Applications/CMake.app/Contents/share/cmake-3.23/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles)
[cmake]   /usr/local/lib/cmake/llvm/FindTerminfo.cmake:21 (check_c_source_compiles)
[cmake]   /usr/local/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package)
[cmake]   tools/driver/CMakeLists.txt:6 (find_package)
[cmake] 
[cmake] 
[cmake] -- Could NOT find Terminfo (missing: Terminfo_LINKABLE) 
[cmake] -- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)

如何修复它?

gav*_*n.d 5

这实际上是clang-14 及更高版本中的一个众所周知的问题。

临时解决方案是在项目中使用C语言。

project(test LANGUAGES C CXX) # instead of project(test LANGUAGES CXX)
Run Code Online (Sandbox Code Playgroud)