1 cmake_minimum_required(VERSION 2.6)
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.5.3-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 "5")
26 SET(CPACK_PACKAGE_VERSION_PATCH "3")
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!
56 ########################################################################
57 # Fix stupid flags on MSVC
58 ########################################################################
59 SET(SHARED_LIBS_DEFAULT ON)
60 IF(CMAKE_GENERATOR MATCHES "Visual Studio")
61 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
62 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
63 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
64 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
65 SET(SHARED_LIBS_DEFAULT OFF)
66 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
68 set(GMX_EXTRA_LIBRARIES)
72 ######################################################################
74 # these need ot be done early (before further tests).
75 #####################################################################
77 include(CheckCCompilerFlag)
78 include(CheckCXXCompilerFlag)
83 ########################################################################
84 # User input options #
85 ########################################################################
86 option(GMX_DOUBLE "Use double precision (much slower, use only if you really need it)" OFF)
87 option(GMX_MPI "Build a parallel (message-passing) version of GROMACS" OFF)
88 option(GMX_THREADS "Build a parallel (thread-based) version of GROMACS (cannot be combined with MPI yet)" ON)
89 option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
90 mark_as_advanced(GMX_SOFTWARE_INVSQRT)
91 option(GMX_POWERPC_INVSQRT "Use PowerPC hardware 1/sqrt" OFF)
92 mark_as_advanced(GMX_POWERPC_INVSQRT)
93 option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
94 mark_as_advanced(GMX_FAHCORE)
95 option(GMX_OPENMM "Accelerated execution on GPUs through the OpenMM library (rerun cmake after changing to see relevant options)" OFF)
96 set(GMX_ACCELERATION "auto"
97 CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran")
99 set(GMX_FFT_LIBRARY "fftw3"
100 CACHE STRING "FFT library choices: fftw3,fftw2,mkl,fftpack[built-in]")
101 option(GMX_DISABLE_FFTW_MEASURE
102 "Do not optimize FFTW setups (not needed with SSE)" OFF)
103 mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
104 set(GMX_QMMM_PROGRAM "none"
105 CACHE STRING "QM package choices: none,gaussian,mopac,gamess,orca")
106 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
107 mark_as_advanced(GMX_BROKEN_CALLOC)
108 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic with MPI, Windows)" ${SHARED_LIBS_DEFAULT})
109 option(GMX_MPI_IN_PLACE "Enable MPI_IN_PLACE for MPIs that have it defined" ON)
110 mark_as_advanced(GMX_MPI_IN_PLACE)
111 option(GMX_DLOPEN "Compile with dlopen, needed to read VMD supported file formats" ON)
112 mark_as_advanced(GMX_DLOPEN)
115 option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
116 mark_as_advanced(GMX_IA32_ASM)
117 option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
118 mark_as_advanced(GMX_X86_64_ASM)
120 option(USE_VERSION_H "Generate development version string/information" ON)
121 mark_as_advanced(USE_VERSION_H)
123 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)
125 if(UNIX AND NOT APPLE)
126 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)
127 mark_as_advanced(GMX_PREFER_STATIC_LIBS)
130 ########################################################################
131 # Set up binary and library suffixing
132 ########################################################################
133 set(GMX_BINARY_SUFFIX "" CACHE STRING "Suffix for GROMACS binaries (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
134 set(GMX_LIBS_SUFFIX ""
135 CACHE STRING "Suffix for GROMACS libs (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
136 if (GMX_DEFAULT_SUFFIX)
137 set(GMX_BINARY_SUFFIX "")
138 set(GMX_LIBS_SUFFIX "")
140 set(GMX_BINARY_SUFFIX "_mpi")
141 set(GMX_LIBS_SUFFIX "_mpi")
144 set (GMX_BINARY_SUFFIX "${GMX_BINARY_SUFFIX}_d")
145 set (GMX_LIBS_SUFFIX "${GMX_LIBS_SUFFIX}_d")
148 set (GMX_BINARY_SUFFIX "-gpu")
149 set (GMX_LIBS_SUFFIX "_gpu")
151 mark_as_advanced(FORCE GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
152 message(STATUS "Using default binary suffix: \"${GMX_BINARY_SUFFIX}\"")
153 message(STATUS "Using default library suffix: \"${GMX_LIBS_SUFFIX}\"")
154 else(GMX_DEFAULT_SUFFIX)
155 mark_as_advanced(CLEAR GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
156 message(STATUS "Using manually set binary suffix: \"${GMX_BINARY_SUFFIX}\"")
157 message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"")
158 endif(GMX_DEFAULT_SUFFIX)
162 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE")
164 if(GMX_SOFTWARE_INVSQRT)
165 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT")
166 endif(GMX_SOFTWARE_INVSQRT)
167 if(GMX_POWERPC_INVSQRT)
168 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_POWERPC_INVSQRT")
169 endif(GMX_POWERPC_INVSQRT)
171 ########################################################################
172 #Process MPI settings
173 ########################################################################
174 include(CheckCSourceCompiles) # for gmxTestMPI_IN_PLACE
177 There are known problems with some MPI implementations:
178 OpenMPI version < 1.4.1
179 MVAPICH2 version <= 1.4.1 *")
181 #message(FATAL_ERROR "Thread-based parallelization conflicts with MPI.")
182 set(GMX_THREADS OFF CACHE BOOL
183 "Thread-based parallelization conflicts with MPI." FORCE)
187 set(GROMACS_C_FLAGS ${GROMACS_FLAGS} ${MPI_COMPILE_FLAGS})
188 set(GROMACS_LINKER_FLAGS ${GROMACS_LINKER_FLAGS} ${MPI_LINK_FLAGS})
190 include_directories(${MPI_INCLUDE_PATH})
191 list(APPEND GMX_EXTRA_LIBRARIES ${MPI_LIBRARIES})
192 add_definitions( -DMPI ) #for FAHCORE
193 include(gmxTestMPI_IN_PLACE)
194 if (GMX_MPI_IN_PLACE)
195 gmx_test_mpi_in_place(MPI_IN_PLACE_EXISTS)
196 endif (GMX_MPI_IN_PLACE)
198 message(FATAL_ERROR "MPI support requested, but no MPI compiler found.")
200 include(gmxTestCatamount)
201 gmx_test_catamount(GMX_CRAY_XT3)
203 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
208 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")
212 #######################################################################
213 # Check for options incompatible with OpenMM build #
214 #######################################################################
216 cmake_minimum_required(VERSION 2.6.4)
217 # we'll use the built-in fft to avoid unnecessary dependencies
218 string(TOUPPER ${GMX_FFT_LIBRARY} GMX_FFT_LIBRARY)
219 if(NOT ${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
220 message(STATUS "No external FFT libraries needed for the OpenMM build, switching to fftpack!")
221 set(GMX_FFT_LIBRARY "fftpack" CACHE STRING
222 "No external FFT libraries needed for the OpenMM build, switching to fftpack!" FORCE)
225 message(FATAL_ERROR "The OpenMM build is not compatible with MPI!")
228 message(STATUS "Threads are not compatible with OpenMM build, disabled!")
229 set(GMX_THREADS OFF CACHE BOOL
230 "Threads are not compatible with OpenMM build, disabled!" FORCE)
232 if(GMX_SOFTWARE_INVSQRT)
233 set(GMX_SOFTWARE_INVSQRT OFF CACHE STRING
234 "The OpenMM build does not need GROMACS software 1/sqrt!" FORCE)
235 endif(GMX_SOFTWARE_INVSQRT)
236 string(TOUPPER ${GMX_ACCELERATION} GMX_ACCELERATION)
237 if(NOT GMX_ACCELERATION STREQUAL "NONE")
238 message(STATUS "Switching off CPU-based acceleration, the OpenMM build does not support/need any!")
239 set(GMX_ACCELERATION "none" CACHE STRING
240 "Switching off CPU-based acceleration, the OpenMM build does not support/need any!" FORCE)
243 message(FATAL_ERROR "The OpenMM build does not support FAH build!")
246 message(FATAL_ERROR "The OpenMM-build does not support double precision calculations!")
248 # mark as advanced the unused variables
249 mark_as_advanced(FORCE GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
250 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
252 mark_as_advanced(CLEAR GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
253 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
257 ########################################################################
258 # Basic system tests (standard libraries, headers, functions, types) #
259 ########################################################################
260 include(CheckIncludeFiles)
261 check_include_files(string.h HAVE_STRING_H)
262 check_include_files(math.h HAVE_MATH_H)
263 check_include_files(limits.h HAVE_LIMITS_H)
264 check_include_files(memory.h HAVE_MEMORY_H)
265 check_include_files(unistd.h HAVE_UNISTD_H)
266 check_include_files(pwd.h HAVE_PWD_H)
267 check_include_files(stdint.h HAVE_STDINT_H)
268 check_include_files(stdlib.h HAVE_STDLIB_H)
269 check_include_files(pthread.h HAVE_PTHREAD_H)
270 check_include_files(dirent.h HAVE_DIRENT_H)
271 check_include_files(inttypes.h HAVE_INTTYPES_H)
272 check_include_files(regex.h HAVE_REGEX_H)
273 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
274 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
275 check_include_files(sys/time.h HAVE_SYS_TIME_H)
276 check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
277 check_include_files("rpc/rpc.h;rpc/xdr.h" HAVE_RPC_XDR_H)
279 check_include_files(xmmintrin.h HAVE_XMMINTRIN_H)
280 check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
281 check_include_files(pmmintrin.h HAVE_PMMINTRIN_H)
282 check_include_files(smmintrin.h HAVE_SMMINTRIN_H)
283 check_include_files(io.h HAVE_IO_H)
286 include(CheckFunctionExists)
287 check_function_exists(strcasecmp HAVE_STRCASECMP)
288 check_function_exists(strdup HAVE_STRDUP)
289 check_function_exists(vprintf HAVE_VPRINTF)
290 check_function_exists(memcmp HAVE_MEMCMP)
291 check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
292 check_function_exists(memalign HAVE_MEMALIGN)
293 check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
294 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
295 check_function_exists(isnan HAVE_ISNAN)
296 check_function_exists(_isnan HAVE__ISNAN)
297 check_function_exists(isfinite HAVE_ISFINITE)
298 check_function_exists(_isfinite HAVE__ISFINITE)
299 check_function_exists(fsync HAVE_FSYNC)
300 check_function_exists(_fileno HAVE__FILENO)
301 check_function_exists(fileno HAVE_FILENO)
302 check_function_exists(_commit HAVE__COMMIT)
304 include(CheckLibraryExists)
305 check_library_exists(m sqrt "" HAVE_LIBM)
306 check_library_exists(m cbrt "" HAVE_CBRT)
309 include(CheckTypeSize)
311 check_type_size("bool" SIZEOF_BOOL) # will also set HAVE_BOOL
312 check_type_size("int" SIZEOF_INT)
313 check_type_size("long int" SIZEOF_LONG_INT)
314 check_type_size("long long int" SIZEOF_LONG_LONG_INT)
315 check_type_size("off_t" SIZEOF_OFF_T)
316 check_type_size("void *" SIZEOF_VOIDP)
318 if (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
320 else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
321 set(GMX_64_BIT FALSE)
322 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
324 # Check for some basic types that we *need*, so set these to int if they are not present
325 check_type_size(uid_t uid_t)
332 check_type_size(gid_t gid_t)
339 check_type_size(size_t size_t)
346 check_type_size(off_t off_t)
353 include(TestBigEndian)
354 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
359 ########################################################################
360 # Find external packages #
361 ########################################################################
362 if(UNIX AND NOT APPLE)
363 if(GMX_PREFER_STATIC_LIBS)
364 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
365 if(BUILD_SHARED_LIBS)
366 message(WARNING "Static libraries requested, the GROMACS libraries will also be build static (BUILD_SHARED_LIBS=OFF)")
367 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Enable shared libraries (can be problematic with MPI, Windows)" FORCE)
372 find_package(LibXml2)
375 include_directories(${LIBXML2_INCLUDE_DIR})
376 set(PKG_XML libxml-2.0)
377 set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
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})
416 # only bother with finding git and using version.h if the source is a git repo
417 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
419 # We need at least git v1.5.1 be able to parse git's date output. If not
420 # fund or the version is too small, we can't generate version information.
421 find_package(Git 1.5.1)
422 # this should at some point become VERSION_LESS
423 if(NOT Git_FOUND OR Git_VERSION STRLESS "1.5.1")
424 message("No compatible git version found, won't be able to generate proper development version information.")
425 set(USE_VERSION_H OFF)
429 set(USE_VERSION_H OFF)
433 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
436 ########################################################################
437 # Generate development version info for cache
438 ########################################################################
439 # set(GEN_VERSION_INFO_INTERNAL "ON")
440 # include(gmxGenerateVersionString)
442 ########################################################################
443 # Our own GROMACS tests
444 ########################################################################
446 add_definitions( -DHAVE_CONFIG_H )
447 include_directories(${CMAKE_BINARY_DIR}/src)
448 include_directories(${CMAKE_SOURCE_DIR}/include)
450 include(gmxCheckBuildUserTime)
451 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
453 include(gmxTestFloatFormat)
454 gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
455 GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
456 GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
458 include(gmxTestLargeFiles)
459 gmx_test_large_files(GMX_LARGEFILES)
460 check_function_exists(fseeko HAVE_FSEEKO)
462 include(gmxTestSignal)
463 gmx_test_retsigtype(RETSIGTYPE)
464 gmx_test_sigusr1(HAVE_SIGUSR1)
466 include(gmxTestInline)
467 gmx_test_inline(INLINE_KEYWORD)
469 include(gmxTestRestrict)
470 gmx_test_inline(RESTRICT_KEYWORD)
472 include(gmxTestPipes)
473 gmx_test_pipes(HAVE_PIPES)
475 include(gmxTestInlineASM)
476 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
477 gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
479 # turn on SSE if supported with reasonable defaults.
480 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
481 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x64|x86_64|AMD64|amd64)")
483 set(GMX_ACCELERATION "SSE" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
486 set(GMX_X86_64_ASM ON CACHE BOOL "Add SSE assembly files for x86_64" FORCE)
488 set(GMX_IA32_ASM ON CACHE BOOL "Add SSE assembly files for i386" FORCE)
491 # Determine the assembler/compiler to use
493 set(GMX_ACCELERATION "none" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
495 endif (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
498 gmx_test_xdr(GMX_SYSTEM_XDR)
499 if(NOT GMX_SYSTEM_XDR)
500 set(GMX_INTERNAL_XDR 1)
501 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
502 endif(NOT GMX_SYSTEM_XDR)
504 # Process nonbonded accelerated kernels settings
505 string(TOUPPER ${GMX_ACCELERATION} ${GMX_ACCELERATION})
506 if(${GMX_ACCELERATION} STREQUAL "NONE")
508 elseif(${GMX_ACCELERATION} STREQUAL "SSE")
510 if(CMAKE_GENERATOR MATCHES "Visual Studio")
511 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" ON)
513 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" OFF)
515 mark_as_advanced(GMX_ASM_USEASM-NASM)
518 # for 32-bit compiles, we might need to turn on sse
519 CHECK_C_COMPILER_FLAG("-msse2" XFLAGS_SSE)
521 set(GROMACS_C_FLAGS "-msse2 ${GROMACS_C_FLAGS}")
523 CHECK_CXX_COMPILER_FLAG("-msse2" XXFLAGS_SSE)
525 set(GROMACS_CXX_FLAGS "-msse2 ${GROMACS_CXX_FLAGS}")
527 endif (NOT GMX_64_BIT)
535 elseif(GMX_X86_64_ASM)
537 set(GMX_X86_64_SSE2 1)
539 set(GMX_X86_64_SSE 1)
543 # if(HAVE_PMMINTRIN_H)
545 # endif(HAVE_PMMINTRIN_H)
546 # if(HAVE_SMMINTRIN_H)
548 # endif(HAVE_SMMINTRIN_H)
550 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
552 #these are switch on by default sometimes
554 set(GMX_GMX_X86_64_ASM 0)
555 elseif(${GMX_ACCELERATION} STREQUAL "BLUEGENE")
556 # GMX_ACCELERATION=BlueGene should be set in the Toolchain-BlueGene?-???.cmake file
557 message(STATUS "Configuring for BlueGene")
559 if (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
560 set(SHARED_LIBS_DEFAULT OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
561 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
562 endif (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
563 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene" FORCE)
564 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on BlueGene" FORCE)
565 set(GMX_X11 OFF CACHE BOOL "X11 not compatible with BlueGene, disabled!" FORCE)
566 set(GMX_THREADS OFF CACHE BOOL "Threads not compatible with BlueGene, disabled!" FORCE)
567 set(GMX_MPI ON CACHE BOOL "Use MPI on BlueGene" FORCE)
568 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use MASSV for BLAS on BlueGene" FORCE)
569 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use MASSV for LAPACK on BlueGene" FORCE)
570 list(APPEND GMX_EXTRA_LIBRARIES massv)
571 elseif(${GMX_ACCELERATION} STREQUAL "POWER6")
573 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on Power6" FORCE)
574 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on Power6" FORCE)
575 elseif(${GMX_ACCELERATION} STREQUAL "IA64")
577 set(DISABLE_WATERWATER_NLIST 1)
578 set(DISABLE_WATER_NLIST 1)
579 elseif(${GMX_ACCELERATION} STREQUAL "ALTIVEC")
580 check_include_files(altivec.h HAVE_ALTIVEC_H)
582 set(GMX_PPC_ALTIVEC 1)
583 endif(HAVE_ALTIVEC_H)
584 else(${GMX_ACCELERATION} STREQUAL "NONE")
585 MESSAGE(FATAL_ERROR "Unrecognized option for accelerated kernels: ${GMX_ACCELERATION}. Pick one of auto, none, SSE, Fortran, BlueGene, Power6, ia64, altivec")
586 endif(${GMX_ACCELERATION} STREQUAL "NONE")
588 if(GMX_FORTRAN OR GMX_POWER6)
590 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).")
592 enable_language(Fortran)
593 include(FortranCInterface)
594 discover_fortran_mangling(prefix isupper suffix extra_under_score found)
595 if(extra_under_score)
597 endif(extra_under_score)
599 set(prefix "${prefix} ##")
603 set(F77_FUNCDEF "${prefix} NAME ## ${suffix}")
604 set(F77_FUNCDEF_ "${prefix} NAME ## ${suffix}${extrasuffix}")
606 set(F77_FUNCDEF "${prefix} name ## ${suffix}")
607 set(F77_FUNCDEF_ "${prefix} name ## ${suffix}${extrasuffix}")
609 else(GMX_FORTRAN OR GMX_POWER6)
610 set(F77_FUNCDEF "name ## _")
611 set(F77_FUNCDEF_ "name ## _")
612 endif(GMX_FORTRAN OR GMX_POWER6)
614 # Process QM/MM Settings
615 string(TOUPPER ${GMX_QMMM_PROGRAM} ${GMX_QMMM_PROGRAM})
616 if(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
617 set(GMX_QMMM_GAUSSIAN 1)
618 elseif(${GMX_QMMM_PROGRAM} STREQUAL "MOPAC")
619 set(GMX_QMMM_MOPAC 1)
620 elseif(${GMX_QMMM_PROGRAM} STREQUAL "GAMESS")
621 set(GMX_QMMM_GAMESS 1)
622 elseif(${GMX_QMMM_PROGRAM} STREQUAL "ORCA")
624 elseif(${GMX_QMMM_PROGRAM} STREQUAL "NONE")
626 else(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
627 MESSAGE(FATAL_ERROR "Invalid QM/MM program option: ${GMX_QMMM_PROGRAM}. Choose one of: Gaussian, Mopac, Gamess, Orca, None")
628 endif(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
630 # Process FFT library settings - if not OpenMM build
631 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
634 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
635 # MESSAGE(STATUS "Using external FFT library - fftw3")
637 find_package(FFTW3 REQUIRED)
638 include_directories(${FFTW3_INCLUDE_DIR})
639 set(FFT_LIBRARIES ${FFTW3_LIBRARIES})
642 find_package(FFTW3F REQUIRED)
643 include_directories(${FFTW3F_INCLUDE_DIR})
644 set(FFT_LIBRARIES ${FFTW3F_LIBRARIES})
645 set(PKG_FFT "fftw3f")
648 if(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
649 MESSAGE(FATAL_ERROR "Cannot find fftw3 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
650 endif(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
654 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
655 # MESSAGE(STATUS "Using external FFT library - fftw2")
657 find_package(FFTW2 REQUIRED)
659 find_package(FFTW2F REQUIRED)
663 MESSAGE(FATAL_ERROR "Cannot find fftw2 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
664 endif(NOT FFTW2_FOUND)
665 include_directories(${FFTW2_INCLUDE_DIR})
666 set(FFT_LIBRARIES ${FFTW2_LIBRARIES})
667 set(PKG_FFT_LIBS ${FFTW2_LIBRARIES})
669 if("${FFTW2_LIBRARIES}" MATCHES "dfftw")
670 set(FFTW2_NAME_DFFTW 1)
671 elseif("${FFTW2_LIBRARIES}" MATCHES "sfftw")
672 set(FFTW2_NAME_SFFTW 1)
673 else("${FFTW2_LIBRARIES}" MATCHES "dfftw")
674 set(FFTW2_NAME_FFTW 1)
675 endif("${FFTW2_LIBRARIES}" MATCHES "dfftw")
678 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
679 # MESSAGE(STATUS "Using external FFT library - Intel MKL")
680 find_package(MKL REQUIRED)
681 include_directories(${MKL_INCLUDE_DIR})
682 set(FFT_LIBRARIES ${MKL_LIBRARIES})
683 set(PKG_FFT_LIBS ${MKL_LIBRARIES})
688 #elseif(${GMX_FFT_LIBRARY} STREQUAL "ACML")
689 # MESSAGE(STATUS "Using external FFT library - AMD core math library")
690 # set(GMX_FFT_ACML 1)
691 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
692 MESSAGE(STATUS "Using internal FFT library - fftpack")
693 set(GMX_FFT_FFTPACK 1)
694 else(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
695 MESSAGE(FATAL_ERROR "Invalid FFT library setting: ${GMX_FFT_LIBRARY}. Choose one of: fftw3, fftw2, mkl, acml, fftpack")
696 endif(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
698 # MKL has BLAS/LAPACK routines
699 if(HAVE_MKL OR ACCELERATE_FRAMEWORK)
700 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use external BLAS instead of built-in")
701 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use external LAPACK instead of built-in")
702 else(HAVE_MKL OR ACCELERATE_FRAMEWORK)
703 set(GMX_EXTERNAL_BLAS FALSE CACHE BOOL "Use external LAPACK instead of built-in")
704 set(GMX_EXTERNAL_LAPACK FALSE CACHE BOOL "Use external LAPACK instead of built-in")
705 if(GMX_EXTERNAL_BLAS)
706 #FindBLAS needs Fortran
707 enable_language(Fortran)
709 list(APPEND GMX_EXTRA_LIBRARIES ${BLAS_LIBRARIES})
710 endif(GMX_EXTERNAL_BLAS)
711 if(GMX_EXTERNAL_LAPACK)
712 #FindLAPACK needs Fortran
713 enable_language(Fortran)
715 list(APPEND GMX_EXTRA_LIBRARIES ${LAPACK_LIBRARIES})
716 endif(GMX_EXTERNAL_LAPACK)
717 endif(HAVE_MKL OR ACCELERATE_FRAMEWORK)
718 mark_as_advanced(GMX_EXTERNAL_LAPACK)
719 mark_as_advanced(GMX_EXTERNAL_BLAS)
721 # Math and thread libraries must often come after all others when linking...
723 list(APPEND GMX_EXTRA_LIBRARIES m)
727 set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
728 "Path to swindirect.h")
729 include_directories(${COREWRAP_INCLUDE_DIR})
732 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
733 # these are set after everything else
734 if (NOT DEFINED GROMACS_C_FLAGS_SET)
735 set(GROMACS_C_FLAGS_SET true CACHE INTERNAL "Whether to reset the C flags"
737 set(CMAKE_C_FLAGS "${GROMACS_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
738 "Flags used by the compiler during all build types" FORCE)
739 set(CMAKE_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING
740 "Flags used by the compiler during all build types" FORCE)
741 set(CMAKE_EXE_LINKER_FLAGS
742 "${GROMACS_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
743 CACHE STRING "Linker flags" FORCE)
744 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
746 ########################################################################
747 # Specify install locations and which subdirectories to process #
748 ########################################################################
750 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
752 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
754 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
755 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/gromacs)
756 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
757 set(INCL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
759 set(GMXLIBDIR ${DATA_INSTALL_DIR}/top)
761 ##################################################################
762 # Shared library settings - Darwin uses INSTALL_NAME_DIR instead!
763 ##################################################################
764 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
765 set(CMAKE_SKIP_BUILD_RPATH FALSE)
766 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
767 set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
768 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
771 add_subdirectory(share)
772 add_subdirectory(include)
773 add_subdirectory(man)
774 add_subdirectory(src)
775 add_subdirectory(scripts)
777 #######################
779 #######################
781 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
782 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
784 ###########################
785 ADD_CUSTOM_TARGET(uninstall
786 "${CMAKE_COMMAND}" -P
787 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
788 ###########################
791 ########################################################################
793 ########################################################################
796 mark_as_advanced(BUILD_TESTING)
799 add_test(TestBuildAll make)
800 add_subdirectory(tests)