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