From 00d8f84d6bfd2e4e2f78385d83c86b0a00aada9a Mon Sep 17 00:00:00 2001
From: Berenger Bramas <berenger.bramas@inria.fr>
Date: Tue, 5 Jun 2012 14:40:55 +0200
Subject: [PATCH] Update the cmake to compile mpi program.

---
 CMakeLists.txt | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 875461943..90819632b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,11 +6,14 @@ if(insource)
     MESSAGE(FATAL_ERROR "${PROJECT_NAME} requires an out of source build. Goto ./Build and tapes cmake ../")
 endif(insource)
 
-# MPI option has to be set before project
-OPTION( SCALFMM_USE_MPI "Set to ON to build ScaFMM with MPI" OFF )
+# MPI option has to be set before project, cannot be changed in the cache!
 if( SCALFMM_USE_MPI )
-	SET(CMAKE_CXX_COMPILER mpicxx)
-endif()
+	include(CMakeForceCompiler)
+	CMAKE_FORCE_C_COMPILER(mpicc "MPI C Compiler") 
+    	CMAKE_FORCE_CXX_COMPILER(mpicxx "MPI C++ Compiler")
+else()
+	MESSAGE(STATUS "Remove CMake cache and run cmake .. -DSCALFMM_USE_MPI=ON to enable MPI" )
+endif(SCALFMM_USE_MPI)
 
 # Project Infos
 project(scalfmm)
-- 
GitLab