FindMPI.cmake make configuration fail when it is not found even is not required
If libopenmpi-dev
is not installed this simple CMakeLists.txt fails
cmake_minimum_required(VERSION 3.11)
project(foo)
find_package(MPI QUIET)
Log:
CMake Error in /home/ngenesio/dev/CMakeBug/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "MPI::MPI_C" includes non-existent path
"/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in /home/ngenesio/dev/CMakeBug/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "MPI::MPI_C" includes non-existent path
"/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error at /usr/share/cmake-3.11/Modules/FindMPI.cmake:1179 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
/usr/share/cmake-3.11/Modules/FindMPI.cmake:1220 (_MPI_try_staged_settings)
/usr/share/cmake-3.11/Modules/FindMPI.cmake:1480 (_MPI_check_lang_works)
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/ngenesio/dev/CMakeBug/build/CMakeFiles/CMakeOutput.log".
Tried on Debian testing, cmake 3.11 cc @drdanz