title: Build MPICH with CMake
body: <p>I need to force my <strong>Cmake</strong> to build and link my MPI code with <strong>MPICH</strong>. My MPICH is installed using the Ubuntu Package manager, in a standard location <code>/usr/lib/mpich/</code>. However, CMake still looks for the <strong>OpenMPI</strong> libraries, which I do not use. <strong>How can I instruct CMake to look for MPICH instead?</strong></p>
  
  <p>Below, you can see the output of some basic diagnostics:</p>
  
  <pre><code>$ whereis openmpi
  openmpi:
  
  $ whereis mpich
  mpich: /usr/lib/mpich /usr/include/mpich
  
  $ mpicc -v
  mpicc for MPICH version 3.2
  </code></pre>
  
  <p>Below, I also provide the Cmake script and the <strong>errors</strong> I get from cmake and the <strong>mpirun.mpich</strong>. My Cmake is 3.5.1 and I run on Ubuntu Xenial 16.04.</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0)
  
  message (STATUS "Adding mpiService")
  
  find_package(MPI REQUIRED)
  
  set(CMAKE_C_COMPILER mpicc)
  set(CMAKE_CXX_COMPILER mpicxx)
  set(MPI_GUESS_LIBRARY_NAME MPICH2)
  
  message(STATUS ${MPI_INCLUDE_PATH}) 
  message(STATUS ${MPI_C_LIBRARIES}) 
  
  #add_definitions(-DOMPI_SKIP_MPICXX)
  
  add_executable(mpiService main.cpp)
  
  set(CMAKE_VERBOSE_MAKEFILE ON)
  
  include_directories(SYSTEM ${MPI_INCLUDE_PATH})
  
  target_link_libraries(
      mpiService
      PRIVATE
      ${MPI_C_LIBRARIES}
      )
  </code></pre>
  
  <p>From the Cmake STATUS I get the following output:</p>
  
  <pre><code>/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include/usr/lib/openmpi/include/usr/lib/openmpi/include/openmpi
  /usr/lib/openmpi/lib/libmpi.so
  </code></pre>
  
  <p>And when I run the binary I get the following:</p>
  
  <pre><code>ubuntu@node1:~$ mpirun.mpich -np 2 --host node1,node2 mpiService
  mpiService: error while loading shared libraries: libmpi.so.12: cannot open shared object file: No such file or directory
  mpiService: error while loading shared libraries: libmpi.so.12: cannot open shared object file: No such file or directory
  </code></pre>