forked from yesint/pteros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
200 lines (166 loc) · 6.79 KB
/
CMakeLists.txt
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
cmake_minimum_required(VERSION 3.1)
project(pteros)
OPTION(WITH_PYTHON "Build python bindings and compile analysis plugins as Python modules" ON)
OPTION(WITH_OPENMP "Use OpenMP parallelization if supported" ON)
OPTION(WITH_OPENBABEL "Use OpenBabel if supported" ON)
OPTION(WITH_GROMACS "Use Gromacs if supported. Required to read tpr files." ON)
OPTION(WITH_POWERSASA "Use POWERSASA code. This implies severe license restrictions! \n Read the comment in thirdparty/sasa/LICENSE carefully before enabling this option!" OFF)
OPTION(STANDALONE_PLUGINS "Compile analysis plugins as stand-alone executables" OFF)
OPTION(MAKE_PACKAGE "Generate package" OFF)
OPTION(INSTALL_INTERNAL_SPDLOG "Install internal spdlog headers in the case if there is no system-wide spdlog" ON)
OPTION(MAKE_EXAMPLES "Compile examples and plugin templates" OFF)
OPTION(MAKE_TEST "Compile tests" OFF)
# Use shared Boost libraries
set(Boost_USE_STATIC_LIBS OFF)
# Gloabal compiler and linker flags for Linux
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
# Strip libraries and executables to decrease size in Release builds
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -s")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
ENDIF()
#Sets optmization for Eigen in Release build
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
# Enable STL debugging in debug mode
#SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
# Enable C++11 and C99 everywhere
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
# Set specific options for GCC if used
if(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed")
endif()
# Find OpenMP if needed and only in release mode
if(WITH_OPENMP AND CMAKE_BUILD_TYPE STREQUAL "Release")
message("Looking for OpenMP...")
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()
# Find Python only if we need bindings
if(WITH_PYTHON)
# Configure pybind11
message("Looking for Pybind11...")
find_package(pybind11 REQUIRED)
# Set python install dir
set(PY_INST_DIR python)
endif()
# Find Boost
message("Looking for Boost...")
find_package(Boost 1.48.0 REQUIRED system date_time)
# For boost>1.50 and on windows also add filesystem to compile normally
if(${Boost_MINOR_VERSION} GREATER 50 AND ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_package(Boost 1.50.0 REQUIRED filesystem)
endif()
# Add Boost includes and libs globally - they are needed everywhere
include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES})
# Look for OpenBabel
if(WITH_OPENBABEL)
message("Looking for OpenBabel...")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
find_package(OpenBabel2 REQUIRED)
if(${OPENBABEL2_FOUND})
add_definitions(-DUSE_OPENBABEL)
include_directories(${OPENBABEL2_INCLUDE_DIR})
link_libraries(${OPENBABEL2_LIBRARIES})
else()
message("-- OpenBabel is not found!")
endif()
endif()
# Add Eigen
message("Looking for Eigen...")
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
# Main Pteros include dir (for build time, not yet installed)
include_directories(include)
#--------------
# CPack config
#--------------
IF(MAKE_PACKAGE)
message("Configuring package...")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pteros molecular modeling library")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "7")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(CPACK_GENERATOR DEB)
SET(CPACK_PACKAGE_CONTACT "Semen Yesylevskyy [email protected]")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "g++ (>=4.8), libboost-all-dev (>=1.50), python-dev (>=2.7), python-numpy, libeigen3-dev")
set(PY_INST_DIR ${PYTHON_SITE_PACKAGES})
ENDIF()
INCLUDE(CPack)
ENDIF()
#----------------------------
# Build thirdparty libraries
#----------------------------
message("Looking for spdlog...")
find_package(spdlog CONFIG QUIET)
if(NOT ${spdlog_FOUND})
message("-- spdlog not found! Using internal one.")
include_directories(${PROJECT_SOURCE_DIR}/thirdparty)
# Install spdlog headers
if(${INSTALL_INTERNAL_SPDLOG})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/thirdparty/spdlog DESTINATION include)
endif()
endif()
# Build separate tng_io library
add_subdirectory(thirdparty/tng_io)
include_directories(thirdparty/tng_io/include)
# DSSP library
add_subdirectory(thirdparty/dssp)
include_directories(thirdparty/dssp)
# VMD molfile plugins
add_subdirectory(thirdparty/molfile_plugins)
include_directories(thirdparty/molfile_plugins)
# xdrfile library
add_subdirectory(thirdparty/xdrfile)
include_directories(thirdparty/xdrfile)
# voro++ library
add_subdirectory(thirdparty/voro++)
include_directories(thirdparty/voro++)
# SASA library from MDTraj
add_subdirectory(thirdparty/sasa)
include_directories(thirdparty/sasa)
#---------------------------------------------
# Compiling pteros itself
#---------------------------------------------
add_subdirectory(src/core)
add_subdirectory(src/analysis)
add_subdirectory(src/tools)
add_subdirectory(src/python)
add_subdirectory(src/python/compiled_analysis_plugins)
add_subdirectory(src/extras)
IF(MAKE_TEST)
add_subdirectory(src/test)
ENDIF()
IF(MAKE_EXAMPLES)
add_subdirectory(src/examples)
add_subdirectory(template_plugin)
ENDIF()
# Install headers
install(DIRECTORY include DESTINATION .)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message("------------------------------")
message("IMPORTANT!")
message("In order to be able to link with Pteros and to use Pteros Python modules")
message("you have to add the following lines to your .bashrc file:")
message("export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:${CMAKE_INSTALL_PREFIX}/lib\"")
message("export PYTHONPATH=\"\$PYTHONPATH:${CMAKE_INSTALL_PREFIX}/python\"")
message("export PATH=\"\$PATH:${CMAKE_INSTALL_PREFIX}/bin\"")
message("------------------------------")
ENDIF()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
message("------------------------------")
message("IMPORTANT!")
message("In order to be able to link with Pteros and to use Pteros Python modules")
message("you have to add the following directories to your PATH:")
message("${CMAKE_INSTALL_PREFIX}/lib")
message("${CMAKE_INSTALL_PREFIX}/bin")
message("${CMAKE_INSTALL_PREFIX}/python")
message("------------------------------")
ENDIF()