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

CMake error in FindTerminfo with clang-15 on MacOS

我在我的项目中使用 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!

如何解决?

它实际上是一个 well-known issue in clang-14 and greater.

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

project(test LANGUAGES C CXX) # instead of project(test LANGUAGES CXX)