Page MenuHomePhabricator

FindTerminfo.cmake: Don't require that C language support be enabled for CMake project.
Needs RevisionPublic

Authored by shaneharper on Dec 30 2021, 4:32 PM.

Details

Reviewers
jackoalan
Summary

Here's a simple CMakeLists.txt that demonstrates the problem:

project("My project does not use C" CXX)
set(LLVM_DIR  "${LLVM_obj-root}/lib/cmake/llvm")
find_package(LLVM REQUIRED CONFIG)

Test with:

cmake . -DLLVM_obj-root=`llvm-config --obj-root`

Without the patch to FindTerminfo.cmake CMake v3.16.3 will fail with:

Unknown extension ".c" for file
...
try_compile() works only for enabled languages.

Diff Detail

Event Timeline

shaneharper created this revision.Dec 30 2021, 4:32 PM
shaneharper requested review of this revision.Dec 30 2021, 4:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 30 2021, 4:32 PM
jackoalan requested changes to this revision.Dec 30 2021, 4:53 PM

Thank you for the patch! It makes sense that the check functions depend on the corresponding language to be enabled.

The only issue I see is the converse is also potentially true (where the importer only has C enabled to link with the C API).

It should be written to check C if it is in the ENABLED_LANGUAGES global property, and fall back to C++ otherwise.

If you could also make the same modification to FindFFI.cmake, this will be a very useful change for importers with C++-only projects.

This revision now requires changes to proceed.Dec 30 2021, 4:53 PM