jedbrown / cmake-modules

CMake modules for some scientific libraries
BSD 2-Clause "Simplified" License
87 stars 54 forks source link

Add Test to verify MPI discovery #33

Closed fsimonis closed 3 years ago

fsimonis commented 5 years ago

This PR adds a test to verify the MPI discovery by compiling the following snippet:

include<mpi.h>
int main (int argc, char* argv[]) {
  return 0;
}

Success

-- Performing Test petsc-mpi
-- Performing Test petsc-mpi - Success
-- petsc_lib_dir /.../.../petsc/x68_64/lib
-- Recognized PETSc install with single library for all packages
-- Performing Test MULTIPASS_TEST_1_petsc_works_minimal
-- Performing Test MULTIPASS_TEST_1_petsc_works_minimal - Success

Failure

-- Performing Test petsc-mpi
-- Performing Test petsc-mpi - Failure
CMake Error at .../cmake-modules/FindPETSc.cmake:82 (message):
  Compilation of the petsc mpi test failed.  This indicates that the compiler
  cannot find mpi.h.  Make sure to set the compiler to the compiler wrapper
  provided by your MPI version prior to calling this script.

  Logfile of the compilation:
  /.../.../build/CMakeFiles/FindPETSc/petsc-mpi.log
Call Stack (most recent call first):
  CMakeLists.txt:60 (find_package)

-- Configuring incomplete, errors occurred!

Closes #32

jedbrown commented 5 years ago

One quirk I forgot to mention is that PETSc can be configured without MPI, so we shouldn't insist on it here. Maybe only do this test if a PETSc compile fails?

fsimonis commented 5 years ago

@jedbrown I realised that later too.

Anyhow, I turned the mpi check into a set of diagnostics which run after the standard tests fail. This should give the user some guidance on where to start.