keyword "project" would prevent "find_package(MPI)" setting variables
On ubuntu 16.04 + CMake 3.9.1 + gcc 5.4.1 + openmpi
,If I comment out project(main)
, CMake can find MPI_INCLUDE_PATH.
But if I add project(main)
, it seems that it would reset MPI variables
to empty.
Here is the CMakeList.txt to reproduce the problem.[CMakeLists.txt] (/uploads/f19275ec93e381721f4f1cf68269eeb0/CMakeLists.txt)
1 cmake_minimum_required(VERSION 3.0)
2
3 set (CMAKE_CXX_STANDARD 11)
4 set(CMAKE_CXX_STARARD REQUIRED)
5
6 find_package(MPI)
7
8 message("MPI_INCLUDE_PATH: " ${MPI_INCLUDE_PATH})
9 include_directories(SYSTEM ${MPI_INCLUDE_PATH})
10
11 project(main)
Edited by Haocheng LIU