1 cmake_minimum_required(VERSION 2.6)
2 # Keep CMake suitably quiet on Cygwin
3 set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
7 mark_as_advanced(DART_ROOT)
9 # PROJECT_VERSION should have the following structure:
10 # VERSION-dev[-SUFFIX] where the VERSION should have the for: vMajor.vMinor.vPatch
12 # The "-dev" suffix is important to keep because it makes possible to distinguish
13 # between a build from official release and a build from git release branch on a
14 # machine with no git.
16 # NOTE: when releasing the "-dev" suffix needs to be stripped off!
17 set(PROJECT_VERSION "4.5.5-dev")
18 set(CUSTOM_VERSION_STRING ""
19 CACHE STRING "Custom version string (if empty, use hard-coded default)")
20 mark_as_advanced(CUSTOM_VERSION_STRING)
21 if (CUSTOM_VERSION_STRING)
22 set(PROJECT_VERSION ${CUSTOM_VERSION_STRING})
23 endif (CUSTOM_VERSION_STRING)
25 # It is a bit irritating, but this has to be set separately for now!
26 SET(CPACK_PACKAGE_VERSION_MAJOR "4")
27 SET(CPACK_PACKAGE_VERSION_MINOR "5")
28 SET(CPACK_PACKAGE_VERSION_PATCH "5")
31 # Cmake modules/macros are in a subdirectory to keep this file cleaner
32 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
34 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
35 set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE)
38 if(NOT CMAKE_BUILD_TYPE)
39 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
40 endif(NOT CMAKE_BUILD_TYPE)
44 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
45 set(CPACK_PACKAGE_VENDOR "gromacs.org")
46 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation")
47 set(CPACK_SET_DESTDIR "ON")
48 set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
49 set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt")
50 # Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this...
51 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/admin/InstallLicense.txt")
52 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
54 #must come after all cpack settings!
57 ########################################################################
58 # Check and warn if cache generated on a different host is being reused
59 ########################################################################
61 execute_process(COMMAND hostname
62 OUTPUT_VARIABLE TMP_HOSTNAME
63 OUTPUT_STRIP_TRAILING_WHITESPACE)
64 if(GMX_BUILD_HOSTNAME AND NOT "${GMX_BUILD_HOSTNAME}" STREQUAL "${TMP_HOSTNAME}")
66 The CMake cache, probably generated on a different host (${GMX_BUILD_HOSTNAME}),
67 is being reused! This could lead to inconsitencies; therefore, it is
68 recommended to regenerate the cache!")
70 set(GMX_BUILD_HOSTNAME "${TMP_HOSTNAME}" CACHE INTERNAL
71 "Hostname of the machine where the cache was generated.")
74 ########################################################################
75 # Fix stupid flags on Windows
76 ########################################################################
77 SET(SHARED_LIBS_DEFAULT ON)
78 IF( (CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "NMake") AND MSVC )
79 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
80 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
81 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
82 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
83 SET(SHARED_LIBS_DEFAULT OFF)
86 IF(CMAKE_GENERATOR MATCHES "NMake" AND CMAKE_C_COMPILER_ID MATCHES "Intel")
87 STRING(REPLACE /GZ /RTC1 CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
88 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
89 STRING(REPLACE /GZ /RTC1 CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
90 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
91 SET(SHARED_LIBS_DEFAULT OFF)
94 set(GMX_EXTRA_LIBRARIES)
98 ######################################################################
100 # these need ot be done early (before further tests).
101 #####################################################################
103 include(CheckCCompilerFlag)
104 include(CheckCXXCompilerFlag)
109 ########################################################################
110 # User input options #
111 ########################################################################
112 option(GMX_DOUBLE "Use double precision (much slower, use only if you really need it)" OFF)
113 option(GMX_MPI "Build a parallel (message-passing) version of GROMACS" OFF)
114 option(GMX_THREADS "Build a parallel (thread-based) version of GROMACS (cannot be combined with MPI yet)" ON)
115 option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
116 mark_as_advanced(GMX_SOFTWARE_INVSQRT)
117 option(GMX_POWERPC_INVSQRT "Use PowerPC hardware 1/sqrt" OFF)
118 mark_as_advanced(GMX_POWERPC_INVSQRT)
119 option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
120 mark_as_advanced(GMX_FAHCORE)
121 option(GMX_OPENMM "Accelerated execution on GPUs through the OpenMM library (rerun cmake after changing to see relevant options)" OFF)
122 set(GMX_ACCELERATION "auto"
123 CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran")
125 set(GMX_FFT_LIBRARY "fftw3"
126 CACHE STRING "FFT library choices: fftw3,fftw2,mkl,fftpack[built-in]")
127 option(GMX_DISABLE_FFTW_MEASURE
128 "Do not optimize FFTW setups (not needed with SSE)" OFF)
129 mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
130 set(GMX_QMMM_PROGRAM "none"
131 CACHE STRING "QM package choices: none,gaussian,mopac,gamess,orca")
132 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
133 mark_as_advanced(GMX_BROKEN_CALLOC)
134 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic with MPI, Windows)" ${SHARED_LIBS_DEFAULT})
135 option(GMX_MPI_IN_PLACE "Enable MPI_IN_PLACE for MPIs that have it defined" ON)
136 mark_as_advanced(GMX_MPI_IN_PLACE)
137 option(GMX_DLOPEN "Compile with dlopen, needed to read VMD supported file formats" ON)
138 mark_as_advanced(GMX_DLOPEN)
141 option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
142 mark_as_advanced(GMX_IA32_ASM)
143 option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
144 mark_as_advanced(GMX_X86_64_ASM)
146 option(USE_VERSION_H "Generate development version string/information" ON)
147 mark_as_advanced(USE_VERSION_H)
149 option(GMX_DEFAULT_SUFFIX "Use default suffixes for GROMACS binaries and libs (_d for double, _mpi for MPI; rerun cmake after changing to see relevant options)" ON)
151 if(UNIX AND NOT APPLE)
152 option(GMX_PREFER_STATIC_LIBS "When finding libraries prefer \".a\" static archives (NOTE: this is enabled only for UNIX (excluding APPLE) platforms but it might not always work!" OFF)
153 mark_as_advanced(GMX_PREFER_STATIC_LIBS)
156 ########################################################################
157 # Set up binary and library suffixing
158 ########################################################################
159 set(GMX_BINARY_SUFFIX "" CACHE STRING "Suffix for GROMACS binaries (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
160 set(GMX_LIBS_SUFFIX ""
161 CACHE STRING "Suffix for GROMACS libs (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
162 if (GMX_DEFAULT_SUFFIX)
163 set(GMX_BINARY_SUFFIX "")
164 set(GMX_LIBS_SUFFIX "")
166 set(GMX_BINARY_SUFFIX "_mpi")
167 set(GMX_LIBS_SUFFIX "_mpi")
170 set (GMX_BINARY_SUFFIX "${GMX_BINARY_SUFFIX}_d")
171 set (GMX_LIBS_SUFFIX "${GMX_LIBS_SUFFIX}_d")
174 set (GMX_BINARY_SUFFIX "-gpu")
175 set (GMX_LIBS_SUFFIX "_gpu")
177 mark_as_advanced(FORCE GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
178 message(STATUS "Using default binary suffix: \"${GMX_BINARY_SUFFIX}\"")
179 message(STATUS "Using default library suffix: \"${GMX_LIBS_SUFFIX}\"")
180 else(GMX_DEFAULT_SUFFIX)
181 mark_as_advanced(CLEAR GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
182 message(STATUS "Using manually set binary suffix: \"${GMX_BINARY_SUFFIX}\"")
183 message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"")
184 endif(GMX_DEFAULT_SUFFIX)
188 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE")
190 if(GMX_SOFTWARE_INVSQRT)
191 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT")
192 endif(GMX_SOFTWARE_INVSQRT)
193 if(GMX_POWERPC_INVSQRT)
194 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_POWERPC_INVSQRT")
195 endif(GMX_POWERPC_INVSQRT)
197 ########################################################################
198 #Process MPI settings
199 ########################################################################
200 include(CheckCSourceCompiles) # for gmxTestMPI_IN_PLACE
203 #message(FATAL_ERROR "Thread-based parallelization conflicts with MPI.")
204 set(GMX_THREADS OFF CACHE BOOL
205 "Thread-based parallelization conflicts with MPI." FORCE)
209 set(GROMACS_C_FLAGS ${GROMACS_FLAGS} ${MPI_COMPILE_FLAGS})
210 set(GROMACS_LINKER_FLAGS ${GROMACS_LINKER_FLAGS} ${MPI_LINK_FLAGS})
212 include_directories(${MPI_INCLUDE_PATH})
213 list(APPEND GMX_EXTRA_LIBRARIES ${MPI_LIBRARIES})
215 add_definitions( -DMPI ) #for FAHCORE
217 include(gmxTestMPI_IN_PLACE)
218 if (GMX_MPI_IN_PLACE)
219 gmx_test_mpi_in_place(MPI_IN_PLACE_EXISTS)
220 endif (GMX_MPI_IN_PLACE)
222 # test for unsuitable versions of OpenMPI
223 exec_program(${MPIEXEC}
225 OUTPUT_VARIABLE MPI_TYPE
226 RETURN_VALUE MPI_EXEC_RETURN)
227 if(MPI_EXEC_RETURN EQUAL 0)
228 if(MPI_TYPE MATCHES "Open MPI|OpenRTE")
229 string(REGEX MATCH "[0-9]+\\.[0-9]*\\.?[0-9]*" MPI_VERSION ${MPI_TYPE})
230 if(MPI_VERSION VERSION_LESS "1.4.1")
232 There are known problems with OpenMPI version < 1.4.1.
233 Please consider updating your OpenMPI.")
234 endif(MPI_VERSION VERSION_LESS "1.4.1")
236 else(MPI_TYPE MATCHES "Open MPI|OpenRTE")
237 # This is not OpenMPI, so give the old generic warning message
239 There are known problems with some MPI implementations:
240 MVAPICH2 version <= 1.4.1
241 Please consider updating your MPI if applicable.")
242 endif(MPI_TYPE MATCHES "Open MPI|OpenRTE")
244 endif(MPI_EXEC_RETURN EQUAL 0)
246 message(FATAL_ERROR "MPI support requested, but no MPI compiler found.")
248 include(gmxTestCatamount)
249 gmx_test_catamount(GMX_CRAY_XT3)
251 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
256 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")
260 #######################################################################
261 # Check for options incompatible with OpenMM build #
262 #######################################################################
264 cmake_minimum_required(VERSION 2.6.4)
265 # we'll use the built-in fft to avoid unnecessary dependencies
266 string(TOUPPER ${GMX_FFT_LIBRARY} GMX_FFT_LIBRARY)
267 if(NOT ${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
268 message(STATUS "No external FFT libraries needed for the OpenMM build, switching to fftpack!")
269 set(GMX_FFT_LIBRARY "fftpack" CACHE STRING
270 "No external FFT libraries needed for the OpenMM build, switching to fftpack!" FORCE)
273 message(FATAL_ERROR "The OpenMM build is not compatible with MPI!")
276 message(STATUS "Threads are not compatible with OpenMM build, disabled!")
277 set(GMX_THREADS OFF CACHE BOOL
278 "Threads are not compatible with OpenMM build, disabled!" FORCE)
280 if(GMX_SOFTWARE_INVSQRT)
281 set(GMX_SOFTWARE_INVSQRT OFF CACHE STRING
282 "The OpenMM build does not need GROMACS software 1/sqrt!" FORCE)
283 endif(GMX_SOFTWARE_INVSQRT)
284 string(TOUPPER ${GMX_ACCELERATION} GMX_ACCELERATION)
285 if(NOT GMX_ACCELERATION STREQUAL "NONE")
286 message(STATUS "Switching off CPU-based acceleration, the OpenMM build does not support/need any!")
287 set(GMX_ACCELERATION "none" CACHE STRING
288 "Switching off CPU-based acceleration, the OpenMM build does not support/need any!" FORCE)
291 message(FATAL_ERROR "The OpenMM build does not support FAH build!")
294 message(FATAL_ERROR "The OpenMM-build does not support double precision calculations!")
296 # mark as advanced the unused variables
297 mark_as_advanced(FORCE GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
298 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
300 mark_as_advanced(CLEAR GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
301 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
305 ########################################################################
306 # Basic system tests (standard libraries, headers, functions, types) #
307 ########################################################################
308 include(CheckIncludeFiles)
309 check_include_files(string.h HAVE_STRING_H)
310 check_include_files(math.h HAVE_MATH_H)
311 check_include_files(limits.h HAVE_LIMITS_H)
312 check_include_files(memory.h HAVE_MEMORY_H)
313 check_include_files(unistd.h HAVE_UNISTD_H)
314 check_include_files(direct.h HAVE_DIRECT_H)
315 check_include_files(pwd.h HAVE_PWD_H)
316 check_include_files(stdint.h HAVE_STDINT_H)
317 check_include_files(stdlib.h HAVE_STDLIB_H)
318 check_include_files(pthread.h HAVE_PTHREAD_H)
319 check_include_files(dirent.h HAVE_DIRENT_H)
320 check_include_files(inttypes.h HAVE_INTTYPES_H)
321 check_include_files(regex.h HAVE_REGEX_H)
322 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
323 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
324 check_include_files(sys/time.h HAVE_SYS_TIME_H)
325 check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
326 check_include_files("rpc/rpc.h;rpc/xdr.h" HAVE_RPC_XDR_H)
328 check_include_files(xmmintrin.h HAVE_XMMINTRIN_H)
329 check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
330 check_include_files(pmmintrin.h HAVE_PMMINTRIN_H)
331 check_include_files(smmintrin.h HAVE_SMMINTRIN_H)
332 check_include_files(io.h HAVE_IO_H)
335 include(CheckFunctionExists)
336 check_function_exists(strcasecmp HAVE_STRCASECMP)
337 check_function_exists(strdup HAVE_STRDUP)
338 check_function_exists(vprintf HAVE_VPRINTF)
339 check_function_exists(memcmp HAVE_MEMCMP)
340 check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
341 check_function_exists(memalign HAVE_MEMALIGN)
342 check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
343 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
344 check_function_exists(isnan HAVE_ISNAN)
345 check_function_exists(_isnan HAVE__ISNAN)
346 check_function_exists(fsync HAVE_FSYNC)
347 check_function_exists(_fileno HAVE__FILENO)
348 check_function_exists(fileno HAVE_FILENO)
349 check_function_exists(_commit HAVE__COMMIT)
350 check_function_exists(lstat HAVE_LSTAT)
352 include(CheckLibraryExists)
353 check_library_exists(m sqrt "" HAVE_LIBM)
354 check_library_exists(m cbrt "" HAVE_CBRT)
357 include(CheckTypeSize)
359 check_type_size("bool" SIZEOF_BOOL) # will also set HAVE_BOOL
360 check_type_size("int" SIZEOF_INT)
361 check_type_size("long int" SIZEOF_LONG_INT)
362 check_type_size("long long int" SIZEOF_LONG_LONG_INT)
363 check_type_size("off_t" SIZEOF_OFF_T)
364 check_type_size("void *" SIZEOF_VOIDP)
366 if (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
368 else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
369 set(GMX_64_BIT FALSE)
370 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
372 # Check for some basic types that we *need*, so set these to int if they are not present
373 check_type_size(uid_t uid_t)
380 check_type_size(gid_t gid_t)
387 check_type_size(size_t size_t)
394 check_type_size(off_t off_t)
401 include(TestBigEndian)
402 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
407 ########################################################################
408 # Find external packages #
409 ########################################################################
410 if(UNIX AND NOT APPLE)
411 if(GMX_PREFER_STATIC_LIBS)
412 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
413 if(BUILD_SHARED_LIBS)
414 message(WARNING "Static libraries requested, the GROMACS libraries will also be build static (BUILD_SHARED_LIBS=OFF)")
415 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Enable shared libraries (can be problematic with MPI, Windows)" FORCE)
420 option(GMX_XML "Use libxml2 to parse xml files" ON)
422 find_package(LibXml2)
425 include_directories(${LIBXML2_INCLUDE_DIR})
426 set(PKG_XML libxml-2.0)
427 set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
432 option(GMX_GSL "Add support for gsl" OFF)
437 include_directories(${GSL_INCLUDE_DIR})
443 option(GMX_X11 "Use X window system" OFF)
446 # X11 includes/libraries are only set in the ngmx subdirectory!
453 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREADS")
455 set(THREAD_MPI_LIB thread_mpi)
457 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
458 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
459 message(FATAL_ERROR "FFTW2 can't be used with threads. Try fftw3 or mkl.")
464 set(CUDA_BUILD_EMULATION OFF)
465 find_package(CUDA 3.1 REQUIRED)
466 add_definitions(-DGMX_OPENMM)
467 if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
468 set(CUDA_VERBOSE_BUILD ON)
474 find_library(ACCELERATE_FRAMEWORK Accelerate)
475 list(APPEND GMX_EXTRA_LIBRARIES ${ACCELERATE_FRAMEWORK})
482 # only bother with finding git and using version.h if the source is a git repo
483 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
485 # We need at least git v1.5.1 be able to parse git's date output. If not
486 # fund or the version is too small, we can't generate version information.
487 find_package(Git 1.5.1)
488 # this should at some point become VERSION_LESS
489 if(NOT Git_FOUND OR Git_VERSION STRLESS "1.5.1")
490 message("No compatible git version found, won't be able to generate proper development version information.")
491 set(USE_VERSION_H OFF)
495 set(USE_VERSION_H OFF)
499 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
500 set(PKG_DL_LIBS "-l${CMAKE_DL_LIBS}")
505 ########################################################################
506 # Generate development version info for cache
507 ########################################################################
508 # set(GEN_VERSION_INFO_INTERNAL "ON")
509 # include(gmxGenerateVersionString)
511 ########################################################################
512 # Our own GROMACS tests
513 ########################################################################
515 add_definitions( -DHAVE_CONFIG_H )
516 include_directories(${CMAKE_BINARY_DIR}/src)
517 include_directories(${CMAKE_SOURCE_DIR}/include)
519 include(gmxCheckBuildUserTime)
520 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
522 include(gmxTestFloatFormat)
523 gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
524 GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
525 GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
527 include(gmxTestLargeFiles)
528 gmx_test_large_files(GMX_LARGEFILES)
529 check_function_exists(fseeko HAVE_FSEEKO)
531 include(gmxTestSignal)
532 gmx_test_retsigtype(RETSIGTYPE)
533 gmx_test_sigusr1(HAVE_SIGUSR1)
535 include(gmxTestInline)
536 gmx_test_inline(INLINE_KEYWORD)
538 include(gmxTestRestrict)
539 gmx_test_inline(RESTRICT_KEYWORD)
541 include(gmxTestPipes)
542 gmx_test_pipes(HAVE_PIPES)
544 include(gmxTestIsfinite)
545 gmx_test_isfinite(HAVE_ISFINITE)
546 gmx_test__isfinite(HAVE__ISFINITE)
547 gmx_test__finite(HAVE__FINITE)
549 include(gmxTestInlineASM)
550 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
551 gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
553 # turn on SSE if supported with reasonable defaults.
554 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
555 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x64|x86_64|AMD64|amd64)" OR CYGWIN)
557 set(GMX_ACCELERATION "SSE" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
559 # Determine the assembler/compiler to use
561 set(GMX_ACCELERATION "none" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
563 endif (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
566 gmx_test_xdr(GMX_SYSTEM_XDR)
567 if(NOT GMX_SYSTEM_XDR)
568 set(GMX_INTERNAL_XDR 1)
569 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
570 endif(NOT GMX_SYSTEM_XDR)
572 # Process nonbonded accelerated kernels settings
573 string(TOUPPER ${GMX_ACCELERATION} ${GMX_ACCELERATION})
574 if(${GMX_ACCELERATION} STREQUAL "NONE")
576 elseif(${GMX_ACCELERATION} STREQUAL "SSE")
579 set(GMX_X86_64_ASM ON CACHE BOOL "Add SSE assembly files for x86_64" FORCE)
581 set(GMX_IA32_ASM ON CACHE BOOL "Add SSE assembly files for i386" FORCE)
584 if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES NMake )
585 option(GMX_ASM_USEASM_NASM "Use Nasm for assembly instead of compiler (necessary on windows)" ON)
587 option(GMX_ASM_USEASM_NASM "Use Nasm for assembly instead of compiler (necessary on windows)" OFF)
589 mark_as_advanced(GMX_ASM_USEASM_NASM)
592 # for 32-bit compiles, we might need to turn on sse
593 CHECK_C_COMPILER_FLAG("-msse2" XFLAGS_SSE)
595 set(GROMACS_C_FLAGS "-msse2 ${GROMACS_C_FLAGS}")
597 CHECK_CXX_COMPILER_FLAG("-msse2" XXFLAGS_SSE)
599 set(GROMACS_CXX_FLAGS "-msse2 ${GROMACS_CXX_FLAGS}")
601 endif (NOT GMX_64_BIT)
609 elseif(GMX_X86_64_ASM)
611 set(GMX_X86_64_SSE2 1)
613 set(GMX_X86_64_SSE 1)
617 # if(HAVE_PMMINTRIN_H)
619 # endif(HAVE_PMMINTRIN_H)
620 # if(HAVE_SMMINTRIN_H)
622 # endif(HAVE_SMMINTRIN_H)
624 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
626 #these are switch on by default sometimes
628 set(GMX_GMX_X86_64_ASM 0)
629 elseif(${GMX_ACCELERATION} STREQUAL "BLUEGENE")
630 # GMX_ACCELERATION=BlueGene should be set in the Toolchain-BlueGene?-???.cmake file
631 message(STATUS "Configuring for BlueGene")
633 if (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
634 set(SHARED_LIBS_DEFAULT OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
635 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
636 endif (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
637 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene" FORCE)
638 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on BlueGene" FORCE)
639 set(GMX_X11 OFF CACHE BOOL "X11 not compatible with BlueGene, disabled!" FORCE)
640 set(GMX_THREADS OFF CACHE BOOL "Threads not compatible with BlueGene, disabled!" FORCE)
641 set(GMX_MPI ON CACHE BOOL "Use MPI on BlueGene" FORCE)
642 elseif(${GMX_ACCELERATION} STREQUAL "POWER6")
644 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on Power6" FORCE)
645 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on Power6" FORCE)
646 elseif(${GMX_ACCELERATION} STREQUAL "IA64")
648 set(DISABLE_WATERWATER_NLIST 1)
649 set(DISABLE_WATER_NLIST 1)
650 elseif(${GMX_ACCELERATION} STREQUAL "ALTIVEC")
651 check_include_files(altivec.h HAVE_ALTIVEC_H)
653 set(GMX_PPC_ALTIVEC 1)
654 endif(HAVE_ALTIVEC_H)
655 else(${GMX_ACCELERATION} STREQUAL "NONE")
656 MESSAGE(FATAL_ERROR "Unrecognized option for accelerated kernels: ${GMX_ACCELERATION}. Pick one of auto, none, SSE, Fortran, BlueGene, Power6, ia64, altivec")
657 endif(${GMX_ACCELERATION} STREQUAL "NONE")
659 if(GMX_FORTRAN OR GMX_POWER6)
661 message(FATAL_ERROR "FORTRAN/POWER6 is incompatible with threads and only provides a speed-up on certain IBM compilers. Disable FORTRAN (or threads if you really want to use FORTRAN kernels).")
663 enable_language(Fortran)
664 include(FortranCInterface)
665 discover_fortran_mangling(prefix isupper suffix extra_under_score found)
666 if(extra_under_score)
668 endif(extra_under_score)
670 set(prefix "${prefix} ##")
673 set(suffix "## ${suffix}")
675 set(extrasuffix "${suffix}${extrasuffix}")
679 # Don't know if this is needed, but it can't hurt
680 set(extrasuffix "## ${extrasuffix}")
685 set(F77_FUNCDEF "${prefix} NAME ${suffix}")
686 set(F77_FUNCDEF_ "${prefix} NAME ${extrasuffix}")
688 set(F77_FUNCDEF "${prefix} name ${suffix}")
689 set(F77_FUNCDEF_ "${prefix} name ${extrasuffix}")
691 else(GMX_FORTRAN OR GMX_POWER6)
692 set(F77_FUNCDEF "name ## _")
693 set(F77_FUNCDEF_ "name ## _")
694 endif(GMX_FORTRAN OR GMX_POWER6)
696 # Process QM/MM Settings
697 string(TOUPPER ${GMX_QMMM_PROGRAM} ${GMX_QMMM_PROGRAM})
698 if(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
699 set(GMX_QMMM_GAUSSIAN 1)
700 elseif(${GMX_QMMM_PROGRAM} STREQUAL "MOPAC")
701 set(GMX_QMMM_MOPAC 1)
702 elseif(${GMX_QMMM_PROGRAM} STREQUAL "GAMESS")
703 set(GMX_QMMM_GAMESS 1)
704 elseif(${GMX_QMMM_PROGRAM} STREQUAL "ORCA")
706 elseif(${GMX_QMMM_PROGRAM} STREQUAL "NONE")
708 else(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
709 MESSAGE(FATAL_ERROR "Invalid QM/MM program option: ${GMX_QMMM_PROGRAM}. Choose one of: Gaussian, Mopac, Gamess, Orca, None")
710 endif(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
712 # Process FFT library settings - if not OpenMM build
713 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
716 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
717 # MESSAGE(STATUS "Using external FFT library - fftw3")
719 find_package(FFTW3 REQUIRED)
720 include_directories(${FFTW3_INCLUDE_DIR})
721 set(FFT_LIBRARIES ${FFTW3_LIBRARIES})
724 find_package(FFTW3F REQUIRED)
725 include_directories(${FFTW3F_INCLUDE_DIR})
726 set(FFT_LIBRARIES ${FFTW3F_LIBRARIES})
727 set(PKG_FFT "fftw3f")
730 if(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
731 MESSAGE(FATAL_ERROR "Cannot find fftw3 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
732 endif(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
736 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
737 # MESSAGE(STATUS "Using external FFT library - fftw2")
739 find_package(FFTW2 REQUIRED)
741 find_package(FFTW2F REQUIRED)
745 MESSAGE(FATAL_ERROR "Cannot find fftw2 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
746 endif(NOT FFTW2_FOUND)
747 include_directories(${FFTW2_INCLUDE_DIR})
748 set(FFT_LIBRARIES ${FFTW2_LIBRARIES})
749 set(PKG_FFT_LIBS ${FFTW2_LIBRARIES})
751 if("${FFTW2_LIBRARIES}" MATCHES "dfftw")
752 set(FFTW2_NAME_DFFTW 1)
753 elseif("${FFTW2_LIBRARIES}" MATCHES "sfftw")
754 set(FFTW2_NAME_SFFTW 1)
755 else("${FFTW2_LIBRARIES}" MATCHES "dfftw")
756 set(FFTW2_NAME_FFTW 1)
757 endif("${FFTW2_LIBRARIES}" MATCHES "dfftw")
760 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
761 # MESSAGE(STATUS "Using external FFT library - Intel MKL")
762 find_package(MKL REQUIRED)
763 include_directories(${MKL_INCLUDE_DIR})
764 set(FFT_LIBRARIES ${MKL_LIBRARIES})
765 set(PKG_FFT_LIBS ${MKL_LIBRARIES})
770 #elseif(${GMX_FFT_LIBRARY} STREQUAL "ACML")
771 # MESSAGE(STATUS "Using external FFT library - AMD core math library")
772 # set(GMX_FFT_ACML 1)
773 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
774 MESSAGE(STATUS "Using internal FFT library - fftpack")
775 set(GMX_FFT_FFTPACK 1)
776 else(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
777 MESSAGE(FATAL_ERROR "Invalid FFT library setting: ${GMX_FFT_LIBRARY}. Choose one of: fftw3, fftw2, mkl, acml, fftpack")
778 endif(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
780 # MKL has BLAS/LAPACK routines
781 if(HAVE_MKL OR ACCELERATE_FRAMEWORK)
782 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use external BLAS instead of built-in")
783 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use external LAPACK instead of built-in")
784 else(HAVE_MKL OR ACCELERATE_FRAMEWORK)
785 set(GMX_EXTERNAL_BLAS FALSE CACHE BOOL "Use external BLAS instead of built-in")
786 set(GMX_EXTERNAL_LAPACK FALSE CACHE BOOL "Use external LAPACK instead of built-in")
787 if(GMX_EXTERNAL_BLAS)
788 #FindBLAS needs Fortran
789 enable_language(Fortran)
791 list(APPEND GMX_EXTRA_LIBRARIES ${GMX_BLAS_USER})
793 find_package(BLAS REQUIRED)
794 list(APPEND GMX_EXTRA_LIBRARIES ${BLAS_LIBRARIES})
796 endif(GMX_EXTERNAL_BLAS)
797 if(GMX_EXTERNAL_LAPACK)
798 #FindLAPACK needs Fortran
799 enable_language(Fortran)
801 list(APPEND GMX_EXTRA_LIBRARIES ${GMX_LAPACK_USER})
802 else(GMX_LAPACK_USER)
803 find_package(LAPACK REQUIRED)
804 list(APPEND GMX_EXTRA_LIBRARIES ${LAPACK_LIBRARIES})
805 endif(GMX_LAPACK_USER)
806 endif(GMX_EXTERNAL_LAPACK)
807 endif(HAVE_MKL OR ACCELERATE_FRAMEWORK)
808 mark_as_advanced(GMX_EXTERNAL_LAPACK)
809 mark_as_advanced(GMX_EXTERNAL_BLAS)
811 # Math and thread libraries must often come after all others when linking...
813 list(APPEND GMX_EXTRA_LIBRARIES m)
817 set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
818 "Path to swindirect.h")
819 include_directories(${COREWRAP_INCLUDE_DIR})
822 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
823 # these are set after everything else
824 if (NOT DEFINED GROMACS_C_FLAGS_SET)
825 set(GROMACS_C_FLAGS_SET true CACHE INTERNAL "Whether to reset the C flags"
827 set(CMAKE_C_FLAGS "${GROMACS_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
828 "Flags used by the compiler during all build types" FORCE)
829 set(CMAKE_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING
830 "Flags used by the compiler during all build types" FORCE)
831 set(CMAKE_EXE_LINKER_FLAGS
832 "${GROMACS_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
833 CACHE STRING "Linker flags" FORCE)
834 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
836 ########################################################################
837 # Specify install locations and which subdirectories to process #
838 ########################################################################
839 if ( DEFINED GMXLIB )
840 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${GMXLIB}")
842 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
844 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
845 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/gromacs)
846 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
847 set(INCL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
849 set(GMXLIBDIR ${DATA_INSTALL_DIR}/top)
851 ##################################################################
852 # Shared library settings - Darwin uses INSTALL_NAME_DIR instead!
853 ##################################################################
854 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
855 set(CMAKE_SKIP_BUILD_RPATH FALSE)
856 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
857 set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
858 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
861 add_subdirectory(share)
862 add_subdirectory(include)
863 add_subdirectory(man)
864 add_subdirectory(src)
865 add_subdirectory(scripts)
867 #######################
869 #######################
871 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
872 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
874 ###########################
875 ADD_CUSTOM_TARGET(uninstall
876 "${CMAKE_COMMAND}" -P
877 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
878 ###########################
881 ########################################################################
883 ########################################################################
886 mark_as_advanced(BUILD_TESTING)
889 add_subdirectory(tests)