From b82fa316da3f1746bd07b6c1ea50863f4449b43a Mon Sep 17 00:00:00 2001 From: Rossen Apostolov Date: Sat, 30 Oct 2010 19:27:54 +0200 Subject: [PATCH] For MPI builds, CMake will first try to compile a sample MPI program. 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 | 8 ++++++++ cmake/TestMPI.c | 6 ++++++ src/gmxlib/CMakeLists.txt | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 cmake/TestMPI.c diff --git a/cmake/FindMPI.cmake b/cmake/FindMPI.cmake index 481b0e994d..a0c36ed77a 100644 --- a/cmake/FindMPI.cmake +++ b/cmake/FindMPI.cmake @@ -72,6 +72,14 @@ # 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 index 0000000000..4eab044ae7 --- /dev/null +++ b/cmake/TestMPI.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char **argv) +{ + MPI_Init(&argc,&argv); +} diff --git a/src/gmxlib/CMakeLists.txt b/src/gmxlib/CMakeLists.txt index f3802c2719..21bdd4c423 100644 --- a/src/gmxlib/CMakeLists.txt +++ b/src/gmxlib/CMakeLists.txt @@ -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) -- 2.22.0