-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
215 lines (188 loc) · 8.1 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#
# This file is part of the FFEA simulation package
#
# Copyright (c) by the Theory and Development FFEA teams,
# as they appear in the README.md file.
#
# FFEA is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FFEA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FFEA. If not, see <http://www.gnu.org/licenses/>.
#
# To help us fund FFEA development, we humbly ask that you cite
# the research papers on the package.
#
cmake_minimum_required(VERSION 3.18...3.26)
project(FFEA VERSION 2.7.2 LANGUAGES CXX C)
# set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(PACKAGE_NAME "ffea")
set(PACKAGE_VERSION ${PROJECT_VERSION})
option(USE_FFEATOOLS_INTERNAL "Download and use the latest FFEATOOLS or use your own install (OFF)" ON)
#todo check if any of these are now redundant.
option(USE_BOOST_INTERNAL "Use the sources we ship (ON) or your own boost (OFF)" ON)
mark_as_advanced(USE_BOOST_INTERNAL)
option(USE_EIGEN3_INTERNAL "Build Eigen automatically as building FFEA (ON) or use your own install (OFF)" ON)
mark_as_advanced(USE_EIGEN3_INTERNAL)
option(USE_OPENMP "Build with OpenMP support" ON)
option(USE_FAST "Add automatic compiler flags" ON)
mark_as_advanced(USE_FAST)
option(USE_FUTURE "Use C++11 <future> tasking threads" OFF)
mark_as_advanced(USE_FUTURE)
set(USE_PRECISION 2 CACHE STRING "1: Floats + Doubles; 2: Doubles; 3: Doubles + Long Doubles")
mark_as_advanced(USE_PRECISION)
option(USE_MPI "Use MPI parallelisation: EXPERIMENTAL!" OFF)
mark_as_advanced(USE_MPI)
option(USE_PACK "Add generic automatic compiler flags" OFF)
mark_as_advanced(USE_PACK)
set(USE_PACK_DIST "RPM" CACHE STRING "accepted values are RPM and DEB")
mark_as_advanced(USE_PACK_DIST)
# Why is this not an option?
set(BUILD_DOC "TRY" CACHE STRING "ONLY; YES; TRY; NO")
set_property(CACHE BUILD_DOC PROPERTY STRINGS "YES;NO;TRY")
# Docs
include(./cmake/doxygen.cmake)
if(${BUILD_DOC} STREQUAL "ONLY")
return()
endif()
# Debug
if(USE_DEBUG)
# Let the user know what mayhem they may have caused
message(SEND_ERROR "USE_DEBUG has been removed, instead pass -DCMAKE_BUILD_TYPE=Debug at CMake configure time.")
endif(USE_DEBUG)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config)
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE INTERNAL "" FORCE)
endif()
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options($<$<CONFIG:Debug>:-ggdb3>)
add_compile_definitions($<$<CONFIG:Debug>:_GLIBCXX_DEBUG=1>)
endif()
endif()
# 10 ### FAST! ##########
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
if(NOT USE_PACK)
if(USE_FAST)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options($<$<CONFIG:Release>:-O3>)
add_compile_options($<$<CONFIG:Release>:-ffast-math>)
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "4.8")
add_compile_options($<$<CONFIG:Release>:-fipa-pta>)
elseif(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "7.0")
add_compile_options($<$<CONFIG:Release>:-fipa-pta>)
add_compile_options($<$<CONFIG:Release>:-march=native>)
else()
add_compile_options($<$<CONFIG:Release>:-march=native>)
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
add_compile_options($<$<CONFIG:Release>:-O3>)
add_compile_options($<$<CONFIG:Release>:-ipo>)
add_compile_options($<$<CONFIG:Release>:-no-prec-div>)
add_compile_options($<$<CONFIG:Release>:-fp-model fast=2>)
add_compile_options($<$<CONFIG:Release>:-xHost>)
endif()
endif()
else()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options($<$<CONFIG:Release>:-O3>)
add_compile_options($<$<CONFIG:Release>:-ffast-math>)
add_compile_options($<$<CONFIG:Release>:-mtune=generic>)
add_compile_options($<$<CONFIG:Release>:-static>)
add_compile_options($<$<CONFIG:Release>:-static>)
add_compile_options($<$<CONFIG:Release>:-static-libgcc>)
add_compile_options($<$<CONFIG:Release>:-static-libstdc++>)
else()
message(FATAL_ERROR "No packaging without GNU compilers")
endif()
if(USE_FAST)
message(STATUS "USE_FAST changed to USE_PACK!")
endif()
endif()
endif()
######## END OF LIBRARIES #######
#################################
#############################################
###### SOURCES TO BUILD AND INSTALL ########
add_subdirectory("${PROJECT_SOURCE_DIR}/src")
#############################################
#######################################
######## INSTALL THE FFEA TOOLS ######
#######################################
if(USE_FFEATOOLS_INTERNAL AND WIN32)
set(USE_FFEATOOLS_INTERNAL OFF)
message(WARNING "FFEATools does not support Windows")
endif()
message(STATUS "Configuring FFEATools")
include(cmake/GetFFEATools.cmake)
#####################################################
############ # # # ENABLE TESTS # # # ###############
enable_testing()
# set_tests_properties(ENVIRONMENT OMP_NUM_THREADS=1)
add_subdirectory("${PROJECT_SOURCE_DIR}/tests/consistency")
add_subdirectory("${PROJECT_SOURCE_DIR}/tests/physics")
add_subdirectory("${PROJECT_SOURCE_DIR}/tests/ffeatools")
add_subdirectory("${PROJECT_SOURCE_DIR}/tests/rods")
configure_file("${PROJECT_SOURCE_DIR}/CTestCustom.in"
"${PROJECT_BINARY_DIR}/CTestCustom.cmake" @ONLY)
#####################################################
###############################
##### INSTALL THE LICENSE #####
install(FILES COPYING DESTINATION share/ffea COMPONENT data)
#####################################################
########### # # # CPACK STUFF # # # #################
# FFEA links to Boost statically,
# so if packagising for different platforms, we only need their gcc version:
# gcc 4.8 - Native - Ubuntu 14.04, Mint 17, Centos 7
# - Works on - Ubuntu 16.04
# gcc 5.4 - needs Eigen 3.2.10 -
# - Ubuntu 16.04
# gcc 4.4 - CentOS 6
set(CPACK_PACKAGE_NAME ${PACKAGE_NAME})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_PACKAGE_ARCHITECTURE "x86_64")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
set(CPACK_PACKAGE_VENDOR "University of Leeds, UK.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FFEA - a toolkit for molecular simulation using Fluctuating Finite Element Method")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_CONTACT "[email protected]")
# # # CPACK: DEB or RPM # # #
if(USE_PACK_DIST STREQUAL "DEB")
set(CPACK_GENERATOR "TBZ2" "DEB")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_amd64")
elseif(USE_PACK_DIST STREQUAL "RPM")
set(CPACK_GENERATOR "TBZ2" "RPM")
# set(CPACK_GENERATOR "TXZ" "RPM")
endif()
# # # CPACK: DEB attributes # # #
# Choose:
# sudo dpkg -i ffea_1.0_amd64.deb
# sudo apt-get install -f
# or
# sudo apt-get install python2.7 python-numpy python-matplotlib libgomp1
# sudo dpkg -i ffea_1.0_amd64.deb
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgomp1 (>=5.4.0), python2.7, python-numpy, python-matplotlib")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "pymol (>=1.8)")
# # # CPACK: RPM attributes # # #
# sudo yum install numpy python-matplotlib
# sudo rpm -Uvh ffea_1.0_x86_64.rpm
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
set(CPACK_RPM_PACKAGE_REQUIRES "numpy, python-matplotlib")
# pymol 1.6 in CentOS 6 is too old for our plugin and CentOS 7 does not provide pymol.
#must come after all cpack settings!
if(USE_PACK)
include(CPack)
message(STATUS "Ready for a ${USE_PACK_DIST} package")
endif(USE_PACK)