1 cmake_minimum_required(VERSION 2.8)
5 mark_as_advanced(DART_ROOT)
7 # PROJECT_VERSION should have the following structure:
8 # VERSION-dev[-SUFFIX] where the VERSION should have the for: vMajor.vMinor.vPatch
10 # The "-dev" suffix is important to keep because it makes possible to distinguish
11 # between a build from official release and a build from git release branch on a
12 # machine with no git.
14 # NOTE: when releasing the "-dev" suffix needs to be stripped off!
15 set(PROJECT_VERSION "4.6-dev")
16 set(CUSTOM_VERSION_STRING ""
17 CACHE STRING "Custom version string (if empty, use hard-coded default)")
18 mark_as_advanced(CUSTOM_VERSION_STRING)
19 if (CUSTOM_VERSION_STRING)
20 set(PROJECT_VERSION ${CUSTOM_VERSION_STRING})
21 endif (CUSTOM_VERSION_STRING)
23 # It is a bit irritating, but this has to be set separately for now!
24 SET(CPACK_PACKAGE_VERSION_MAJOR "4")
25 SET(CPACK_PACKAGE_VERSION_MINOR "6")
26 #SET(CPACK_PACKAGE_VERSION_PATCH "0")
29 # Cmake modules/macros are in a subdirectory to keep this file cleaner
30 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
32 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
33 set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE)
36 if(NOT CMAKE_BUILD_TYPE)
37 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
38 endif(NOT CMAKE_BUILD_TYPE)
42 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
43 set(CPACK_PACKAGE_VENDOR "gromacs.org")
44 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation")
45 set(CPACK_SET_DESTDIR "ON")
46 set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
47 set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt")
48 # Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this...
49 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/admin/InstallLicense.txt")
50 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
52 #must come after all cpack settings!
55 ########################################################################
56 # Check and warn if cache generated on a different host is being reused
57 ########################################################################
59 execute_process(COMMAND hostname
60 OUTPUT_VARIABLE TMP_HOSTNAME
61 OUTPUT_STRIP_TRAILING_WHITESPACE)
62 if(GMX_BUILD_HOSTNAME AND NOT "${GMX_BUILD_HOSTNAME}" STREQUAL "${TMP_HOSTNAME}")
64 The CMake cache, probably generated on a different host (${GMX_BUILD_HOSTNAME}),
65 is being reused! This could lead to inconsitencies; therefore, it is
66 recommended to regenerate the cache!")
68 set(GMX_BUILD_HOSTNAME "${TMP_HOSTNAME}" CACHE INTERNAL
69 "Hostname of the machine where the cache was generated.")
72 ########################################################################
73 # Fix stupid flags on MSVC
74 ########################################################################
75 SET(SHARED_LIBS_DEFAULT ON)
76 IF(CMAKE_GENERATOR MATCHES "Visual Studio")
77 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
78 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
79 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
80 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
81 SET(SHARED_LIBS_DEFAULT OFF)
82 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
84 set(GMX_EXTRA_LIBRARIES)
88 ######################################################################
90 # these need ot be done early (before further tests).
91 #####################################################################
93 include(CheckCCompilerFlag)
94 include(CheckCXXCompilerFlag)
99 ########################################################################
100 # User input options #
101 ########################################################################
102 option(GMX_DOUBLE "Use double precision (much slower, use only if you really need it)" OFF)
103 option(GMX_MPI "Build a parallel (message-passing) version of GROMACS" OFF)
104 option(GMX_THREADS "Build a parallel (thread-based) version of GROMACS (cannot be combined with MPI yet)" ON)
105 option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
106 mark_as_advanced(GMX_SOFTWARE_INVSQRT)
107 option(GMX_POWERPC_INVSQRT "Use PowerPC hardware 1/sqrt" OFF)
108 mark_as_advanced(GMX_POWERPC_INVSQRT)
109 option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
110 mark_as_advanced(GMX_FAHCORE)
111 option(GMX_OPENMM "Accelerated execution on GPUs through the OpenMM library (rerun cmake after changing to see relevant options)" OFF)
112 set(GMX_ACCELERATION "auto"
113 CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran")
115 set(GMX_FFT_LIBRARY "fftw3"
116 CACHE STRING "FFT library choices: fftw3,fftw2,mkl,fftpack[built-in]")
117 option(GMX_DISABLE_FFTW_MEASURE
118 "Do not optimize FFTW setups (not needed with SSE)" OFF)
119 mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
120 set(GMX_QMMM_PROGRAM "none"
121 CACHE STRING "QM package choices: none,gaussian,mopac,gamess,orca")
122 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
123 mark_as_advanced(GMX_BROKEN_CALLOC)
124 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic with MPI, Windows)" ${SHARED_LIBS_DEFAULT})
125 option(GMX_MPI_IN_PLACE "Enable MPI_IN_PLACE for MPIs that have it defined" ON)
126 mark_as_advanced(GMX_MPI_IN_PLACE)
127 option(GMX_LOAD_PLUGINS "Compile with plugin support, needed to read VMD supported file formats" ON)
128 mark_as_advanced(GMX_LOAD_PLUGINS)
131 option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
132 mark_as_advanced(GMX_IA32_ASM)
133 option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
134 mark_as_advanced(GMX_X86_64_ASM)
136 option(USE_VERSION_H "Generate development version string/information" ON)
137 mark_as_advanced(USE_VERSION_H)
139 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)
141 if(UNIX AND NOT APPLE)
142 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)
143 mark_as_advanced(GMX_PREFER_STATIC_LIBS)
146 ########################################################################
147 # Set up binary and library suffixing
148 ########################################################################
149 set(GMX_BINARY_SUFFIX "" CACHE STRING "Suffix for GROMACS binaries (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
150 set(GMX_LIBS_SUFFIX ""
151 CACHE STRING "Suffix for GROMACS libs (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
152 if (GMX_DEFAULT_SUFFIX)
153 set(GMX_BINARY_SUFFIX "")
154 set(GMX_LIBS_SUFFIX "")
156 set(GMX_BINARY_SUFFIX "_mpi")
157 set(GMX_LIBS_SUFFIX "_mpi")
160 set (GMX_BINARY_SUFFIX "${GMX_BINARY_SUFFIX}_d")
161 set (GMX_LIBS_SUFFIX "${GMX_LIBS_SUFFIX}_d")
164 set (GMX_BINARY_SUFFIX "-gpu")
165 set (GMX_LIBS_SUFFIX "_gpu")
167 mark_as_advanced(FORCE GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
168 if (NOT SUFFIX_QUIETLY)
169 message(STATUS "Using default binary suffix: \"${GMX_BINARY_SUFFIX}\"")
170 message(STATUS "Using default library suffix: \"${GMX_LIBS_SUFFIX}\"")
171 endif (NOT SUFFIX_QUIETLY)
172 else(GMX_DEFAULT_SUFFIX)
173 mark_as_advanced(CLEAR GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
174 if (NOT SUFFIX_QUIETLY)
175 message(STATUS "Using manually set binary suffix: \"${GMX_BINARY_SUFFIX}\"")
176 message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"")
177 endif (NOT SUFFIX_QUIETLY)
178 endif(GMX_DEFAULT_SUFFIX)
179 set(SUFFIX_QUIETLY TRUE CACHE INTERNAL "")
183 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE")
185 if(GMX_SOFTWARE_INVSQRT)
186 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT")
187 endif(GMX_SOFTWARE_INVSQRT)
188 if(GMX_POWERPC_INVSQRT)
189 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_POWERPC_INVSQRT")
190 endif(GMX_POWERPC_INVSQRT)
192 ########################################################################
193 #Process MPI settings
194 ########################################################################
195 include(gmxManageMPI)
197 #######################################################################
198 # Check for options incompatible with OpenMM build #
199 #######################################################################
201 cmake_minimum_required(VERSION 2.6.4)
202 # we'll use the built-in fft to avoid unnecessary dependencies
203 string(TOUPPER ${GMX_FFT_LIBRARY} GMX_FFT_LIBRARY)
204 if(NOT ${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
205 message(STATUS "No external FFT libraries needed for the OpenMM build, switching to fftpack!")
206 set(GMX_FFT_LIBRARY "fftpack" CACHE STRING
207 "No external FFT libraries needed for the OpenMM build, switching to fftpack!" FORCE)
210 message(FATAL_ERROR "The OpenMM build is not compatible with MPI!")
213 message(STATUS "Threads are not compatible with OpenMM build, disabled!")
214 set(GMX_THREADS OFF CACHE BOOL
215 "Threads are not compatible with OpenMM build, disabled!" FORCE)
217 if(GMX_SOFTWARE_INVSQRT)
218 set(GMX_SOFTWARE_INVSQRT OFF CACHE STRING
219 "The OpenMM build does not need GROMACS software 1/sqrt!" FORCE)
220 endif(GMX_SOFTWARE_INVSQRT)
221 string(TOUPPER ${GMX_ACCELERATION} GMX_ACCELERATION)
222 if(NOT GMX_ACCELERATION STREQUAL "NONE")
223 message(STATUS "Switching off CPU-based acceleration, the OpenMM build does not support/need any!")
224 set(GMX_ACCELERATION "none" CACHE STRING
225 "Switching off CPU-based acceleration, the OpenMM build does not support/need any!" FORCE)
228 message(FATAL_ERROR "The OpenMM build does not support FAH build!")
231 message(FATAL_ERROR "The OpenMM-build does not support double precision calculations!")
233 # mark as advanced the unused variables
234 mark_as_advanced(FORCE GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
235 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
237 mark_as_advanced(CLEAR GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
238 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
242 ########################################################################
243 # Basic system tests (standard libraries, headers, functions, types) #
244 ########################################################################
245 include(CheckIncludeFiles)
246 check_include_files(string.h HAVE_STRING_H)
247 check_include_files(math.h HAVE_MATH_H)
248 check_include_files(limits.h HAVE_LIMITS_H)
249 check_include_files(memory.h HAVE_MEMORY_H)
250 check_include_files(unistd.h HAVE_UNISTD_H)
251 check_include_files(direct.h HAVE_DIRECT_H)
252 check_include_files(pwd.h HAVE_PWD_H)
253 check_include_files(stdint.h HAVE_STDINT_H)
254 check_include_files(stdlib.h HAVE_STDLIB_H)
255 check_include_files(pthread.h HAVE_PTHREAD_H)
256 check_include_files(dirent.h HAVE_DIRENT_H)
257 check_include_files(inttypes.h HAVE_INTTYPES_H)
258 check_include_files(regex.h HAVE_REGEX_H)
259 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
260 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
261 check_include_files(sys/time.h HAVE_SYS_TIME_H)
262 check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
263 check_include_files("rpc/rpc.h;rpc/xdr.h" HAVE_RPC_XDR_H)
265 check_include_files(xmmintrin.h HAVE_XMMINTRIN_H)
266 check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
267 check_include_files(pmmintrin.h HAVE_PMMINTRIN_H)
268 check_include_files(smmintrin.h HAVE_SMMINTRIN_H)
269 check_include_files(io.h HAVE_IO_H)
272 include(CheckFunctionExists)
273 check_function_exists(strcasecmp HAVE_STRCASECMP)
274 check_function_exists(strdup HAVE_STRDUP)
275 check_function_exists(vprintf HAVE_VPRINTF)
276 check_function_exists(memcmp HAVE_MEMCMP)
277 check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
278 check_function_exists(memalign HAVE_MEMALIGN)
279 check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
280 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
281 check_function_exists(isnan HAVE_ISNAN)
282 check_function_exists(_isnan HAVE__ISNAN)
283 check_function_exists(isfinite HAVE_ISFINITE)
284 check_function_exists(_isfinite HAVE__ISFINITE)
285 check_function_exists(fsync HAVE_FSYNC)
286 check_function_exists(_fileno HAVE__FILENO)
287 check_function_exists(fileno HAVE_FILENO)
288 check_function_exists(_commit HAVE__COMMIT)
290 include(CheckLibraryExists)
291 check_library_exists(m sqrt "" HAVE_LIBM)
292 check_library_exists(m cbrt "" HAVE_CBRT)
295 include(CheckTypeSize)
297 check_type_size("bool" SIZEOF_BOOL) # will also set HAVE_BOOL
298 check_type_size("int" SIZEOF_INT)
299 check_type_size("long int" SIZEOF_LONG_INT)
300 check_type_size("long long int" SIZEOF_LONG_LONG_INT)
301 check_type_size("off_t" SIZEOF_OFF_T)
302 check_type_size("void *" SIZEOF_VOIDP)
304 if (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
306 else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
307 set(GMX_64_BIT FALSE)
308 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
310 # Check for some basic types that we *need*, so set these to int if they are not present
311 check_type_size(uid_t uid_t)
318 check_type_size(gid_t gid_t)
325 check_type_size(size_t size_t)
332 check_type_size(off_t off_t)
339 include(TestBigEndian)
340 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
345 ########################################################################
346 # Find external packages #
347 ########################################################################
348 if(UNIX AND NOT APPLE)
349 if(GMX_PREFER_STATIC_LIBS)
350 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
351 if(BUILD_SHARED_LIBS)
352 message(WARNING "Static libraries requested, the GROMACS libraries will also be build static (BUILD_SHARED_LIBS=OFF)")
353 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Enable shared libraries (can be problematic with MPI, Windows)" FORCE)
358 option(GMX_XML "Use libxml2 to parse xml files" ON)
360 find_package(LibXml2)
363 include_directories(${LIBXML2_INCLUDE_DIR})
364 set(PKG_XML libxml-2.0)
365 set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
370 option(GMX_GSL "Add support for gsl" OFF)
375 include_directories(${GSL_INCLUDE_DIR})
381 option(GMX_X11 "Use X window system" OFF)
384 # X11 includes/libraries are only set in the ngmx subdirectory!
391 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREADS")
393 set(THREAD_MPI_LIB thread_mpi)
395 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
396 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
397 message(FATAL_ERROR "FFTW2 can't be used with threads. Try fftw3 or mkl.")
402 set(CUDA_BUILD_EMULATION OFF)
403 find_package(CUDA 3.1 REQUIRED)
404 add_definitions(-DGMX_OPENMM)
405 if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
406 set(CUDA_VERBOSE_BUILD ON)
412 find_library(ACCELERATE_FRAMEWORK Accelerate)
413 list(APPEND GMX_EXTRA_LIBRARIES ${ACCELERATE_FRAMEWORK})
420 # only bother with finding git and using version.h if the source is a git repo
421 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
423 # We need at least git v1.5.1 be able to parse git's date output. If not
424 # found or the version is too small, we can't generate version information.
427 # Find out the git version
428 if(GIT_FOUND AND NOT GIT_VERSION)
429 execute_process(COMMAND ${GIT_EXECUTABLE} "--version"
430 OUTPUT_VARIABLE _exec_out
431 OUTPUT_STRIP_TRAILING_WHITESPACE)
432 string(REGEX REPLACE "git version (.*)" "\\1" GIT_VERSION ${_exec_out})
433 set(GIT_VERSION ${GIT_VERSION} CACHE STRING "Git version")
434 mark_as_advanced(GIT_VERSION)
437 if(NOT GIT_FOUND OR GIT_VERSION VERSION_LESS "1.5.1")
438 message("No compatible git version found, won't be able to generate proper development version information.")
439 set(USE_VERSION_H OFF)
443 set(USE_VERSION_H OFF)
446 ########################################################################
447 # Generate development version info for cache
448 ########################################################################
449 # set(GEN_VERSION_INFO_INTERNAL "ON")
450 # include(gmxGenerateVersionString)
452 ########################################################################
453 # Our own GROMACS tests
454 ########################################################################
456 add_definitions( -DHAVE_CONFIG_H )
457 include_directories(${CMAKE_BINARY_DIR}/src)
458 include_directories(${CMAKE_SOURCE_DIR}/include)
460 include(gmxCheckBuildUserTime)
461 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
463 include(gmxTestFloatFormat)
464 gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
465 GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
466 GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
468 include(gmxTestLargeFiles)
469 gmx_test_large_files(GMX_LARGEFILES)
470 check_function_exists(fseeko HAVE_FSEEKO)
472 include(gmxTestSignal)
473 gmx_test_sigusr1(HAVE_SIGUSR1)
475 include(gmxTestInline)
476 gmx_test_inline(INLINE_KEYWORD)
478 include(gmxTestRestrict)
479 gmx_test_inline(RESTRICT_KEYWORD)
481 include(gmxTestPipes)
482 gmx_test_pipes(HAVE_PIPES)
484 include(gmxTestInlineASM)
485 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
486 gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
488 # turn on SSE if supported with reasonable defaults.
489 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
490 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x64|x86_64|AMD64|amd64)" OR CYGWIN)
492 set(GMX_ACCELERATION "SSE" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
494 # Determine the assembler/compiler to use
496 set(GMX_ACCELERATION "none" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
498 endif (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
501 gmx_test_xdr(GMX_SYSTEM_XDR)
502 if(NOT GMX_SYSTEM_XDR)
503 set(GMX_INTERNAL_XDR 1)
504 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
505 endif(NOT GMX_SYSTEM_XDR)
507 # Process nonbonded accelerated kernels settings
508 string(TOUPPER ${GMX_ACCELERATION} ${GMX_ACCELERATION})
509 if(${GMX_ACCELERATION} STREQUAL "NONE")
511 elseif(${GMX_ACCELERATION} STREQUAL "SSE")
514 set(GMX_X86_64_ASM ON CACHE BOOL "Add SSE assembly files for x86_64" FORCE)
516 set(GMX_IA32_ASM ON CACHE BOOL "Add SSE assembly files for i386" FORCE)
519 if(CMAKE_GENERATOR MATCHES "Visual Studio")
520 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" ON)
522 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" OFF)
524 mark_as_advanced(GMX_ASM_USEASM-NASM)
527 # for 32-bit compiles, we might need to turn on sse
528 CHECK_C_COMPILER_FLAG("-msse2" XFLAGS_SSE)
530 set(GROMACS_C_FLAGS "-msse2 ${GROMACS_C_FLAGS}")
532 CHECK_CXX_COMPILER_FLAG("-msse2" XXFLAGS_SSE)
534 set(GROMACS_CXX_FLAGS "-msse2 ${GROMACS_CXX_FLAGS}")
536 endif (NOT GMX_64_BIT)
544 elseif(GMX_X86_64_ASM)
546 set(GMX_X86_64_SSE2 1)
548 set(GMX_X86_64_SSE 1)
552 # if(HAVE_PMMINTRIN_H)
554 # endif(HAVE_PMMINTRIN_H)
555 # if(HAVE_SMMINTRIN_H)
557 # endif(HAVE_SMMINTRIN_H)
559 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
561 #these are switch on by default sometimes
563 set(GMX_GMX_X86_64_ASM 0)
564 elseif(${GMX_ACCELERATION} STREQUAL "BLUEGENE")
565 # GMX_ACCELERATION=BlueGene should be set in the Toolchain-BlueGene?-???.cmake file
566 message(STATUS "Configuring for BlueGene")
568 if (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
569 set(SHARED_LIBS_DEFAULT OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
570 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
571 endif (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
572 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene" FORCE)
573 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on BlueGene" FORCE)
574 set(GMX_X11 OFF CACHE BOOL "X11 not compatible with BlueGene, disabled!" FORCE)
575 set(GMX_THREADS OFF CACHE BOOL "Threads not compatible with BlueGene, disabled!" FORCE)
576 set(GMX_MPI ON CACHE BOOL "Use MPI on BlueGene" FORCE)
577 elseif(${GMX_ACCELERATION} STREQUAL "POWER6")
579 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on Power6" FORCE)
580 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on Power6" FORCE)
581 elseif(${GMX_ACCELERATION} STREQUAL "IA64")
583 set(DISABLE_WATERWATER_NLIST 1)
584 set(DISABLE_WATER_NLIST 1)
585 elseif(${GMX_ACCELERATION} STREQUAL "ALTIVEC")
586 check_include_files(altivec.h HAVE_ALTIVEC_H)
588 set(GMX_PPC_ALTIVEC 1)
589 endif(HAVE_ALTIVEC_H)
590 else(${GMX_ACCELERATION} STREQUAL "NONE")
591 MESSAGE(FATAL_ERROR "Unrecognized option for accelerated kernels: ${GMX_ACCELERATION}. Pick one of auto, none, SSE, Fortran, BlueGene, Power6, ia64, altivec")
592 endif(${GMX_ACCELERATION} STREQUAL "NONE")
594 if(GMX_FORTRAN OR GMX_POWER6)
596 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).")
598 enable_language(Fortran)
599 include(FortranCInterface)
600 discover_fortran_mangling(prefix isupper suffix extra_under_score found)
601 if(extra_under_score)
603 endif(extra_under_score)
605 set(prefix "${prefix} ##")
608 set(suffix "## ${suffix}")
610 set(extrasuffix "${suffix}${extrasuffix}")
614 # Don't know if this is needed, but it can't hurt
615 set(extrasuffix "## ${extrasuffix}")
620 set(F77_FUNCDEF "${prefix} NAME ${suffix}")
621 set(F77_FUNCDEF_ "${prefix} NAME ${extrasuffix}")
623 set(F77_FUNCDEF "${prefix} name ${suffix}")
624 set(F77_FUNCDEF_ "${prefix} name ${extrasuffix}")
626 else(GMX_FORTRAN OR GMX_POWER6)
627 set(F77_FUNCDEF "name ## _")
628 set(F77_FUNCDEF_ "name ## _")
629 endif(GMX_FORTRAN OR GMX_POWER6)
631 # Process QM/MM Settings
632 string(TOUPPER ${GMX_QMMM_PROGRAM} ${GMX_QMMM_PROGRAM})
633 if(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
634 set(GMX_QMMM_GAUSSIAN 1)
635 elseif(${GMX_QMMM_PROGRAM} STREQUAL "MOPAC")
636 set(GMX_QMMM_MOPAC 1)
637 elseif(${GMX_QMMM_PROGRAM} STREQUAL "GAMESS")
638 set(GMX_QMMM_GAMESS 1)
639 elseif(${GMX_QMMM_PROGRAM} STREQUAL "ORCA")
641 elseif(${GMX_QMMM_PROGRAM} STREQUAL "NONE")
643 else(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
644 MESSAGE(FATAL_ERROR "Invalid QM/MM program option: ${GMX_QMMM_PROGRAM}. Choose one of: Gaussian, Mopac, Gamess, Orca, None")
645 endif(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
647 # Process FFT library settings - if not OpenMM build
648 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
651 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
652 # MESSAGE(STATUS "Using external FFT library - fftw3")
654 find_package(FFTW3 REQUIRED)
655 include_directories(${FFTW3_INCLUDE_DIR})
656 set(FFT_LIBRARIES ${FFTW3_LIBRARIES})
659 find_package(FFTW3F REQUIRED)
660 include_directories(${FFTW3F_INCLUDE_DIR})
661 set(FFT_LIBRARIES ${FFTW3F_LIBRARIES})
662 set(PKG_FFT "fftw3f")
665 if(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
666 MESSAGE(FATAL_ERROR "Cannot find fftw3 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
667 endif(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
671 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
672 # MESSAGE(STATUS "Using external FFT library - fftw2")
674 find_package(FFTW2 REQUIRED)
676 find_package(FFTW2F REQUIRED)
680 MESSAGE(FATAL_ERROR "Cannot find fftw2 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
681 endif(NOT FFTW2_FOUND)
682 include_directories(${FFTW2_INCLUDE_DIR})
683 set(FFT_LIBRARIES ${FFTW2_LIBRARIES})
684 set(PKG_FFT_LIBS ${FFTW2_LIBRARIES})
686 if("${FFTW2_LIBRARIES}" MATCHES "dfftw")
687 set(FFTW2_NAME_DFFTW 1)
688 elseif("${FFTW2_LIBRARIES}" MATCHES "sfftw")
689 set(FFTW2_NAME_SFFTW 1)
690 else("${FFTW2_LIBRARIES}" MATCHES "dfftw")
691 set(FFTW2_NAME_FFTW 1)
692 endif("${FFTW2_LIBRARIES}" MATCHES "dfftw")
695 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
696 # MESSAGE(STATUS "Using external FFT library - Intel MKL")
697 find_package(MKL REQUIRED)
698 include_directories(${MKL_INCLUDE_DIR})
699 set(FFT_LIBRARIES ${MKL_LIBRARIES})
700 set(PKG_FFT_LIBS ${MKL_LIBRARIES})
705 #elseif(${GMX_FFT_LIBRARY} STREQUAL "ACML")
706 # MESSAGE(STATUS "Using external FFT library - AMD core math library")
707 # set(GMX_FFT_ACML 1)
708 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
709 MESSAGE(STATUS "Using internal FFT library - fftpack")
710 set(GMX_FFT_FFTPACK 1)
711 else(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
712 MESSAGE(FATAL_ERROR "Invalid FFT library setting: ${GMX_FFT_LIBRARY}. Choose one of: fftw3, fftw2, mkl, acml, fftpack")
713 endif(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
715 # MKL has BLAS/LAPACK routines
716 if(HAVE_MKL OR ACCELERATE_FRAMEWORK)
717 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use external BLAS instead of built-in")
718 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use external LAPACK instead of built-in")
719 else(HAVE_MKL OR ACCELERATE_FRAMEWORK)
720 set(GMX_EXTERNAL_BLAS FALSE CACHE BOOL "Use external BLAS instead of built-in")
721 set(GMX_EXTERNAL_LAPACK FALSE CACHE BOOL "Use external LAPACK instead of built-in")
722 if(GMX_EXTERNAL_BLAS)
723 #FindBLAS needs Fortran
724 enable_language(Fortran)
726 list(APPEND GMX_EXTRA_LIBRARIES ${GMX_BLAS_USER})
728 find_package(BLAS REQUIRED)
729 list(APPEND GMX_EXTRA_LIBRARIES ${BLAS_LIBRARIES})
731 endif(GMX_EXTERNAL_BLAS)
732 if(GMX_EXTERNAL_LAPACK)
733 #FindLAPACK needs Fortran
734 enable_language(Fortran)
736 list(APPEND GMX_EXTRA_LIBRARIES ${GMX_LAPACK_USER})
737 else(GMX_LAPACK_USER)
738 find_package(LAPACK REQUIRED)
739 list(APPEND GMX_EXTRA_LIBRARIES ${LAPACK_LIBRARIES})
740 endif(GMX_LAPACK_USER)
741 endif(GMX_EXTERNAL_LAPACK)
742 endif(HAVE_MKL OR ACCELERATE_FRAMEWORK)
743 mark_as_advanced(GMX_EXTERNAL_LAPACK)
744 mark_as_advanced(GMX_EXTERNAL_BLAS)
746 set(GMX_USE_PLUGINS OFF CACHE INTERNAL "Whether GROMACS will really try to compile support for VMD plugins")
747 set(GMX_VMD_PLUGIN_PATH)
748 mark_as_advanced(GMX_VMD_PLUGIN_PATH)
751 if(CYGWIN OR NOT WIN32)
752 # Native Windows does not have, nor need dlopen
753 # Note that WIN32 is set with Cygwin, but Cygwin needs dlopen to use plug-ins
754 include(gmxTestdlopen)
755 gmx_test_dlopen(HAVE_DLOPEN)
760 # Test for unsuitable versions of VMD
762 if(VMD_FOUND AND NOT GMX_VMD_PLUGIN_PATH)
763 message(STATUS "Checking for suitable VMD version")
764 exec_program(${VMD_EXECUTABLE}
766 OUTPUT_VARIABLE VMD_HELP
767 RETURN_VALUE VMD_EXEC_RETURN)
769 if(VMD_EXEC_RETURN EQUAL 0)
770 # This is the accepted idiom for subexpression matching, unfortunately
771 string(REGEX REPLACE ".*VMD for .*, version ([0-9]+\\.[0-9]*\\.?[0-9]*).*" "\\1" VMD_VERSION ${VMD_HELP})
772 string(REGEX REPLACE ".*VMD for (.*), version .*" "\\1" VMD_ARCH ${VMD_HELP})
774 if(VMD_VERSION VERSION_LESS "1.8")
775 MESSAGE(WARNING "Found VMD version ${VMD_VERSION}, but GROMACS needs at least 1.8")
776 unset(VMD_EXECUTABLE)
779 message(STATUS "VMD version ${VMD_VERSION} is suitable")
780 if(DEFINED ENV{VMDDIR})
781 # This permits GROMACS to avoid hard-coding a fall-back
782 # path that it can tell right now would be useless.
783 set(GMX_VMD_PLUGIN_PATH "$ENV{VMDDIR}/plugins/${VMD_ARCH}/molfile" CACHE PATH "Path to VMD plugins for molfile I/O")
785 set(GMX_VMD_PLUGIN_PATH "/usr/local/lib/vmd/plugins/*/molfile" CACHE PATH "Path to VMD plugins for molfile I/O")
796 # so, should we use plug-ins?
797 if((WIN32 AND NOT CYGWIN) OR (HAVE_DLOPEN AND BUILD_SHARED_LIBS))
799 MESSAGE(STATUS "Found the ability to use plug-ins when building shared libaries, so will compile to use plug-ins (e.g. to read VMD-supported file formats).")
800 endif(NOT VMD_QUIETLY)
801 set(GMX_USE_PLUGINS ON)
802 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) # magic cross-platform pre-set variable for dlopen library
803 set(PKG_DL_LIBS "-l${CMAKE_DL_LIBS}")
807 endif(GMX_LOAD_PLUGINS)
808 set(VMD_QUIETLY TRUE CACHE INTERNAL "")
810 # Math and thread libraries must often come after all others when linking...
812 list(APPEND GMX_EXTRA_LIBRARIES m)
816 set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
817 "Path to swindirect.h")
818 include_directories(${COREWRAP_INCLUDE_DIR})
821 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
822 # these are set after everything else
823 if (NOT DEFINED GROMACS_C_FLAGS_SET)
824 set(GROMACS_C_FLAGS_SET true CACHE INTERNAL "Whether to reset the C flags"
826 set(CMAKE_C_FLAGS "${GROMACS_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
827 "Flags used by the compiler during all build types" FORCE)
828 set(CMAKE_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING
829 "Flags used by the compiler during all build types" FORCE)
830 set(CMAKE_EXE_LINKER_FLAGS
831 "${GROMACS_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
832 CACHE STRING "Linker flags" FORCE)
833 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
835 ########################################################################
836 # Specify install locations and which subdirectories to process #
837 ########################################################################
838 if ( DEFINED GMXLIB )
839 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${GMXLIB}")
841 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
843 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
844 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/gromacs)
845 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
846 set(INCL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
848 set(GMXLIBDIR ${DATA_INSTALL_DIR}/top)
850 ##################################################################
851 # Shared library settings - Darwin uses INSTALL_NAME_DIR instead!
852 ##################################################################
853 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
854 set(CMAKE_SKIP_BUILD_RPATH FALSE)
855 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
856 set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
857 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
860 add_subdirectory(share)
861 add_subdirectory(include)
862 add_subdirectory(man)
863 add_subdirectory(src)
864 add_subdirectory(scripts)
866 #######################
868 #######################
870 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
871 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
873 ###########################
874 ADD_CUSTOM_TARGET(uninstall
875 "${CMAKE_COMMAND}" -P
876 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
877 ###########################
880 ########################################################################
882 ########################################################################
885 mark_as_advanced(BUILD_TESTING)
888 add_subdirectory(tests)