Skip to content

cmake fix: don't enable fortran if there is no fortran compiler

Fixes the following issue which occurs when a fortran compiler is not installed:

-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is unknown
-- Performing Test cxx_std_flag_17
-- Performing Test cxx_std_flag_17 - Success
-- Performing Test compiler_supports_cxx17
-- Performing Test compiler_supports_cxx17 - Success
-- Performing Test HAS_ATTRIBUTE_UNUSED
-- Performing Test HAS_ATTRIBUTE_UNUSED - Success
-- Performing Test HAS_ATTRIBUTE_DEPRECATED
-- Performing Test HAS_ATTRIBUTE_DEPRECATED - Success
-- Performing Test HAS_ATTRIBUTE_DEPRECATED_MSG
-- Performing Test HAS_ATTRIBUTE_DEPRECATED_MSG - Success
-- Performing Test HAVE_IS_INDEXABLE_SUPPORT
-- Performing Test HAVE_IS_INDEXABLE_SUPPORT - Success
-- Performing Test DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
-- Performing Test DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION - Success
-- Performing Test DUNE_HAVE_CXX_OPTIONAL
-- Performing Test DUNE_HAVE_CXX_OPTIONAL - Success
-- Performing Test DUNE_HAVE_CXX_VARIANT
-- Performing Test DUNE_HAVE_CXX_VARIANT - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Performing Test STDTHREAD_WORKS
-- Performing Test STDTHREAD_WORKS - Success
-- Performing Test DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR
-- Performing Test DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR - Success
-- Performing Test DUNE_HAVE_C_ALIGNED_ALLOC
-- Performing Test DUNE_HAVE_C_ALIGNED_ALLOC - Success
-- Looking for C++ include experimental/type_traits
-- Looking for C++ include experimental/type_traits - found
-- Looking for std::move<std::bool_constant<true>>
-- Looking for std::move<std::bool_constant<true>> - found
-- Looking for std::apply<std::negate<int>,std::tuple<int>>
-- Looking for std::apply<std::negate<int>,std::tuple<int>> - found
-- Looking for std::experimental::make_array<int,int>
-- Looking for std::experimental::make_array<int,int> - found
-- Looking for std::move<std::experimental::detected_t<std::decay_t,int>>
-- Looking for std::move<std::experimental::detected_t<std::decay_t,int>> - found
-- Looking for std::identity
-- Looking for std::identity - not found
-- Performing Test HAVE_CXA_DEMANGLE
-- Performing Test HAVE_CXA_DEMANGLE - Success
-- Checking for module 'mpi-c'
--   No package 'mpi-c' found
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS) 
-- Checking for module 'mpi-cxx'
--   No package 'mpi-cxx' found
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS) 
CMake Error: CMAKE_Fortran_COMPILER not set, after EnableLanguage
CMake Error at /usr/share/cmake-3.22/Modules/FindMPI.cmake:1264 (try_compile):
  Failed to configure test project build system.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindMPI.cmake:1291 (_MPI_try_staged_settings)
  /usr/share/cmake-3.22/Modules/FindMPI.cmake:1481 (_MPI_check_lang_works)
  cmake/modules/DuneMPI.cmake:24 (find_package)
  cmake/modules/DuneMacros.cmake:705 (include)
  CMakeLists.txt:17 (dune_project)                                               

Merge request reports