From 9c263144cc63533f4ad4ade66b8728a24ac852ad Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Thu, 17 Dec 2015 08:22:52 +0000
Subject: [PATCH] code factorization for starpu functions test

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f5cb68ce..35d3cf031 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -596,15 +596,23 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
             if(STARPU_LINKER_FLAGS)
                 list(APPEND CMAKE_EXE_LINKER_FLAGS "${STARPU_LINKER_FLAGS}")
             endif()
-            set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS}")
+            set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS_DEP}")
             foreach(libdir ${STARPU_LIBRARY_DIRS_DEP})
                 list(APPEND CMAKE_REQUIRED_FLAGS "-L${libdir}")
             endforeach()
+            set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES_DEP}")
+            if (CHAMELEON_USE_MPI)
+                list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}")
+                list(APPEND CMAKE_REQUIRED_FLAGS "${MPI_C_LINK_FLAGS}")
+                list(APPEND CMAKE_REQUIRED_LIBRARIES "${MPI_C_LIBRARIES}")
+                if (NOT CHAMELEON_SIMULATION)
+                    list(APPEND CMAKE_REQUIRED_LIBRARIES "mpi")
+                endif()
+            endif()
             if (CHAMELEON_SIMULATION)
                 list(APPEND CMAKE_REQUIRED_FLAGS "-include" "starpu_simgrid_wrap.h")
             endif()
             string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
-            set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES_DEP}")
             check_function_exists(starpu_data_idle_prefetch_on_node STARPU_IDLE_PREFETCH_FOUND)
             if ( STARPU_IDLE_PREFETCH_FOUND )
                 add_definitions(-DCHAMELEON_USE_STARPU_IDLE_PREFETCH)
@@ -615,7 +623,6 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
             endif()
             if(CHAMELEON_ENABLE_TRACING)
                 # check if fxt profiling is accessible in starpu and activate it in chameleon
-                set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES_DEP}")
                 unset(STARPU_FXT_START_PROFILING_FOUND CACHE)
                 check_function_exists(starpu_fxt_start_profiling STARPU_FXT_START_PROFILING_FOUND)
                 if ( STARPU_FXT_START_PROFILING_FOUND )
@@ -628,15 +635,8 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
                     message("-- ${Red}Check in CMakeFiles/CMakeError.log to figure out why it fails${ColourReset}")
                 endif()
             endif()
-            if (CHAMELEON_USE_MPI AND STARPU_MPI_LIBRARIES)
+            if (CHAMELEON_USE_MPI)
                 # Check if a specific function exist
-                list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}")
-                list(APPEND CMAKE_REQUIRED_FLAGS "${MPI_C_LINK_FLAGS}")
-                set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES_DEP}")
-                list(APPEND CMAKE_REQUIRED_LIBRARIES "${MPI_C_LIBRARIES}")
-                if (NOT CHAMELEON_SIMULATION)
-                    list(APPEND CMAKE_REQUIRED_LIBRARIES "mpi")
-                endif()
                 unset(STARPU_MPI_DATA_REGISTER_FOUND CACHE)
                 check_function_exists(starpu_mpi_data_register_comm STARPU_MPI_DATA_REGISTER_FOUND)
                 if ( STARPU_MPI_DATA_REGISTER_FOUND )
-- 
GitLab