For MPI builds, CMake will first try to compile a sample MPI program.
authorRossen Apostolov <rossen@cbr.su.se>
Sat, 30 Oct 2010 17:27:54 +0000 (19:27 +0200)
committerRossen Apostolov <rossen@cbr.su.se>
Sat, 30 Oct 2010 17:27:54 +0000 (19:27 +0200)
On some systems such as Cray the FindMPI.cmake module can't find the proper
libraries to link to. Therefore we now test whether the given C compiler
is an MPI wrapper and skip the rest of the tests.
Thanks to Roland Schulz for the patch.

cmake/FindMPI.cmake
cmake/TestMPI.c [new file with mode: 0644]
src/gmxlib/CMakeLists.txt

index 481b0e994dfa5d6c73c3a888444c90637a869a19..a0c36ed77af5dd34443a3886296d45098bffda5c 100644 (file)
 # Microsoft HPC SDK is automatically added to the system path
 # Argonne National Labs MPICH2 sets a registry key that we can use.
 
+TRY_COMPILE(MPI_FOUND ${CMAKE_BINARY_DIR}
+  "${CMAKE_SOURCE_DIR}/cmake/TestMPI.c"
+  COMPILE_DEFINITIONS )
+
+if(MPI_FOUND)
+  return()
+endif()
+
 set(_MPI_PACKAGE_DIR
   mpi
   mpich
diff --git a/cmake/TestMPI.c b/cmake/TestMPI.c
new file mode 100644 (file)
index 0000000..4eab044
--- /dev/null
@@ -0,0 +1,6 @@
+#include <mpi.h> 
+
+int main(int argc, char **argv)
+{
+  MPI_Init(&argc,&argv);
+}
index f3802c27198ba7d94aa5c0cd5db0ab8580f25aa1..21bdd4c4236583e43d039fbd1ca368b7b935bac4 100644 (file)
@@ -136,7 +136,9 @@ endif(NOT GMX_OPENMM)
 
 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${GMX_SSEKERNEL_C_SRC} ${GMX_SSEKERNEL_ASM_SRC} ${FORTRAN_SOURCES} ${GMX_BLUEGENE_C_SRC} ${THREAD_MPI_SRC})
 target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES}  ${THREAD_LIB})
-add_dependencies(gmx gmx_version) 
+if(USE_VERSION_H)
+       add_dependencies(gmx gmx_version) 
+endif()
 set_target_properties(gmx PROPERTIES OUTPUT_NAME "gmx${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
 
 install(TARGETS gmx DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)