FindHDF5: Detecting C component in a CXX project: "Unknown extension ".c" for file"
When using the HDF5 C
interface in a CXX
project, e.g.:
cmake_minimum_required(VERSION 3.16)
project(foo LANGUAGES CXX)
find_package(HDF5 REQUIRED COMPONENTS C)
one get an error:
CMake Error at /usr/share/cmake/Modules/FindHDF5.cmake:241 (try_compile):
Unknown extension ".c" for file
/tmp/cmake-hdf5/build/CMakeFiles/hdf5/cmake_hdf5_test.c
try_compile() works only for enabled languages. Currently these are:
CXX
See project() command to enable other languages.
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindHDF5.cmake:594 (_HDF5_test_regular_compiler_C)
CMakeLists.txt:3 (find_package)
which forces one to enable the C
language for an pure CXX
project.
Any workarounds?
(see https://github.com/ECP-copa/Cabana/pull/590 for a real world example of this issue)
Edited by Christoph Junghans