Merge branch 'release-4-5-patches'
[alexxy/gromacs.git] / cmake / gmxTestMPI_IN_PLACE.cmake
1 # - Define macro to check if MPI_IN_PLACE exists
2 #
3 #  GMX_TEST_MPI_IN_PLACE(VARIABLE)
4 #
5 #  VARIABLE will be set to true if MPI_IN_PLACE exists
6 #
7
8 MACRO(GMX_TEST_MPI_IN_PLACE VARIABLE)
9     MESSAGE(STATUS "Checking for MPI_IN_PLACE")
10
11     set(CMAKE_REQUIRED_DEFINITIONS ${MPI_COMPILE_FLAGS})
12     set(CMAKE_REQUIRED_INCLUDES ${MPI_INCLUDE_PATH})
13     set(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBRARIES})
14     check_c_source_compiles(
15       "#include <mpi.h>
16 int main(void) {
17   void* buf;
18   MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
19 }" MPI_IN_PLACE_COMPILE_OK)
20
21     if(MPI_IN_PLACE_COMPILE_OK)
22         MESSAGE(STATUS "Checking for MPI_IN_PLACE - yes")
23             set(${VARIABLE} ${MPI_IN_PLACE_COMPILE_OK} 
24                 "Result of test for MPI_IN_PLACE")
25     else(MPI_IN_PLACE_COMPILE_OK)
26         MESSAGE(STATUS "Checking for MPI_IN_PLACE - no")
27     endif(MPI_IN_PLACE_COMPILE_OK)
28 ENDMACRO(GMX_TEST_MPI_IN_PLACE VARIABLE)
29
30
31