I am trying to build LAMMPS with the VTK package. I am getting this error when running cmake:
CMake Error at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find MPI (missing: MPI_C_FOUND C)
Reason given by package: MPI component 'C' was requested, but language C is not enabled.
Call Stack (most recent call first):
/usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.31/Modules/FindMPI.cmake:1842 (find_package_handle_standard_args)
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:397 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include)
Modules/Packages/VTK.cmake:1 (find_package)
CMakeLists.txt:585 (include)
Yes, that could be the solution. However it’s not really “my” project and I wouldn’t want to hack into the CMake files of LAMMPS as I have limited developer experience. I’ll try, but I would really prefer another solution, if exists.
Eh…I don’t think so. enable_language should not be called from function and there’s nothing saying find_package(VTK) can’t be there. Users also might not be expecting C bits to be used suddenly. I feel like something like:
# Require MPI support exist.
if (TARGET VTK::mpi AND
# Require there be a reason we were looking for it.
DEFINED VTK_mpi_FOUND AND
# Require that finding it failed.
NOT VTK_mpi_FOUND)
# Detect if the C language is around.
if (NOT CMAKE_C_COMPILER_WORKS)
list(APPEND VTK_mpi_NOT_FOUND_MESSAGE
"The C language is not available; MPI needs C enabled in order to be detected")
endif ()
endif ()
(adapted for vtk-config’s…unqiue variable naming mechanisms).