1 cmake_minimum_required(VERSION 2.6)
5 mark_as_advanced(DART_ROOT)
6 # PROJECT_VERSION should have the following structure:
7 # VERSION[-dev-SUFFIX] where the VERSION can have any form and the suffix
8 set(PROJECT_VERSION "4.5.1")
9 set(CUSTOM_VERSION_STRING ""
10 CACHE STRING "Custom version string (if empty, use hard-coded default)")
11 mark_as_advanced(CUSTOM_VERSION_STRING)
12 if (CUSTOM_VERSION_STRING)
13 set(PROJECT_VERSION ${CUSTOM_VERSION_STRING})
14 endif (CUSTOM_VERSION_STRING)
16 # It is a bit irritating, but this has to be set separately for now!
17 SET(CPACK_PACKAGE_VERSION_MAJOR "4")
18 SET(CPACK_PACKAGE_VERSION_MINOR "5")
19 SET(CPACK_PACKAGE_VERSION_PATCH "1")
22 # Cmake modules/macros are in a subdirectory to keep this file cleaner
23 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
25 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
26 set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE)
29 if(NOT CMAKE_BUILD_TYPE)
30 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
31 endif(NOT CMAKE_BUILD_TYPE)
35 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
36 set(CPACK_PACKAGE_VENDOR "gromacs.org")
37 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation")
38 set(CPACK_SET_DESTDIR "ON")
39 set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
40 set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt")
41 # Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this...
42 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/admin/InstallLicense.txt")
43 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
45 #must come after all cpack settings!
49 ########################################################################
50 # Fix stupid flags on MSVC
51 ########################################################################
52 SET(SHARED_LIBS_DEFAULT ON)
53 IF(CMAKE_GENERATOR MATCHES "Visual Studio")
54 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
55 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
56 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
57 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
58 SET(SHARED_LIBS_DEFAULT OFF)
59 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
61 set(GMX_EXTRA_LIBRARIES)
65 ######################################################################
67 # these need ot be done early (before further tests).
68 #####################################################################
70 include(CheckCCompilerFlag)
71 include(CheckCXXCompilerFlag)
76 ########################################################################
77 # User input options #
78 ########################################################################
79 option(GMX_DOUBLE "Use double precision (much slower, use only if you really need it)" OFF)
80 option(GMX_MPI "Build a parallel (message-passing) version of GROMACS" OFF)
81 option(GMX_THREADS "Build a parallel (thread-based) version of GROMACS (cannot be combined with MPI yet)" ON)
82 option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
83 mark_as_advanced(GMX_SOFTWARE_INVSQRT)
84 option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
85 mark_as_advanced(GMX_FAHCORE)
86 option(GMX_OPENMM "Accelerated execution on GPUs through the OpenMM library (rerun cmake after changing to see relevant options)" OFF)
87 set(GMX_ACCELERATION "auto"
88 CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec")
90 set(GMX_FFT_LIBRARY "fftw3"
91 CACHE STRING "FFT library choices: fftw3,fftw2,mkl,fftpack[built-in]")
92 option(GMX_DISABLE_FFTW_MEASURE
93 "Do not optimize FFTW setups (not needed with SSE)" OFF)
94 mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
95 set(GMX_QMMM_PROGRAM "none"
96 CACHE STRING "QM package choices: none,gaussian,mopac,gamess,orca")
97 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
98 mark_as_advanced(GMX_BROKEN_CALLOC)
99 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic with MPI, Windows)" ${SHARED_LIBS_DEFAULT})
100 option(GMX_MPI_IN_PLACE "Enable MPI_IN_PLACE for MPIs that have it defined" ON)
101 mark_as_advanced(GMX_MPI_IN_PLACE)
102 option(GMX_DLOPEN "Compile with dlopen, needed to read VMD supported file formats" ON)
103 mark_as_advanced(GMX_DLOPEN)
106 option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
107 mark_as_advanced(GMX_IA32_ASM)
108 option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
109 mark_as_advanced(GMX_X86_64_ASM)
111 option(USE_VERSION_H "Generate development version string/information" ON)
112 mark_as_advanced(USE_VERSION_H)
114 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)
115 set(GMX_BINARY_SUFFIX "" CACHE STRING "Suffix for GROMACS binaries (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
116 set(GMX_LIBS_SUFFIX ""
117 CACHE STRING "Suffix for GROMACS libs (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
118 if (GMX_DEFAULT_SUFFIX)
119 set(GMX_BINARY_SUFFIX "")
120 set(GMX_LIBS_SUFFIX "")
122 set(GMX_BINARY_SUFFIX "_mpi")
123 set(GMX_LIBS_SUFFIX "_mpi")
126 set (GMX_BINARY_SUFFIX "${GMX_BINARY_SUFFIX}_d")
127 set (GMX_LIBS_SUFFIX "${GMX_LIBS_SUFFIX}_d")
129 mark_as_advanced(FORCE GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
130 message(STATUS "Using default binary suffix: \"${GMX_BINARY_SUFFIX}\"")
131 message(STATUS "Using default library suffix: \"${GMX_LIBS_SUFFIX}\"")
132 else(GMX_DEFAULT_SUFFIX)
133 mark_as_advanced(CLEAR GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
134 message(STATUS "Using manually set binary suffix: \"${GMX_BINARY_SUFFIX}\"")
135 message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"")
136 endif(GMX_DEFAULT_SUFFIX)
140 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE")
142 if(GMX_SOFTWARE_INVSQRT)
143 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT")
144 endif(GMX_SOFTWARE_INVSQRT)
146 ########################################################################
147 #Process MPI settings
148 ########################################################################
151 There are known problems with some MPI implementations:
152 OpenMPI version < 1.4.1
153 MVAPICH2 version <= 1.4.1 *")
155 #message(FATAL_ERROR "Thread-based parallelization conflicts with MPI.")
156 set(GMX_THREADS OFF CACHE BOOL
157 "Thread-based parallelization conflicts with MPI." FORCE)
161 set(GROMACS_C_FLAGS ${GROMACS_FLAGS} ${MPI_COMPILE_FLAGS})
162 set(GROMACS_LINKER_FLAGS ${GROMACS_LINKER_FLAGS} ${MPI_LINK_FLAGS})
164 include_directories(${MPI_INCLUDE_PATH})
165 list(APPEND GMX_EXTRA_LIBRARIES ${MPI_LIBRARIES})
166 add_definitions( -DMPI ) #for FAHCORE
167 include(gmxTestMPI_IN_PLACE)
168 if (GMX_MPI_IN_PLACE)
169 gmx_test_mpi_in_place(MPI_IN_PLACE_EXISTS)
170 endif (GMX_MPI_IN_PLACE)
172 message(FATAL_ERROR "MPI support requested, but no MPI compiler found.")
174 include(gmxTestCatamount)
175 gmx_test_catamount(GMX_CRAY_XT3)
177 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
182 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")
186 #######################################################################
187 # Check for options incompatible with OpenMM build #
188 #######################################################################
190 cmake_minimum_required(VERSION 2.6.4)
191 # we'll use the built-in fft to avoid unnecessary dependencies
192 message(STATUS "No external FFT libraries needed for the OpenMM build, using fftpack!")
193 set (GMX_FFT_LIBRARY "fftpack" CACHE STRING
194 "No external FFT libraries needed for the OpenMM build, using fftpack!" FORCE)
196 message(FATAL_ERROR "The OpenMM build is not compatible with MPI!")
199 message(STATUS "Threads not compatible with OpenMM build, disabled!")
200 set(GMX_THREADS OFF CACHE BOOL
201 "Threads not compatible with OpenMM build, disabled!" FORCE)
203 if(GMX_SOFTWARE_INVSQRT)
204 set(GMX_SOFTWARE_INVSQRT OFF FORCE)
205 endif(GMX_SOFTWARE_INVSQRT)
206 if(NOT GMX_ACCELERATION MATCHES "^(none|None|NONE)")
207 message(WARNING "CPU-based acceleration turned off, OpenMM does not support/need any!")
208 unset(GMX_ACCELERATION CACHE)
209 set(GMX_ACCELERATION "none" CACHE STRING
210 "CPU-based acceleration turned off, OpenMM does not support/need any!" FORCE)
213 message(FATAL_ERROR "The OpenMM build does not support FAH build!")
215 set(GMX_DOUBLE OFF FORCE )
216 # mark as advanced the unused variables
217 mark_as_advanced(FORCE GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
218 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
220 mark_as_advanced(CLEAR GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
221 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
225 ########################################################################
226 # Basic system tests (standard libraries, headers, functions, types) #
227 ########################################################################
228 include(CheckIncludeFiles)
229 check_include_files(string.h HAVE_STRING_H)
230 check_include_files(math.h HAVE_MATH_H)
231 check_include_files(limits.h HAVE_LIMITS_H)
232 check_include_files(memory.h HAVE_MEMORY_H)
233 check_include_files(unistd.h HAVE_UNISTD_H)
234 check_include_files(pwd.h HAVE_PWD_H)
235 check_include_files(stdint.h HAVE_STDINT_H)
236 check_include_files(stdlib.h HAVE_STDLIB_H)
237 check_include_files(pthread.h HAVE_PTHREAD_H)
238 check_include_files(dirent.h HAVE_DIRENT_H)
239 check_include_files(inttypes.h HAVE_INTTYPES_H)
240 check_include_files(regex.h HAVE_REGEX_H)
241 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
242 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
243 check_include_files(sys/time.h HAVE_SYS_TIME_H)
244 check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
245 check_include_files("rpc/rpc.h;rpc/xdr.h" HAVE_RPC_XDR_H)
247 check_include_files(xmmintrin.h HAVE_XMMINTRIN_H)
248 check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
249 check_include_files(pmmintrin.h HAVE_PMMINTRIN_H)
250 check_include_files(smmintrin.h HAVE_SMMINTRIN_H)
251 check_include_files(io.h HAVE_IO_H)
254 include(CheckFunctionExists)
255 check_function_exists(strcasecmp HAVE_STRCASECMP)
256 check_function_exists(strdup HAVE_STRDUP)
257 check_function_exists(vprintf HAVE_VPRINTF)
258 check_function_exists(memcmp HAVE_MEMCMP)
259 check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
260 check_function_exists(memalign HAVE_MEMALIGN)
261 check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
262 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
263 check_function_exists(isnan HAVE_ISNAN)
264 check_function_exists(_isnan HAVE__ISNAN)
265 check_function_exists(isfinite HAVE_ISFINITE)
266 check_function_exists(_isfinite HAVE__ISFINITE)
267 check_function_exists(fsync HAVE_FSYNC)
268 check_function_exists(_fileno HAVE__FILENO)
269 check_function_exists(fileno HAVE_FILENO)
270 check_function_exists(_commit HAVE__COMMIT)
272 include(CheckLibraryExists)
273 check_library_exists(m sqrt "" HAVE_LIBM)
274 check_library_exists(m cbrt "" HAVE_CBRT)
277 include(CheckTypeSize)
279 check_type_size("bool" SIZEOF_BOOL) # will also set HAVE_BOOL
280 check_type_size("int" SIZEOF_INT)
281 check_type_size("long int" SIZEOF_LONG_INT)
282 check_type_size("long long int" SIZEOF_LONG_LONG_INT)
283 check_type_size("off_t" SIZEOF_OFF_T)
284 check_type_size("void *" SIZEOF_VOIDP)
286 if (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
288 else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
289 set(GMX_64_BIT FALSE)
290 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
292 # Check for some basic types that we *need*, so set these to int if they are not present
293 check_type_size(uid_t uid_t)
300 check_type_size(gid_t gid_t)
307 check_type_size(size_t size_t)
314 check_type_size(off_t off_t)
321 include(TestBigEndian)
322 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
327 ########################################################################
328 # Find external packages #
329 ########################################################################
331 find_package(LibXml2)
334 include_directories(${LIBXML2_INCLUDE_DIR})
335 set(PKG_XML libxml-2.0)
336 set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
340 option(GMX_X11 "Use X window system" OFF)
343 # X11 includes/libraries are only set in the ngmx subdirectory!
350 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREADS")
352 set(THREAD_MPI_LIB thread_mpi)
354 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
355 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
356 message(FATAL_ERROR "FFTW2 can't be used with threads. Try fftw3 or mkl.")
361 set(CUDA_BUILD_EMULATION OFF)
362 find_package(CUDA 3.1 REQUIRED)
363 add_definitions(-DGMX_OPENMM)
364 if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
365 set(CUDA_VERBOSE_BUILD ON)
371 find_library(ACCELERATE_FRAMEWORK Accelerate)
372 list(APPEND GMX_EXTRA_LIBRARIES ${ACCELERATE_FRAMEWORK})
375 # only bother with finding git and using version.h if the source is a git repo
376 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
378 # We need at least git v1.5.1 be able to parse git's date output. If not
379 # fund or the version is too small, we can't generate version information.
380 find_package(Git 1.5.1)
381 # this should at some point become VERSION_LESS
382 if(NOT Git_FOUND OR Git_VERSION STRLESS "1.5.1")
383 message("No compatible git version found, won't be able to generate proper development version information.")
384 set(USE_VERSION_H OFF)
388 set(USE_VERSION_H OFF)
392 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
395 ########################################################################
396 # Generate development version info for cache
397 ########################################################################
398 # set(GEN_VERSION_INFO_INTERNAL "ON")
399 # include(gmxGenerateVersionString)
401 ########################################################################
402 # Our own GROMACS tests
403 ########################################################################
405 add_definitions( -DHAVE_CONFIG_H )
406 include_directories(${CMAKE_BINARY_DIR}/src)
407 include_directories(${CMAKE_SOURCE_DIR}/include)
409 include(gmxCheckBuildUserTime)
410 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
412 include(gmxTestFloatFormat)
413 gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
414 GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
415 GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
417 include(gmxTestLargeFiles)
418 gmx_test_large_files(GMX_LARGEFILES)
419 check_function_exists(fseeko HAVE_FSEEKO)
421 include(gmxTestSignal)
422 gmx_test_retsigtype(RETSIGTYPE)
423 gmx_test_sigusr1(HAVE_SIGUSR1)
425 include(gmxTestInline)
426 gmx_test_inline(INLINE_KEYWORD)
428 include(gmxTestRestrict)
429 gmx_test_inline(RESTRICT_KEYWORD)
431 include(gmxTestPipes)
432 gmx_test_pipes(HAVE_PIPES)
434 include(gmxTestInlineASM)
435 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
436 gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
438 # turn on SSE if supported with reasonable defaults.
439 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
440 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x64|x86_64|AMD64|amd64)")
442 set(GMX_ACCELERATION "SSE" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec" FORCE)
445 set(GMX_X86_64_ASM ON CACHE BOOL "Add SSE assembly files for x86_64" FORCE)
447 set(GMX_IA32_ASM ON CACHE BOOL "Add SSE assembly files for i386" FORCE)
450 # Determine the assembler/compiler to use
452 set(GMX_ACCELERATION "none" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec" FORCE)
454 endif (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
458 gmx_test_xdr(GMX_SYSTEM_XDR)
459 if(NOT GMX_SYSTEM_XDR)
460 set(GMX_INTERNAL_XDR 1)
461 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
462 endif(NOT GMX_SYSTEM_XDR)
464 if(GMX_FORTRAN OR GMX_POWER6)
465 enable_language(Fortran)
466 include(FortranCInterface)
467 discover_fortran_mangling(prefix isupper suffix extra_under_score found)
468 if(extra_under_score)
470 endif(extra_under_score)
473 set(F77_FUNCDEF "${prefix} ## NAME ## ${suffix}")
474 set(F77_FUNCDEF_ "${prefix} ## NAME ## ${suffix}${extrasuffix}")
476 set(F77_FUNCDEF "${prefix} ## name ## ${suffix}")
477 set(F77_FUNCDEF_ "${prefix} ## name ## ${suffix}${extrasuffix}")
479 else(GMX_FORTRAN OR GMX_POWER6)
480 set(F77_FUNCDEF "name ## _")
481 set(F77_FUNCDEF_ "name ## _")
482 endif(GMX_FORTRAN OR GMX_POWER6)
485 # Process nonbonded accelerated kernels settings
486 string(TOUPPER ${GMX_ACCELERATION} ${GMX_ACCELERATION})
487 if(${GMX_ACCELERATION} STREQUAL "NONE")
489 elseif(${GMX_ACCELERATION} STREQUAL "SSE")
491 if(CMAKE_GENERATOR MATCHES "Visual Studio")
492 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" ON)
494 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" OFF)
496 mark_as_advanced(GMX_ASM_USEASM-NASM)
499 # for 32-bit compiles, we might need to turn on sse
500 CHECK_C_COMPILER_FLAG("-msse2" XFLAGS_SSE)
502 set(GROMACS_C_FLAGS "-msse2 ${GROMACS_C_FLAGS}")
504 CHECK_CXX_COMPILER_FLAG("-msse2" XXFLAGS_SSE)
506 set(GROMACS_CXX_FLAGS "-msse2 ${GROMACS_CXX_FLAGS}")
508 endif (NOT GMX_64_BIT)
516 elseif(GMX_X86_64_ASM)
518 set(GMX_X86_64_SSE2 1)
520 set(GMX_X86_64_SSE 1)
524 # if(HAVE_PMMINTRIN_H)
526 # endif(HAVE_PMMINTRIN_H)
527 # if(HAVE_SMMINTRIN_H)
529 # endif(HAVE_SMMINTRIN_H)
531 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
533 elseif(${GMX_ACCELERATION} STREQUAL "BLUEGENE")
535 elseif(${GMX_ACCELERATION} STREQUAL "POWER6")
537 elseif(${GMX_ACCELERATION} STREQUAL "IA64")
539 set(DISABLE_WATERWATER_NLIST 1)
540 set(DISABLE_WATER_NLIST 1)
541 elseif(${GMX_ACCELERATION} STREQUAL "ALTIVEC")
542 check_include_files(altivec.h HAVE_ALTIVEC_H)
544 set(GMX_PPC_ALTIVEC 1)
545 endif(HAVE_ALTIVEC_H)
546 else(${GMX_ACCELERATION} STREQUAL "NONE")
547 MESSAGE(FATAL_ERROR "Unrecognized option for accelerated kernels: ${GMX_ACCELERATION}. Pick one of auto, none, SSE, Fortran, BlueGene, Power6, ia64, altivec")
548 endif(${GMX_ACCELERATION} STREQUAL "NONE")
553 message(WARNING "FORTRAN is incompatible with threads. Disable threads or FORTRAN kernels")
561 # Process QM/MM Settings
562 string(TOUPPER ${GMX_QMMM_PROGRAM} ${GMX_QMMM_PROGRAM})
563 if(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
564 set(GMX_QMMM_GAUSSIAN 1)
565 elseif(${GMX_QMMM_PROGRAM} STREQUAL "MOPAC")
566 set(GMX_QMMM_MOPAC 1)
567 elseif(${GMX_QMMM_PROGRAM} STREQUAL "GAMESS")
568 set(GMX_QMMM_GAMESS 1)
569 elseif(${GMX_QMMM_PROGRAM} STREQUAL "ORCA")
571 elseif(${GMX_QMMM_PROGRAM} STREQUAL "NONE")
573 else(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
574 MESSAGE(FATAL_ERROR "Invalid QM/MM program option: ${GMX_QMMM_PROGRAM}. Choose one of: Gaussian, Mopac, Gamess, Orca, None")
575 endif(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
577 # Process FFT library settings - if not OpenMM build
578 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
581 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
582 # MESSAGE(STATUS "Using external FFT library - fftw3")
584 find_package(FFTW3 REQUIRED)
585 include_directories(${FFTW3_INCLUDE_DIR})
586 set(FFT_LIBRARIES ${FFTW3_LIBRARIES})
589 find_package(FFTW3F REQUIRED)
590 include_directories(${FFTW3F_INCLUDE_DIR})
591 set(FFT_LIBRARIES ${FFTW3F_LIBRARIES})
592 set(PKG_FFT "fftw3f")
595 if(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
596 MESSAGE(FATAL_ERROR "Cannot find fftw3 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
597 endif(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
601 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
602 # MESSAGE(STATUS "Using external FFT library - fftw2")
604 find_package(FFTW2 REQUIRED)
606 find_package(FFTW2F REQUIRED)
610 MESSAGE(FATAL_ERROR "Cannot find fftw2 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
611 endif(NOT FFTW2_FOUND)
612 include_directories(${FFTW2_INCLUDE_DIR})
613 set(FFT_LIBRARIES ${FFTW2_LIBRARIES})
614 set(PKG_FFT_LIBS ${FFTW2_LIBRARIES})
616 if("${FFTW2_LIBRARIES}" MATCHES "dfftw")
617 set(FFTW2_NAME_DFFTW 1)
618 elseif("${FFTW2_LIBRARIES}" MATCHES "sfftw")
619 set(FFTW2_NAME_SFFTW 1)
620 else("${FFTW2_LIBRARIES}" MATCHES "dfftw")
621 set(FFTW2_NAME_FFTW 1)
622 endif("${FFTW2_LIBRARIES}" MATCHES "dfftw")
625 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
626 # MESSAGE(STATUS "Using external FFT library - Intel MKL")
627 find_package(MKL REQUIRED)
628 include_directories(${MKL_INCLUDE_DIR})
629 set(FFT_LIBRARIES ${MKL_LIBRARIES})
630 set(PKG_FFT_LIBS ${MKL_LIBRARIES})
635 #elseif(${GMX_FFT_LIBRARY} STREQUAL "ACML")
636 # MESSAGE(STATUS "Using external FFT library - AMD core math library")
637 # set(GMX_FFT_ACML 1)
638 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
639 MESSAGE(STATUS "Using internal FFT library - fftpack")
640 set(GMX_FFT_FFTPACK 1)
641 else(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
642 MESSAGE(FATAL_ERROR "Invalid FFT library setting: ${GMX_FFT_LIBRARY}. Choose one of: fftw3, fftw2, mkl, acml, fftpack")
643 endif(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
645 # MKL has BLAS/LAPACK routines
646 if(HAVE_MKL OR ACCELERATE_FRAMEWORK)
647 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use external BLAS instead of built-in")
648 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use external LAPACK instead of built-in")
649 else(HAVE_MKL OR ACCELERATE_FRAMEWORK)
650 set(GMX_EXTERNAL_BLAS FALSE CACHE BOOL "Use external LAPACK instead of built-in")
651 set(GMX_EXTERNAL_LAPACK FALSE CACHE BOOL "Use external LAPACK instead of built-in")
652 endif(HAVE_MKL OR ACCELERATE_FRAMEWORK)
653 mark_as_advanced(GMX_EXTERNAL_LAPACK)
654 mark_as_advanced(GMX_EXTERNAL_BLAS)
656 # Math and thread libraries must often come after all others when linking...
658 list(APPEND GMX_EXTRA_LIBRARIES m)
664 set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
665 "Path to swindirect.h")
666 include_directories(${COREWRAP_INCLUDE_DIR})
669 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
670 # these are set after everything else
671 if (NOT DEFINED GROMACS_C_FLAGS_SET)
672 set(GROMACS_C_FLAGS_SET true CACHE INTERNAL "Whether to reset the C flags"
674 set(CMAKE_C_FLAGS "${GROMACS_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
675 "Flags used by the compiler during all build types" FORCE)
676 set(CMAKE_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING
677 "Flags used by the compiler during all build types" FORCE)
678 set(CMAKE_EXE_LINKER_FLAGS
679 "${GROMACS_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
680 CACHE STRING "Linker flags" FORCE)
681 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
683 ########################################################################
684 # Specify install locations and which subdirectories to process #
685 ########################################################################
686 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
687 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
688 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/gromacs)
689 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
690 set(INCL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
692 set(GMXLIBDIR ${DATA_INSTALL_DIR}/top)
694 ##################################################################
695 # Shared library settings - Darwin uses INSTALL_NAME_DIR instead!
696 ##################################################################
697 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
698 set(CMAKE_SKIP_BUILD_RPATH FALSE)
699 set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
700 set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
701 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
704 add_subdirectory(share)
705 add_subdirectory(include)
706 add_subdirectory(man)
707 add_subdirectory(src)
708 add_subdirectory(scripts)
710 #######################
712 #######################
714 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
715 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
717 ###########################
718 ADD_CUSTOM_TARGET(uninstall
719 "${CMAKE_COMMAND}" -P
720 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
721 ###########################
724 ########################################################################
726 ########################################################################
729 mark_as_advanced(BUILD_TESTING)
732 add_test(TestBuildAll make)
733 add_subdirectory(tests)