forked from espressopp/espressopp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (116 loc) · 5.48 KB
/
Copy pathCMakeLists.txt
File metadata and controls
145 lines (116 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.19)
include(CMakePrintHelpers)
project(espressopp VERSION 3.1.0 LANGUAGES CXX)
# C is only used for hdf5, see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8015
if(CMAKE_VERSION VERSION_LESS 3.26)
enable_language(C)
endif()
# Cmake modules/macros are in a subdirectory to keep this file cleaner
set(ESPP_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${ESPP_CMAKE_DIR})
enable_testing()
######################################################################
# compiler tests
# these need ot be done early (before further tests).
#####################################################################
include(CheckCXXCompilerFlag)
# Check for C++14 standard
set(CMAKE_CXX_STANDARD 17) # C++14...
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
########################################################################
# User input options #
########################################################################
option(ESPP_LOCAL_ARCHITECTURE "Use instruction set of the local architecture." OFF)
option(ESPP_VEC_REPORT "Enable reporting of loop vectorization." OFF)
option(ESPP_WERROR "Treat warnings as errors." OFF)
option(ESPP_WALL "Build with more warnings." ON)
option(BUILD_SHARED_LIBS "Build shared libs" ON)
if(NOT BUILD_SHARED_LIBS)
message(WARNING "Building static libraries might lead to problems with python modules - you are on your own!")
endif()
option(USE_GCOV "Enable gcov support" OFF)
if(USE_GCOV)
message(STATUS "Enabling gcov support")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
########################################################################
#Process MPI settings
########################################################################
find_package(MPI REQUIRED COMPONENTS CXX)
########################################################################
#Process FFTW3 settings
########################################################################
find_package(FFTW3 REQUIRED)
########################################################################
#Find HDF5
########################################################################
set(HDF5_PREFER_PARALLEL ON)
#set(HDF5_FIND_DEBUG ON)
find_package(HDF5 REQUIRED COMPONENTS C HL)
if (NOT HDF5_IS_PARALLEL)
message(FATAL_ERROR "HDF5 with MPI support is required! Serial version detected.")
endif()
########################################################################
#Process GROMACS settings
########################################################################
find_package(GROMACS 2021 CONFIG QUIET NAMES gromacs gromacs_d)
option(WITH_XTC "Build with DumpXTC class (requires libgromacs)" ${GROMACS_FOUND})
if(WITH_XTC)
find_package(GROMACS 2021 CONFIG REQUIRED NAMES gromacs gromacs_d)
endif()
########################################################################
#Process Python settings
########################################################################
find_package(Python3 COMPONENTS Interpreter Development)
#cmake_print_variables( Python3_INCLUDE_DIRS Python3_LINK_OPTIONS Python3_LIBRARY_DIRS Python3_RUNTIME_LIBRARY_DIRS Python3_VERSION Python3_VERSION_MAJOR Python3_VERSION_MINOR Python3_NumPy_VERSION)
set(PYTHON_VERSION_NO_DOT "${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
########################################################################
# Basic system tests (standard libraries, headers, functions, types) #
########################################################################
list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
#set( Boost_DEBUG ON )
find_package(Boost 1.69.0 REQUIRED COMPONENTS mpi serialization system filesystem python${PYTHON_VERSION_NO_DOT} numpy${PYTHON_VERSION_NO_DOT} unit_test_framework)
#cmake_print_variables( Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS Boost_LIBRARIES Boost_LIB_VERSION )
######################################
# Automatic CCache detection #
######################################
option(USE_CCACHE "automatically search for and use ccache" OFF)
if (USE_CCACHE)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Using ccache: ${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()
#############################
# Find ScaFaCoS (optional) #
#############################
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(SCAFACOS IMPORTED_TARGET scafacos)
if ( SCAFACOS_FOUND )
add_definitions( -DHAVE_CONFIG_H )
endif()
endif()
#############################
# Find Random123 (optional) #
#############################
find_package(RANDOM123)
######################################
# Include the following subdirectory #
######################################
add_subdirectory(src)
add_subdirectory(testsuite)
add_custom_target(symlink ALL COMMENT "Creating symlink")
add_custom_command(TARGET symlink POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_SOURCE_DIR}/src espressopp)
add_subdirectory(doc)