forked from merzlab/QUICK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
316 lines (219 loc) · 8.58 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
cmake_minimum_required(VERSION 3.9.0) # version 3.9.0 needed for FindMPI and FindOpenMP versions which provide imported targets
project(quick LANGUAGES NONE VERSION 24.03)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quick-cmake)
if(NOT INSIDE_AMBER)
# initialization and include paths
#-------------------------------------------------------------
include(cmake/AmberBuildSystemInit.cmake NO_POLICY_SCOPE)
#now enable the languages
enable_language(C CXX Fortran)
include(AmberBuildSystem2ndInit)
include(MPIConfig)
set(LINALG_LIBS_REQUIRED TRUE)
set(NEEDED_3RDPARTY_TOOLS blas lapack mkl mirp)
set(REQUIRED_3RDPARTY_TOOLS )
set(BUNDLED_3RDPARTY_TOOLS blas lapack)
include(3rdPartyTools)
include(CompilerFlags)
#CPack setup
# --------------------------------------------------------------------
set(PACKAGE_NAME "QUICK")
set(PACKAGE_FILENAME "QUICK")
set(BUNDLE_IDENTIFIER org.merzlab.quick)
set(BUNDLE_SIGNATURE QUIK)
include(Packaging)
endif()
option(ENABLEF "Enables the support for f functions in the ERI code." FALSE)
# Compiler flags
# These should really go into cmake/CompilerFlags.cmake but with the
# current setup in Amber the Amber compilation flags will take
# precedence so we need to overwrite those here until we have a fully
# independent build system for Quick and integrate Quick in Amber
# as ExternalProject
# --------------------------------------------------------------------
# add -DDEBUG in debug configuration
set_property(DIRECTORY . PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG>)
option(WARNINGS "Enable warnings." FALSE)
set(NO_OPT_FFLAGS -O0)
set(NO_OPT_CFLAGS -O0)
set(NO_OPT_CXXFLAGS -O0)
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_Fortran_FLAGS "")
# GNU
# --------------------------------------------------------------------
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(OPT_CFLAGS -O2 -mtune=native)
if (WARNINGS)
add_flags(C -Wall -Wno-unused-function -Wno-unknown-pragmas)
if(NOT UNUSED_WARNINGS)
add_flags(C -Wno-unused-variable -Wno-unused-but-set-variable)
endif()
if(NOT UNINITIALIZED_WARNINGS)
add_flags(C -Wno-uninitialized -Wno-maybe-uninitialized)
endif()
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(OPT_CXXFLAGS -O2 -mtune=native)
if (WARNINGS)
add_flags(CXX -Wall -Wno-unused-function -Wno-unknown-pragmas)
# Kill it! Kill it with fire!
check_cxx_compiler_flag(-Wno-unused-local-typedefs SUPPORTS_WNO_UNUSED_LOCAL_TYPEDEFS)
if(SUPPORTS_WNO_UNUSED_LOCAL_TYPEDEFS)
add_flags(CXX -Wno-unused-local-typedefs)
endif()
if(NOT UNUSED_WARNINGS)
add_flags(CXX -Wno-unused-variable -Wno-unused-but-set-variable)
endif()
if(NOT UNINITIALIZED_WARNINGS)
add_flags(CXX -Wno-uninitialized -Wno-maybe-uninitialized)
endif()
endif()
endif()
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set(OPT_FFLAGS -O2 -mtune=native)
add_flags(Fortran -ffree-line-length-none)
if (WARNINGS)
add_flags(Fortran -Wall -Wno-tabs -Wno-unused-function -ffree-line-length-none -Wno-unused-dummy-argument)
if(NOT UNUSED_WARNINGS)
add_flags(Fortran -Wno-unused-variable)
endif()
if(NOT UNINITIALIZED_WARNINGS)
add_flags(Fortran -Wno-maybe-uninitialized)
endif()
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
endif()
add_definitions(-DGNU)
endif()
# Intel
# --------------------------------------------------------------------
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_C_FLAGS_DEBUG "-g -debug all -traceback")
set(OPT_CFLAGS -ip -O2 -xHost)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS_DEBUG "-g -debug all -traceback")
set(OPT_CXXFLAGS -ip -O2 -xHost)
endif()
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -debug all -traceback")
set(CMAKE_Fortran_FLAGS "-cpp -diag-disable 8291")
set(OPT_FFLAGS -ip -O2 -xHost)
if(WARNINGS)
add_flags(Fortran "-warn all" "-warn nounused")
option(IFORT_CHECK_INTERFACES "If enabled and Intel Fortran is in use, then ifort will check that types passed to functions are the correct ones, and produce warnings or errors for mismatches." FALSE)
if(NOT IFORT_CHECK_INTERFACES)
# disable errors from type mismatches
add_flags(Fortran -warn nointerfaces)
endif()
endif()
endif()
# PGI, CRAY, CLANG: NOT SUPPORTED
# --------------------------------------------------------------------
if(${COMPILER} STREQUAL PGI)
message(FATAL_ERROR "PGI compiler not supported by QUICK.")
elseif(${COMPILER} STREQUAL CRAY)
message(FATAL_ERROR "CRAY compiler not supported by QUICK.")
#elseif(${COMPILER} STREQUAL CLANG)
# message(FATAL_ERROR "CLANG compiler not supported by QUICK.")
endif()
# disable optimization flags if optimization is disabled
if(NOT OPTIMIZE)
set(OPT_FFLAGS ${NO_OPT_FFLAGS})
set(OPT_CFLAGS ${NO_OPT_CFLAGS})
set(OPT_CXXFLAGS ${NO_OPT_CXXFLAGS})
endif()
#create space-separated versions of each flag set for use in PROPERTY COMPILE_FLAGS
list_to_space_separated(OPT_FFLAGS_SPC ${OPT_FFLAGS})
list_to_space_separated(OPT_CFLAGS_SPC ${OPT_CFLAGS})
list_to_space_separated(OPT_CXXFLAGS_SPC ${OPT_CXXFLAGS})
list_to_space_separated(NO_OPT_FFLAGS_SPC ${NO_OPT_FFLAGS})
list_to_space_separated(NO_OPT_CFLAGS_SPC ${NO_OPT_CFLAGS})
list_to_space_separated(NO_OPT_CXXFLAGS_SPC ${NO_OPT_CXXFLAGS})
# blas vs lapack vs MKL selection
if(lapack_ENABLED)
set(QUICK_LAPACK lapack)
elseif(mkl_ENABLED)
set(QUICK_LAPACK ${MKL_FORTRAN_LIBRARIES})
else()
set(QUICK_LAPACK "")
endif()
if(blas_ENABLED)
set(QUICK_BLAS blas)
elseif(mkl_ENABLED)
set(QUICK_BLAS ${MKL_FORTRAN_LIBRARIES})
endif()
# debug options
option(QUICK_DEBUG_TIME "Compiles a debug version of QUICK that reports more information on timing" FALSE)
option(QUICK_DEBUG "Compiles a debug version of QUICK with extra prints enabled." FALSE)
option(QUICK_VERBOSE_PTXAS "Enable verbose output from CUDA's ptxas." FALSE)
if(QUICK_DEBUG)
add_definitions(-DDEBUG)
endif()
if(QUICK_DEBUG OR QUICK_DEBUG_TIME)
add_definitions(-DDEBUGTIME)
endif()
# extra compiling flags
if(INSIDE_AMBER)
add_definitions(-DCEW)
endif()
# set general preprocessor flag for enabling F functions
if(ENABLEF)
add_definitions(-DENABLEF)
endif()
# CUDA compiler flags
# --------------------------------------------------------------------
include(QUICKCudaConfig)
#--------------------------------------------------------------
# Build code
add_subdirectory(src)
if(NOT INSIDE_AMBER) # Amber is currently not set up for exported targets
#--------------------------------------------------------------
# Exported targets
# directory relative to prefix where config files will be installed
set(CMAKE_PACKAGE_CONFIG_DIR share/cmake/QUICK)
# install targets file
install(EXPORT QUICK
FILE QUICKTargets.cmake
NAMESPACE QUICK::
DESTINATION ${CMAKE_PACKAGE_CONFIG_DIR})
# install version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/QUICKConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
# install top-level file
configure_package_config_file(QUICKConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/QUICKConfig.cmake
INSTALL_DESTINATION ${CMAKE_PACKAGE_CONFIG_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QUICKConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/QUICKConfig.cmake DESTINATION ${CMAKE_PACKAGE_CONFIG_DIR})
endif()
#--------------------------------------------------------------
# Additional files
if(INSIDE_AMBER)
# install data in basis dir
install(DIRECTORY basis DESTINATION AmberTools/src/quick COMPONENT Data)
# install tests dir
install(DIRECTORY test USE_SOURCE_PERMISSIONS DESTINATION AmberTools/src/quick COMPONENT Tests ${TESTS_EXCLUDE_OPTION})
# install runtest script
install(PROGRAMS tools/runtest DESTINATION AmberTools/src/quick COMPONENT Tests)
else()
# Standalone install
# install modules
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amber-modules/ DESTINATION ./include)
# install data in basis dir
install(DIRECTORY basis DESTINATION . USE_SOURCE_PERMISSIONS)
# install tests dir
install(DIRECTORY test DESTINATION . USE_SOURCE_PERMISSIONS)
# install scripts
install(PROGRAMS tools/runtest DESTINATION .)
install(FILES quick-cmake/quick.rc DESTINATION .)
endif()
#--------------------------------------------------------------
# build report
if(NOT INSIDE_AMBER)
print_build_report()
endif()