From 5ca32fa2b89e582b550fb9d2f4939a0892180c4a Mon Sep 17 00:00:00 2001
From: Matthieu Kuhn <mkuhn@scm.gforge.inria.fr>
Date: Mon, 22 May 2017 15:02:30 +0200
Subject: [PATCH] Fixed and added required includes for ptscotch tests

---
 modules/find/FindPTSCOTCH.cmake | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/find/FindPTSCOTCH.cmake b/modules/find/FindPTSCOTCH.cmake
index 1396d05..1e81c0d 100644
--- a/modules/find/FindPTSCOTCH.cmake
+++ b/modules/find/FindPTSCOTCH.cmake
@@ -285,7 +285,7 @@ if(PTSCOTCH_LIBRARIES)
   # MPI
   if (MPI_FOUND)
     if (MPI_C_INCLUDE_PATH)
-      list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}")
+      list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}")
     endif()
     if (MPI_C_LINK_FLAGS)
       if (${MPI_C_LINK_FLAGS} MATCHES "  -")
@@ -373,12 +373,15 @@ mark_as_advanced(PTSCOTCH_DIR_FOUND)
 # Check the size of SCOTCH_Num
 # ---------------------------------
 set(CMAKE_REQUIRED_INCLUDES ${PTSCOTCH_INCLUDE_DIRS})
-
+# Add ptscotch dependencies incdirs (mainly MPI) to required includes for the examples
+list(APPEND CMAKE_REQUIRED_INCLUDES ${PTSCOTCH_INCLUDE_DIRS_DEP})
 include(CheckCSourceRuns)
 #stdio.h and stdint.h should be included by scotch.h directly
+#mpi.h not included into ptscotch.h => MPI_comm undefined
 set(PTSCOTCH_C_TEST_SCOTCH_Num_4 "
 #include <stdio.h>
 #include <stdint.h>
+#include <mpi.h>
 #include <ptscotch.h>
 int main(int argc, char **argv) {
   if (sizeof(SCOTCH_Num) == 4)
@@ -391,6 +394,7 @@ int main(int argc, char **argv) {
 set(PTSCOTCH_C_TEST_SCOTCH_Num_8 "
 #include <stdio.h>
 #include <stdint.h>
+#include <mpi.h>
 #include <ptscotch.h>
 int main(int argc, char **argv) {
   if (sizeof(SCOTCH_Num) == 8)
-- 
GitLab