Merge remote-tracking branch 'gerrit/release-4-5-patches' into release-4-6
[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 include(CheckCSourceCompiles)
9 MACRO(GMX_TEST_MPI_IN_PLACE VARIABLE)
10     MESSAGE(STATUS "Checking for MPI_IN_PLACE")
11
12     set(CMAKE_REQUIRED_DEFINITIONS ${MPI_COMPILE_FLAGS})
13     set(CMAKE_REQUIRED_INCLUDES ${MPI_INCLUDE_PATH})
14     set(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBRARIES})
15     check_c_source_compiles(
16       "#include <mpi.h>
17 int main(void) {
18   void* buf;
19   MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
20 }" MPI_IN_PLACE_COMPILE_OK)
21
22     if(MPI_IN_PLACE_COMPILE_OK)
23         MESSAGE(STATUS "Checking for MPI_IN_PLACE - yes")
24             set(${VARIABLE} ${MPI_IN_PLACE_COMPILE_OK} 
25                 "Result of test for MPI_IN_PLACE")
26     else(MPI_IN_PLACE_COMPILE_OK)
27         MESSAGE(STATUS "Checking for MPI_IN_PLACE - no")
28     endif(MPI_IN_PLACE_COMPILE_OK)
29 ENDMACRO(GMX_TEST_MPI_IN_PLACE VARIABLE)
30
31
32