Merge release-4-6 into master
[alexxy/gromacs.git] / CMakeLists.txt
index 86930a38b24f346d2ff9cfa30f05296e854f7fe4..d0e7869bb21f6cbe1c30b90e5793aa5432981527 100644 (file)
@@ -14,7 +14,7 @@ mark_as_advanced(DART_ROOT)
 # machine with no git. 
 #
 # NOTE: when releasing the "-dev" suffix needs to be stripped off!
-set(PROJECT_VERSION "4.6-dev")
+set(PROJECT_VERSION "5.0-dev")
 set(CUSTOM_VERSION_STRING ""
     CACHE STRING "Custom version string (if empty, use hard-coded default)")
 mark_as_advanced(CUSTOM_VERSION_STRING)
@@ -40,6 +40,7 @@ if(NOT CMAKE_BUILD_TYPE)
 endif(NOT CMAKE_BUILD_TYPE)
 
 enable_language(C)
+enable_language(CXX)
 
 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 set(CPACK_PACKAGE_VENDOR "gromacs.org")
@@ -79,6 +80,9 @@ IF( WIN32 AND NOT CYGWIN)
   option(GMX_PREFER_STATIC_LIBS "When finding libraries prefer static system libraries (MT instead of MD)!" ON)
   mark_as_advanced(GMX_PREFER_STATIC_LIBS)
   SET(SHARED_LIBS_DEFAULT OFF)  #is currently not working on Windows
+  # This makes windows.h not declare min/max as macros that would break
+  # C++ code using std::min/std::max.
+  add_definitions(-DNOMINMAX)
 
   IF (GMX_PREFER_STATIC_LIBS)
     #Only setting Debug and Release flags. Others configurations current not used.
@@ -278,43 +282,22 @@ endif(GMX_OPENMM)
 # Basic system tests (standard libraries, headers, functions, types)   #
 ########################################################################
 include(CheckIncludeFiles)
-check_include_files(string.h     HAVE_STRING_H)
-check_include_files(math.h       HAVE_MATH_H)
-check_include_files(limits.h     HAVE_LIMITS_H)
-check_include_files(memory.h     HAVE_MEMORY_H)
 check_include_files(unistd.h    HAVE_UNISTD_H)
-check_include_files(direct.h    HAVE_DIRECT_H)
 check_include_files(pwd.h        HAVE_PWD_H)
-check_include_files(stdint.h    HAVE_STDINT_H)
-check_include_files(stdlib.h    HAVE_STDLIB_H)
 check_include_files(pthread.h    HAVE_PTHREAD_H)
 check_include_files(dirent.h     HAVE_DIRENT_H)
-check_include_files(inttypes.h   HAVE_INTTYPES_H)
 check_include_files(regex.h      HAVE_REGEX_H)
 check_include_files(sys/types.h  HAVE_SYS_TYPES_H)
-check_include_files(sys/stat.h   HAVE_SYS_STAT_H)
 check_include_files(sys/time.h   HAVE_SYS_TIME_H)
-check_include_files(rpc/rpc.h    HAVE_RPC_RPC_H)
-check_include_files("rpc/rpc.h;rpc/xdr.h"    HAVE_RPC_XDR_H)
-# SSE support
-check_include_files(xmmintrin.h  HAVE_XMMINTRIN_H)
-check_include_files(emmintrin.h  HAVE_EMMINTRIN_H)
-check_include_files(pmmintrin.h  HAVE_PMMINTRIN_H)
-check_include_files(smmintrin.h  HAVE_SMMINTRIN_H)
 check_include_files(io.h                HAVE_IO_H)
 
 
 include(CheckFunctionExists)
-check_function_exists(strcasecmp        HAVE_STRCASECMP)
 check_function_exists(strdup            HAVE_STRDUP)
-check_function_exists(vprintf           HAVE_VPRINTF)
-check_function_exists(memcmp            HAVE_MEMCMP)
 check_function_exists(posix_memalign    HAVE_POSIX_MEMALIGN)
 check_function_exists(memalign          HAVE_MEMALIGN)
 check_function_exists(_aligned_malloc   HAVE__ALIGNED_MALLOC)
 check_function_exists(gettimeofday      HAVE_GETTIMEOFDAY)
-check_function_exists(isnan             HAVE_ISNAN)
-check_function_exists(_isnan            HAVE__ISNAN)
 check_function_exists(fsync             HAVE_FSYNC)
 check_function_exists(_fileno           HAVE__FILENO)
 check_function_exists(fileno            HAVE_FILENO)
@@ -329,7 +312,6 @@ check_library_exists(m cbrt "" HAVE_CBRT)
 
 include(CheckTypeSize)
 
-check_type_size("bool"          SIZEOF_BOOL) # will also set HAVE_BOOL
 check_type_size("int"           SIZEOF_INT) 
 check_type_size("long int"      SIZEOF_LONG_INT) 
 check_type_size("long long int" SIZEOF_LONG_LONG_INT) 
@@ -342,35 +324,6 @@ else (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
     set(GMX_64_BIT FALSE)
 endif (CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
 
-# Check for some basic types that we *need*, so set these to int if they are not present 
-check_type_size(uid_t uid_t)
-if(NOT uid_t)
-  set(uid_t int)
-else(NOT uid_t)
-  set(uid_t 0)
-endif(NOT uid_t)
-
-check_type_size(gid_t gid_t)
-if(NOT gid_t)
-  set(gid_t 1)
-else(NOT gid_t)
-  set(gid_t 0)
-endif(NOT gid_t)
-
-check_type_size(size_t size_t)
-if(NOT size_t)
-  set(size_t int)
-else(NOT size_t)
-  set(size_t 0)
-endif(NOT size_t)
-
-check_type_size(off_t off_t)
-if(NOT off_t)
-  set(off_t int)
-else(NOT off_t)
-  set(off_t 0)
-endif(NOT off_t)
-
 include(TestBigEndian)
 test_big_endian(GMX_INTEGER_BIG_ENDIAN)
 
@@ -398,7 +351,6 @@ if (GMX_XML)
     include_directories(${LIBXML2_INCLUDE_DIR})
     set(PKG_XML libxml-2.0)
     set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
-    set(HAVE_LIBXML2 1)
   endif(LIBXML2_FOUND)
 endif(GMX_XML)
 
@@ -425,6 +377,7 @@ endif(GMX_X11)
 if(GMX_THREAD_MPI)
     set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREAD_MPI")
     include(ThreadMPI)
+    tmpi_make_cxx_lib()
     set(THREAD_MPI_LIB thread_mpi)
     set(GMX_MPI 1)
     string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
@@ -486,6 +439,38 @@ else()
     set(USE_VERSION_H OFF)
 endif()
 
+option(GMX_INTERNAL_BOOST "Use minimal internal version of boost" OFF)
+if ( NOT GMX_INTERNAL_BOOST )
+  find_package( Boost 1.36.0 )
+else ( NOT GMX_INTERNAL_BOOST )
+  set (Boost_FOUND FALSE)
+endif( NOT GMX_INTERNAL_BOOST )
+
+if(Boost_FOUND)
+  include_directories(${Boost_INCLUDE_DIRS})
+else()
+  message("Boost >= 1.36 not found. Using minimal internal version. Not recommended if GROMACS is used as library!")
+  include_directories(${CMAKE_SOURCE_DIR}/src/external/boost)
+  add_definitions( -DBOOST_NO_TYPEID )  #TYPEID not supported for minimal internal version (would add significant more code)
+  # TODO: Propagate the above settings to the installed CMakeFiles.txt template
+  # (from share/template/)
+  # TODO: Reorder stuff such that INCL_INSTALL_DIR could be used here
+  set(PKG_CFLAGS "${PKG_CFLAGS} -DBOOST_NO_TYPEID -I${CMAKE_INSTALL_PREFIX}/include/gromacs/external/boost")
+  install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/external/boost/boost
+          DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gromacs/external/boost
+          COMPONENT development)
+endif()
+
+if (LIBXML2_FOUND)
+    option(GMX_BUILD_UNITTESTS "Build unit tests with BUILD_TESTING (uses Google C++ Testing and Mocking Frameworks, requires libxml2)" ON)
+else (LIBXML2_FOUND)
+    set(GMX_BUILD_UNITTESTS OFF)
+endif (LIBXML2_FOUND)
+mark_as_advanced(GMX_BUILD_UNITTESTS)
+set(MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/cmake/legacy_and_external.supp)
+
+find_package(Doxygen)
+
 ########################################################################
 # Generate development version info for cache
 ########################################################################
@@ -497,9 +482,11 @@ endif()
 ########################################################################
 
 add_definitions( -DHAVE_CONFIG_H )
+include_directories(${CMAKE_SOURCE_DIR}/src)
+# Required for config.h, maybe should only be set in src/CMakeLists.txt
 include_directories(${CMAKE_BINARY_DIR}/src)
-include_directories(${CMAKE_BINARY_DIR}/include)
-include_directories(${CMAKE_SOURCE_DIR}/include)
+# Required for now to make old code compile
+include_directories(${CMAKE_SOURCE_DIR}/src/gromacs/legacyheaders)
 
 include(gmxCheckBuildUserTime)
 gmx_check_build_user_time(BUILD_TIME BUILD_USER BUILD_MACHINE)
@@ -519,9 +506,6 @@ gmx_test_sigusr1(HAVE_SIGUSR1)
 include(gmxTestInline)
 gmx_test_inline(INLINE_KEYWORD)
 
-include(gmxTestRestrict)
-gmx_test_inline(RESTRICT_KEYWORD)
-
 include(gmxTestPipes)
 gmx_test_pipes(HAVE_PIPES)
 
@@ -530,9 +514,9 @@ gmx_test_isfinite(HAVE_ISFINITE)
 gmx_test__isfinite(HAVE__ISFINITE)
 gmx_test__finite(HAVE__FINITE)
 
-include(gmxTestInlineASM)
-gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
-gmx_test_inline_asm_msvc_x86(GMX_X86_MSVC_INLINE_ASM)
+include(gmxTestCXX11)
+gmx_test_cxx11(GMX_CXX11 CXX11_FLAG)
+set(GROMACS_CXX_FLAGS "${CXX11_FLAG} ${GROMACS_CXX_FLAGS}")
 
 # turn on SSE if supported with reasonable defaults.
 if (${GMX_ACCELERATION} STREQUAL "auto" AND NOT GMX_OPENMM)
@@ -598,13 +582,6 @@ elseif(${GMX_ACCELERATION} STREQUAL "SSE")
       endif()
     endif()
 
-#    if(HAVE_PMMINTRIN_H)
-#        set(GMX_SSE3 1)
-#    endif(HAVE_PMMINTRIN_H)
-#    if(HAVE_SMMINTRIN_H)
-#        set(GMX_SSE4_1 1)
-#    endif(HAVE_SMMINTRIN_H)
-
 elseif(${GMX_ACCELERATION} STREQUAL "FORTRAN")
     set(GMX_FORTRAN 1)
     #these are switch on by default sometimes
@@ -667,14 +644,15 @@ if(GMX_FORTRAN OR GMX_POWER6)
 
     if(isupper)
         set(F77_FUNCDEF   "${prefix} NAME ${suffix}")
-        set(F77_FUNCDEF_  "${prefix} NAME ${extrasuffix}")
+        # The underscored versions are not currently used.
+        #set(F77_FUNCDEF_  "${prefix} NAME ${extrasuffix}")
     else(isupper)
         set(F77_FUNCDEF   "${prefix} name ${suffix}")
-        set(F77_FUNCDEF_  "${prefix} name ${extrasuffix}")
+        #set(F77_FUNCDEF_  "${prefix} name ${extrasuffix}")
     endif(isupper)
 else(GMX_FORTRAN OR GMX_POWER6)
         set(F77_FUNCDEF   "name ## _")
-        set(F77_FUNCDEF_  "name ## _")
+        #set(F77_FUNCDEF_  "name ## _")
 endif(GMX_FORTRAN OR GMX_POWER6)
 
 # Process QM/MM Settings
@@ -887,7 +865,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
 endif()
 
 add_subdirectory(share)
-add_subdirectory(include)
 add_subdirectory(man)
 add_subdirectory(src)
 add_subdirectory(scripts)
@@ -905,6 +882,37 @@ ADD_CUSTOM_TARGET(uninstall
                   "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
 ###########################
 
+########################################################################
+# Doxygen configuration
+########################################################################
+if (DOXYGEN_FOUND)
+    FILE(GLOB NB_KERNEL_DIRS src/gromacs/gmxlib/nonbonded/nb_kernel_*/)
+    LIST(REMOVE_ITEM NB_KERNEL_DIRS
+         ${CMAKE_SOURCE_DIR}/src/gromacs/gmxlib/nonbonded/nb_kernel_c)
+    FOREACH(NB_KERNEL_DIR ${NB_KERNEL_DIRS})
+        SET(NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN
+            "${NB_KERNEL_DIRS_TO_IGNORE_IN_DOXYGEN} \\\n                         ${NB_KERNEL_DIR}")
+    ENDFOREACH(NB_KERNEL_DIR)
+    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.cmakein
+                   ${CMAKE_BINARY_DIR}/Doxyfile)
+    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile-lib.cmakein
+                   ${CMAKE_BINARY_DIR}/Doxyfile-lib)
+    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile-user.cmakein
+                   ${CMAKE_BINARY_DIR}/Doxyfile-user)
+    add_custom_target(doc
+      ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+      COMMENT "Generating full documentation with Doxygen" VERBATIM)
+    add_custom_target(doc-user
+      ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-user
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+      COMMENT "Generating user documentation with Doxygen" VERBATIM)
+    add_custom_target(doc-lib
+      ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-lib
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+      COMMENT "Generating libary documentation with Doxygen" VERBATIM)
+endif (DOXYGEN_FOUND)
+
 
 ########################################################################
 # Tests                                                                #
@@ -913,7 +921,7 @@ ADD_CUSTOM_TARGET(uninstall
 include(CTest)
 mark_as_advanced(BUILD_TESTING)
 IF(BUILD_TESTING)
-       enable_testing()
-       add_subdirectory(tests)
+    enable_testing()
+    add_subdirectory(tests)
 ENDIF()