simple corr
[alexxy/gromacs-testing.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.8)
2
3 project(gromacs-spacetimecorr CXX)
4
5 if (NOT CMAKE_BUILD_TYPE)
6     set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
7 endif()
8
9 # CMake modules are in a subdirectory to keep this file cleaner
10 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
11
12 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
13 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
14 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
15
16 # In principle, this could be deduced from GROMACS_IS_DOUBLE returned by
17 # find_package(GROMACS) based on the suffix alone, but it is clearer that the
18 # user explicitly sets what they want to get, and then need to provide a suffix
19 # to match.
20 option(GMX_DOUBLE "Use double precision" OFF)
21 option(GMX_OPENMP "Enable OpenMP-based multithreading" ON)
22 set(GMX_SUFFIX "" CACHE STRING "Suffix for the GROMACS installation to use (empty for default)")
23
24 # This does not allow for a non-suffixed double-precision libgromacs, but
25 # that should be rare enough for demonstration purposes.
26 if (GMX_DOUBLE AND NOT GMX_SUFFIX)
27     set(GROMACS_SUFFIX "_d")
28 else()
29     set(GROMACS_SUFFIX ${GMX_SUFFIX})
30 endif()
31
32 find_package(GROMACS 2016 REQUIRED)
33 gromacs_check_double(GMX_DOUBLE)
34 gromacs_check_compiler(CXX)
35 include(gmxManageOpenMP)
36
37 add_definitions(${GROMACS_DEFINITIONS})
38
39 # Use static linking on MSVC
40 if (CMAKE_GENERATOR MATCHES "Visual Studio")
41     string(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
42     set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
43     string(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
44     set(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
45 endif()
46
47 if(NOT GMX_OPENMP)
48     #Unset all OpenMP flags in case OpenMP was disabled either by the user
49     #or because it was only partially detected (e.g. only for C but not C++ compiler)
50     unset(OpenMP_C_FLAGS CACHE)
51     unset(OpenMP_CXX_FLAGS CACHE)
52 endif()
53
54
55 add_subdirectory(src)