'CMake error in FindTerminfo with clang-15 on MacOS

I'm using llvm in my project and find it with cmake's find_package(LLVM REQUIRED CONFIG).

Configuration fails with message:

[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!

How to fix it?



Solution 1:[1]

It's actually a well-known issue in clang-14 and greater.

Temporary solution is to use C language in your project.

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gavrilikhin.d