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)
43 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
44 set(CPACK_PACKAGE_VENDOR "gromacs.org")
45 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation")
46 set(CPACK_SET_DESTDIR "ON")
47 set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
48 set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt")
49 # Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this...
50 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/admin/InstallLicense.txt")
51 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
53 #must come after all cpack settings!
56 ########################################################################
57 # Check and warn if cache generated on a different host is being reused
58 ########################################################################
60 execute_process(COMMAND hostname
61 OUTPUT_VARIABLE TMP_HOSTNAME
62 OUTPUT_STRIP_TRAILING_WHITESPACE)
63 if(GMX_BUILD_HOSTNAME AND NOT "${GMX_BUILD_HOSTNAME}" STREQUAL "${TMP_HOSTNAME}")
65 The CMake cache, probably generated on a different host (${GMX_BUILD_HOSTNAME}),
66 is being reused! This could lead to inconsitencies; therefore, it is
67 recommended to regenerate the cache!")
69 set(GMX_BUILD_HOSTNAME "${TMP_HOSTNAME}" CACHE INTERNAL
70 "Hostname of the machine where the cache was generated.")
73 ########################################################################
74 # Fix stupid flags on MSVC
75 ########################################################################
76 SET(SHARED_LIBS_DEFAULT ON)
77 IF(CMAKE_GENERATOR MATCHES "Visual Studio")
78 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
79 SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
80 STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
81 SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
82 SET(SHARED_LIBS_DEFAULT OFF)
83 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
85 set(GMX_EXTRA_LIBRARIES)
89 ######################################################################
91 # these need ot be done early (before further tests).
92 #####################################################################
94 include(CheckCCompilerFlag)
95 include(CheckCXXCompilerFlag)
100 ########################################################################
101 # User input options #
102 ########################################################################
103 option(GMX_DOUBLE "Use double precision (much slower, use only if you really need it)" OFF)
104 option(GMX_MPI "Build a parallel (message-passing) version of GROMACS" OFF)
105 option(GMX_THREADS "Build a parallel (thread-based) version of GROMACS (cannot be combined with MPI yet)" ON)
106 option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
107 mark_as_advanced(GMX_SOFTWARE_INVSQRT)
108 option(GMX_POWERPC_INVSQRT "Use PowerPC hardware 1/sqrt" OFF)
109 mark_as_advanced(GMX_POWERPC_INVSQRT)
110 option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
111 mark_as_advanced(GMX_FAHCORE)
112 option(GMX_OPENMM "Accelerated execution on GPUs through the OpenMM library (rerun cmake after changing to see relevant options)" OFF)
113 set(GMX_ACCELERATION "auto"
114 CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran")
116 set(GMX_FFT_LIBRARY "fftw3"
117 CACHE STRING "FFT library choices: fftw3,fftw2,mkl,fftpack[built-in]")
118 option(GMX_DISABLE_FFTW_MEASURE
119 "Do not optimize FFTW setups (not needed with SSE)" OFF)
120 mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
121 set(GMX_QMMM_PROGRAM "none"
122 CACHE STRING "QM package choices: none,gaussian,mopac,gamess,orca")
123 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
124 mark_as_advanced(GMX_BROKEN_CALLOC)
125 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic with MPI, Windows)" ${SHARED_LIBS_DEFAULT})
126 option(GMX_MPI_IN_PLACE "Enable MPI_IN_PLACE for MPIs that have it defined" ON)
127 mark_as_advanced(GMX_MPI_IN_PLACE)
128 option(GMX_DLOPEN "Compile with dlopen, needed to read VMD supported file formats" ON)
129 mark_as_advanced(GMX_DLOPEN)
132 option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
133 mark_as_advanced(GMX_IA32_ASM)
134 option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
135 mark_as_advanced(GMX_X86_64_ASM)
137 option(USE_VERSION_H "Generate development version string/information" ON)
138 mark_as_advanced(USE_VERSION_H)
140 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)
142 if(UNIX AND NOT APPLE)
143 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)
144 mark_as_advanced(GMX_PREFER_STATIC_LIBS)
147 ########################################################################
148 # Set up binary and library suffixing
149 ########################################################################
150 set(GMX_BINARY_SUFFIX "" CACHE STRING "Suffix for GROMACS binaries (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
151 set(GMX_LIBS_SUFFIX ""
152 CACHE STRING "Suffix for GROMACS libs (default: _d for double, _mpi for MPI, _mpi_d for MPI and double).")
153 if (GMX_DEFAULT_SUFFIX)
154 set(GMX_BINARY_SUFFIX "")
155 set(GMX_LIBS_SUFFIX "")
157 set(GMX_BINARY_SUFFIX "_mpi")
158 set(GMX_LIBS_SUFFIX "_mpi")
161 set (GMX_BINARY_SUFFIX "${GMX_BINARY_SUFFIX}_d")
162 set (GMX_LIBS_SUFFIX "${GMX_LIBS_SUFFIX}_d")
165 set (GMX_BINARY_SUFFIX "-gpu")
166 set (GMX_LIBS_SUFFIX "_gpu")
168 mark_as_advanced(FORCE GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
169 message(STATUS "Using default binary suffix: \"${GMX_BINARY_SUFFIX}\"")
170 message(STATUS "Using default library suffix: \"${GMX_LIBS_SUFFIX}\"")
171 else(GMX_DEFAULT_SUFFIX)
172 mark_as_advanced(CLEAR GMX_BINARY_SUFFIX GMX_LIBS_SUFFIX)
173 message(STATUS "Using manually set binary suffix: \"${GMX_BINARY_SUFFIX}\"")
174 message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"")
175 endif(GMX_DEFAULT_SUFFIX)
179 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE")
181 if(GMX_SOFTWARE_INVSQRT)
182 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT")
183 endif(GMX_SOFTWARE_INVSQRT)
184 if(GMX_POWERPC_INVSQRT)
185 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_POWERPC_INVSQRT")
186 endif(GMX_POWERPC_INVSQRT)
188 ########################################################################
189 #Process MPI settings
190 ########################################################################
191 include(CheckCSourceCompiles) # for gmxTestMPI_IN_PLACE
194 There are known problems with some MPI implementations:
195 OpenMPI version < 1.4.1
196 MVAPICH2 version <= 1.4.1 *")
198 #message(FATAL_ERROR "Thread-based parallelization conflicts with MPI.")
199 set(GMX_THREADS OFF CACHE BOOL
200 "Thread-based parallelization conflicts with MPI." FORCE)
204 set(GROMACS_C_FLAGS ${GROMACS_FLAGS} ${MPI_COMPILE_FLAGS})
205 set(GROMACS_LINKER_FLAGS ${GROMACS_LINKER_FLAGS} ${MPI_LINK_FLAGS})
207 include_directories(${MPI_INCLUDE_PATH})
208 list(APPEND GMX_EXTRA_LIBRARIES ${MPI_LIBRARIES})
209 add_definitions( -DMPI ) #for FAHCORE
210 include(gmxTestMPI_IN_PLACE)
211 if (GMX_MPI_IN_PLACE)
212 gmx_test_mpi_in_place(MPI_IN_PLACE_EXISTS)
213 endif (GMX_MPI_IN_PLACE)
215 message(FATAL_ERROR "MPI support requested, but no MPI compiler found.")
217 include(gmxTestCatamount)
218 gmx_test_catamount(GMX_CRAY_XT3)
220 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
225 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")
229 #######################################################################
230 # Check for options incompatible with OpenMM build #
231 #######################################################################
233 cmake_minimum_required(VERSION 2.6.4)
234 # we'll use the built-in fft to avoid unnecessary dependencies
235 string(TOUPPER ${GMX_FFT_LIBRARY} GMX_FFT_LIBRARY)
236 if(NOT ${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
237 message(STATUS "No external FFT libraries needed for the OpenMM build, switching to fftpack!")
238 set(GMX_FFT_LIBRARY "fftpack" CACHE STRING
239 "No external FFT libraries needed for the OpenMM build, switching to fftpack!" FORCE)
242 message(FATAL_ERROR "The OpenMM build is not compatible with MPI!")
245 message(STATUS "Threads are not compatible with OpenMM build, disabled!")
246 set(GMX_THREADS OFF CACHE BOOL
247 "Threads are not compatible with OpenMM build, disabled!" FORCE)
249 if(GMX_SOFTWARE_INVSQRT)
250 set(GMX_SOFTWARE_INVSQRT OFF CACHE STRING
251 "The OpenMM build does not need GROMACS software 1/sqrt!" FORCE)
252 endif(GMX_SOFTWARE_INVSQRT)
253 string(TOUPPER ${GMX_ACCELERATION} GMX_ACCELERATION)
254 if(NOT GMX_ACCELERATION STREQUAL "NONE")
255 message(STATUS "Switching off CPU-based acceleration, the OpenMM build does not support/need any!")
256 set(GMX_ACCELERATION "none" CACHE STRING
257 "Switching off CPU-based acceleration, the OpenMM build does not support/need any!" FORCE)
260 message(FATAL_ERROR "The OpenMM build does not support FAH build!")
263 message(FATAL_ERROR "The OpenMM-build does not support double precision calculations!")
265 # mark as advanced the unused variables
266 mark_as_advanced(FORCE GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
267 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
269 mark_as_advanced(CLEAR GMX_ACCELERATION GMX_MPI GMX_FFT_LIBRARY
270 GMX_QMMM_PROGRAM GMX_THREADS GMX_DOUBLE)
274 ########################################################################
275 # Basic system tests (standard libraries, headers, functions, types) #
276 ########################################################################
277 include(CheckIncludeFiles)
278 check_include_files(string.h HAVE_STRING_H)
279 check_include_files(math.h HAVE_MATH_H)
280 check_include_files(limits.h HAVE_LIMITS_H)
281 check_include_files(memory.h HAVE_MEMORY_H)
282 check_include_files(unistd.h HAVE_UNISTD_H)
283 check_include_files(pwd.h HAVE_PWD_H)
284 check_include_files(stdint.h HAVE_STDINT_H)
285 check_include_files(stdlib.h HAVE_STDLIB_H)
286 check_include_files(pthread.h HAVE_PTHREAD_H)
287 check_include_files(dirent.h HAVE_DIRENT_H)
288 check_include_files(inttypes.h HAVE_INTTYPES_H)
289 check_include_files(regex.h HAVE_REGEX_H)
290 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
291 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
292 check_include_files(sys/time.h HAVE_SYS_TIME_H)
293 check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
294 check_include_files("rpc/rpc.h;rpc/xdr.h" HAVE_RPC_XDR_H)
296 check_include_files(xmmintrin.h HAVE_XMMINTRIN_H)
297 check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
298 check_include_files(pmmintrin.h HAVE_PMMINTRIN_H)
299 check_include_files(smmintrin.h HAVE_SMMINTRIN_H)
300 check_include_files(io.h HAVE_IO_H)
303 include(CheckFunctionExists)
304 check_function_exists(strcasecmp HAVE_STRCASECMP)
305 check_function_exists(strdup HAVE_STRDUP)
306 check_function_exists(vprintf HAVE_VPRINTF)
307 check_function_exists(memcmp HAVE_MEMCMP)
308 check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
309 check_function_exists(memalign HAVE_MEMALIGN)
310 check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
311 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
312 check_function_exists(isnan HAVE_ISNAN)
313 check_function_exists(_isnan HAVE__ISNAN)
314 check_function_exists(isfinite HAVE_ISFINITE)
315 check_function_exists(_isfinite HAVE__ISFINITE)
316 check_function_exists(fsync HAVE_FSYNC)
317 check_function_exists(_fileno HAVE__FILENO)
318 check_function_exists(fileno HAVE_FILENO)
319 check_function_exists(_commit HAVE__COMMIT)
321 include(CheckLibraryExists)
322 check_library_exists(m sqrt "" HAVE_LIBM)
323 check_library_exists(m cbrt "" HAVE_CBRT)
326 include(CheckTypeSize)
328 check_type_size("bool" SIZEOF_BOOL) # will also set HAVE_BOOL
329 check_type_size("int" SIZEOF_INT)
330 check_type_size("long int" SIZEOF_LONG_INT)
331 check_type_size("long long int" SIZEOF_LONG_LONG_INT)
332 check_type_size("off_t" SIZEOF_OFF_T)
333 check_type_size("void *" SIZEOF_VOIDP)
335 if (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
337 else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
338 set(GMX_64_BIT FALSE)
339 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
341 # Check for some basic types that we *need*, so set these to int if they are not present
342 check_type_size(uid_t uid_t)
349 check_type_size(gid_t gid_t)
356 check_type_size(size_t size_t)
363 check_type_size(off_t off_t)
370 include(TestBigEndian)
371 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
376 ########################################################################
377 # Find external packages #
378 ########################################################################
379 if(UNIX AND NOT APPLE)
380 if(GMX_PREFER_STATIC_LIBS)
381 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
382 if(BUILD_SHARED_LIBS)
383 message(WARNING "Static libraries requested, the GROMACS libraries will also be build static (BUILD_SHARED_LIBS=OFF)")
384 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Enable shared libraries (can be problematic with MPI, Windows)" FORCE)
389 option(GMX_XML "Use libxml2 to parse xml files" ON)
391 find_package(LibXml2)
394 include_directories(${LIBXML2_INCLUDE_DIR})
395 set(PKG_XML libxml-2.0)
396 set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
401 option(GMX_GSL "Add support for gsl" OFF)
406 include_directories(${GSL_INCLUDE_DIR})
412 option(GMX_X11 "Use X window system" OFF)
415 # X11 includes/libraries are only set in the ngmx subdirectory!
422 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREADS")
424 set(THREAD_MPI_LIB thread_mpi)
426 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
427 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
428 message(FATAL_ERROR "FFTW2 can't be used with threads. Try fftw3 or mkl.")
433 set(CUDA_BUILD_EMULATION OFF)
434 find_package(CUDA 3.1 REQUIRED)
435 add_definitions(-DGMX_OPENMM)
436 if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
437 set(CUDA_VERBOSE_BUILD ON)
443 find_library(ACCELERATE_FRAMEWORK Accelerate)
444 list(APPEND GMX_EXTRA_LIBRARIES ${ACCELERATE_FRAMEWORK})
447 # only bother with finding git and using version.h if the source is a git repo
448 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
450 # We need at least git v1.5.1 be able to parse git's date output. If not
451 # fund or the version is too small, we can't generate version information.
452 find_package(Git 1.5.1)
453 # this should at some point become VERSION_LESS
454 if(NOT Git_FOUND OR Git_VERSION STRLESS "1.5.1")
455 message("No compatible git version found, won't be able to generate proper development version information.")
456 set(USE_VERSION_H OFF)
460 set(USE_VERSION_H OFF)
464 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
469 find_package(Doxygen)
471 ########################################################################
472 # Generate development version info for cache
473 ########################################################################
474 # set(GEN_VERSION_INFO_INTERNAL "ON")
475 # include(gmxGenerateVersionString)
477 ########################################################################
478 # Our own GROMACS tests
479 ########################################################################
481 add_definitions( -DHAVE_CONFIG_H )
482 include_directories(${CMAKE_SOURCE_DIR}/src)
483 # Required for config.h, maybe should only be set in src/CMakeLists.txt
484 include_directories(${CMAKE_BINARY_DIR}/src)
485 # Required for now to make old code compile
486 include_directories(${CMAKE_SOURCE_DIR}/src/gromacs/legacyheaders)
488 include(gmxCheckBuildUserTime)
489 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
491 include(gmxTestFloatFormat)
492 gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
493 GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
494 GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
496 include(gmxTestLargeFiles)
497 gmx_test_large_files(GMX_LARGEFILES)
498 check_function_exists(fseeko HAVE_FSEEKO)
500 include(gmxTestSignal)
501 gmx_test_retsigtype(RETSIGTYPE)
502 gmx_test_sigusr1(HAVE_SIGUSR1)
504 include(gmxTestInline)
505 gmx_test_inline(INLINE_KEYWORD)
507 include(gmxTestRestrict)
508 gmx_test_inline(RESTRICT_KEYWORD)
510 include(gmxTestPipes)
511 gmx_test_pipes(HAVE_PIPES)
513 include(gmxTestInlineASM)
514 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
515 gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
517 # turn on SSE if supported with reasonable defaults.
518 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
519 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x64|x86_64|AMD64|amd64)")
521 set(GMX_ACCELERATION "SSE" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
524 set(GMX_X86_64_ASM ON CACHE BOOL "Add SSE assembly files for x86_64" FORCE)
526 set(GMX_IA32_ASM ON CACHE BOOL "Add SSE assembly files for i386" FORCE)
529 # Determine the assembler/compiler to use
531 set(GMX_ACCELERATION "none" CACHE STRING "Accelerated kernels. Pick one of: auto, none, SSE, BlueGene, Power6, ia64, altivec, fortran" FORCE)
533 endif (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
536 gmx_test_xdr(GMX_SYSTEM_XDR)
537 if(NOT GMX_SYSTEM_XDR)
538 set(GMX_INTERNAL_XDR 1)
539 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
540 endif(NOT GMX_SYSTEM_XDR)
542 # Process nonbonded accelerated kernels settings
543 string(TOUPPER ${GMX_ACCELERATION} ${GMX_ACCELERATION})
544 if(${GMX_ACCELERATION} STREQUAL "NONE")
546 elseif(${GMX_ACCELERATION} STREQUAL "SSE")
548 if(CMAKE_GENERATOR MATCHES "Visual Studio")
549 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" ON)
551 option(GMX_ASM_USEASM-NASM "Use Nasm for assembly instead of compiler (necessary on windows)" OFF)
553 mark_as_advanced(GMX_ASM_USEASM-NASM)
556 # for 32-bit compiles, we might need to turn on sse
557 CHECK_C_COMPILER_FLAG("-msse2" XFLAGS_SSE)
559 set(GROMACS_C_FLAGS "-msse2 ${GROMACS_C_FLAGS}")
561 CHECK_CXX_COMPILER_FLAG("-msse2" XXFLAGS_SSE)
563 set(GROMACS_CXX_FLAGS "-msse2 ${GROMACS_CXX_FLAGS}")
565 endif (NOT GMX_64_BIT)
573 elseif(GMX_X86_64_ASM)
575 set(GMX_X86_64_SSE2 1)
577 set(GMX_X86_64_SSE 1)
581 # if(HAVE_PMMINTRIN_H)
583 # endif(HAVE_PMMINTRIN_H)
584 # if(HAVE_SMMINTRIN_H)
586 # endif(HAVE_SMMINTRIN_H)
588 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
590 #these are switch on by default sometimes
592 set(GMX_GMX_X86_64_ASM 0)
593 elseif(${GMX_ACCELERATION} STREQUAL "BLUEGENE")
594 # GMX_ACCELERATION=BlueGene should be set in the Toolchain-BlueGene?-???.cmake file
595 message(STATUS "Configuring for BlueGene")
597 if (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
598 set(SHARED_LIBS_DEFAULT OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
599 set(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared libraries not compatible with BlueGene/L, disabled!" FORCE)
600 endif (${CMAKE_SYSTEM_NAME} STREQUAL "BlueGeneL")
601 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene" FORCE)
602 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on BlueGene" FORCE)
603 set(GMX_X11 OFF CACHE BOOL "X11 not compatible with BlueGene, disabled!" FORCE)
604 set(GMX_THREADS OFF CACHE BOOL "Threads not compatible with BlueGene, disabled!" FORCE)
605 set(GMX_MPI ON CACHE BOOL "Use MPI on BlueGene" FORCE)
606 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use MASSV for BLAS on BlueGene" FORCE)
607 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use MASSV for LAPACK on BlueGene" FORCE)
608 list(APPEND GMX_EXTRA_LIBRARIES massv)
609 elseif(${GMX_ACCELERATION} STREQUAL "POWER6")
611 set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on Power6" FORCE)
612 set(GMX_POWERPC_INVSQRT ON CACHE BOOL "Use hardware reciprocal square root on Power6" FORCE)
613 elseif(${GMX_ACCELERATION} STREQUAL "IA64")
615 set(DISABLE_WATERWATER_NLIST 1)
616 set(DISABLE_WATER_NLIST 1)
617 elseif(${GMX_ACCELERATION} STREQUAL "ALTIVEC")
618 check_include_files(altivec.h HAVE_ALTIVEC_H)
620 set(GMX_PPC_ALTIVEC 1)
621 endif(HAVE_ALTIVEC_H)
622 else(${GMX_ACCELERATION} STREQUAL "NONE")
623 MESSAGE(FATAL_ERROR "Unrecognized option for accelerated kernels: ${GMX_ACCELERATION}. Pick one of auto, none, SSE, Fortran, BlueGene, Power6, ia64, altivec")
624 endif(${GMX_ACCELERATION} STREQUAL "NONE")
626 if(GMX_FORTRAN OR GMX_POWER6)
628 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).")
630 enable_language(Fortran)
631 include(FortranCInterface)
632 discover_fortran_mangling(prefix isupper suffix extra_under_score found)
633 if(extra_under_score)
635 endif(extra_under_score)
637 set(prefix "${prefix} ##")
641 set(F77_FUNCDEF "${prefix} NAME ## ${suffix}")
642 set(F77_FUNCDEF_ "${prefix} NAME ## ${suffix}${extrasuffix}")
644 set(F77_FUNCDEF "${prefix} name ## ${suffix}")
645 set(F77_FUNCDEF_ "${prefix} name ## ${suffix}${extrasuffix}")
647 else(GMX_FORTRAN OR GMX_POWER6)
648 set(F77_FUNCDEF "name ## _")
649 set(F77_FUNCDEF_ "name ## _")
650 endif(GMX_FORTRAN OR GMX_POWER6)
652 # Process QM/MM Settings
653 string(TOUPPER ${GMX_QMMM_PROGRAM} ${GMX_QMMM_PROGRAM})
654 if(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
655 set(GMX_QMMM_GAUSSIAN 1)
656 elseif(${GMX_QMMM_PROGRAM} STREQUAL "MOPAC")
657 set(GMX_QMMM_MOPAC 1)
658 elseif(${GMX_QMMM_PROGRAM} STREQUAL "GAMESS")
659 set(GMX_QMMM_GAMESS 1)
660 elseif(${GMX_QMMM_PROGRAM} STREQUAL "ORCA")
662 elseif(${GMX_QMMM_PROGRAM} STREQUAL "NONE")
664 else(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
665 MESSAGE(FATAL_ERROR "Invalid QM/MM program option: ${GMX_QMMM_PROGRAM}. Choose one of: Gaussian, Mopac, Gamess, Orca, None")
666 endif(${GMX_QMMM_PROGRAM} STREQUAL "GAUSSIAN")
668 # Process FFT library settings - if not OpenMM build
669 string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
672 if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
673 # MESSAGE(STATUS "Using external FFT library - fftw3")
675 find_package(FFTW3 REQUIRED)
676 include_directories(${FFTW3_INCLUDE_DIR})
677 set(FFT_LIBRARIES ${FFTW3_LIBRARIES})
680 find_package(FFTW3F REQUIRED)
681 include_directories(${FFTW3F_INCLUDE_DIR})
682 set(FFT_LIBRARIES ${FFTW3F_LIBRARIES})
683 set(PKG_FFT "fftw3f")
686 if(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
687 MESSAGE(FATAL_ERROR "Cannot find fftw3 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
688 endif(NOT FFTW3_FOUND AND NOT FFTW3F_FOUND)
692 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTW2")
693 # MESSAGE(STATUS "Using external FFT library - fftw2")
695 find_package(FFTW2 REQUIRED)
697 find_package(FFTW2F REQUIRED)
701 MESSAGE(FATAL_ERROR "Cannot find fftw2 (with correct precision). Fix it, choose another FFT library, or use the Gromacs built-in fftpack (slower)!")
702 endif(NOT FFTW2_FOUND)
703 include_directories(${FFTW2_INCLUDE_DIR})
704 set(FFT_LIBRARIES ${FFTW2_LIBRARIES})
705 set(PKG_FFT_LIBS ${FFTW2_LIBRARIES})
707 if("${FFTW2_LIBRARIES}" MATCHES "dfftw")
708 set(FFTW2_NAME_DFFTW 1)
709 elseif("${FFTW2_LIBRARIES}" MATCHES "sfftw")
710 set(FFTW2_NAME_SFFTW 1)
711 else("${FFTW2_LIBRARIES}" MATCHES "dfftw")
712 set(FFTW2_NAME_FFTW 1)
713 endif("${FFTW2_LIBRARIES}" MATCHES "dfftw")
716 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
717 # MESSAGE(STATUS "Using external FFT library - Intel MKL")
718 find_package(MKL REQUIRED)
719 include_directories(${MKL_INCLUDE_DIR})
720 set(FFT_LIBRARIES ${MKL_LIBRARIES})
721 set(PKG_FFT_LIBS ${MKL_LIBRARIES})
726 #elseif(${GMX_FFT_LIBRARY} STREQUAL "ACML")
727 # MESSAGE(STATUS "Using external FFT library - AMD core math library")
728 # set(GMX_FFT_ACML 1)
729 elseif(${GMX_FFT_LIBRARY} STREQUAL "FFTPACK")
730 MESSAGE(STATUS "Using internal FFT library - fftpack")
731 set(GMX_FFT_FFTPACK 1)
732 else(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
733 MESSAGE(FATAL_ERROR "Invalid FFT library setting: ${GMX_FFT_LIBRARY}. Choose one of: fftw3, fftw2, mkl, acml, fftpack")
734 endif(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
736 # MKL has BLAS/LAPACK routines
737 if(HAVE_MKL OR ACCELERATE_FRAMEWORK)
738 set(GMX_EXTERNAL_BLAS TRUE CACHE BOOL "Use external BLAS instead of built-in")
739 set(GMX_EXTERNAL_LAPACK TRUE CACHE BOOL "Use external LAPACK instead of built-in")
740 else(HAVE_MKL OR ACCELERATE_FRAMEWORK)
741 set(GMX_EXTERNAL_BLAS FALSE CACHE BOOL "Use external LAPACK instead of built-in")
742 set(GMX_EXTERNAL_LAPACK FALSE CACHE BOOL "Use external LAPACK instead of built-in")
743 if(GMX_EXTERNAL_BLAS)
744 #FindBLAS needs Fortran
745 enable_language(Fortran)
746 find_package(BLAS REQUIRED)
747 list(APPEND GMX_EXTRA_LIBRARIES ${BLAS_LIBRARIES})
748 endif(GMX_EXTERNAL_BLAS)
749 if(GMX_EXTERNAL_LAPACK)
750 #FindLAPACK needs Fortran
751 enable_language(Fortran)
752 find_package(LAPACK REQUIRED)
753 list(APPEND GMX_EXTRA_LIBRARIES ${LAPACK_LIBRARIES})
754 endif(GMX_EXTERNAL_LAPACK)
755 endif(HAVE_MKL OR ACCELERATE_FRAMEWORK)
756 mark_as_advanced(GMX_EXTERNAL_LAPACK)
757 mark_as_advanced(GMX_EXTERNAL_BLAS)
759 # Math and thread libraries must often come after all others when linking...
761 list(APPEND GMX_EXTRA_LIBRARIES m)
765 set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
766 "Path to swindirect.h")
767 include_directories(${COREWRAP_INCLUDE_DIR})
770 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
771 # these are set after everything else
772 if (NOT DEFINED GROMACS_C_FLAGS_SET)
773 set(GROMACS_C_FLAGS_SET true CACHE INTERNAL "Whether to reset the C flags"
775 set(CMAKE_C_FLAGS "${GROMACS_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
776 "Flags used by the compiler during all build types" FORCE)
777 set(CMAKE_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING
778 "Flags used by the compiler during all build types" FORCE)
779 set(CMAKE_EXE_LINKER_FLAGS
780 "${GROMACS_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
781 CACHE STRING "Linker flags" FORCE)
782 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
784 ########################################################################
785 # Specify install locations and which subdirectories to process #
786 ########################################################################
788 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
790 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
792 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
793 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/gromacs)
794 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
795 set(INCL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
797 set(GMXLIBDIR ${DATA_INSTALL_DIR}/top)
799 ##################################################################
800 # Shared library settings - Darwin uses INSTALL_NAME_DIR instead!
801 ##################################################################
802 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
803 set(CMAKE_SKIP_BUILD_RPATH FALSE)
804 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
805 set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
806 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
809 add_subdirectory(share)
810 add_subdirectory(man)
811 add_subdirectory(src)
812 add_subdirectory(scripts)
814 #######################
816 #######################
818 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
819 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
821 ###########################
822 ADD_CUSTOM_TARGET(uninstall
823 "${CMAKE_COMMAND}" -P
824 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
825 ###########################
827 ########################################################################
828 # Doxygen configuration
829 ########################################################################
831 FILE(GLOB NB_KERNEL_DIRS src/gromacs/gmxlib/nonbonded/nb_kernel_*/)
832 LIST(REMOVE_ITEM NB_KERNEL_DIRS
833 ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_c)
834 FOREACH(NB_KERNEL_DIR ${NB_KERNEL_DIRS})
835 SET(NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN
836 "${NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN} \\\n ${NB_KERNEL_DIR}")
837 ENDFOREACH(NB_KERNEL_DIR)
838 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.cmakein
839 ${CMAKE_BINARY_DIR}/Doxyfile)
840 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile-lib.cmakein
841 ${CMAKE_BINARY_DIR}/Doxyfile-lib)
842 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile-user.cmakein
843 ${CMAKE_BINARY_DIR}/Doxyfile-user)
844 endif (DOXYGEN_FOUND)
847 ########################################################################
849 ########################################################################
852 mark_as_advanced(BUILD_TESTING)
855 add_subdirectory(tests)