Threads should either trigger language enablement, or not rely on it
Consider the following CMakeLists:
make_minimum_required(VERSION 3.25 FATAL_ERROR)
project(foo Fortran)
find_package(Threads)
add_library(foo INTERFACE foo.f90)
if (Threads_FOUND)
target_link_libraries(foo INTERFACE Threads::Threads)
endif()
this fails at find_package()
, with the error:
CMake Error at /path/to/cmake/Modules/FindThreads.cmake:66 (message):
FindThreads only works if either C or CXX language is enabled
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
This failure doesn't make sense. If a package can require the enablement of a language - then it should be able to trigger the enablement of that language, itself. And on the contrary, if a package can't require the enablement of the language, then it is illegitimate for FindThreads to fail this way.