-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
391 lines (327 loc) · 13 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
cmake_minimum_required(VERSION 3.18)
project(curcuma)
option (USE_XTB
"Compile XTB and use as library" OFF)
option (USE_TBLITE
"Compile TBLITE and use as library" ON)
option (USE_D3
"Compile cpp-D4 and use as library" ON)
option (USE_D4
"Compile cpp-D4 and use as library" OFF)
option (C17
"Use C++ 17 Standard" ON)
option (Helper
"Helper apps for interfaces" OFF)
option (WriteMoreInfo
"Write statistic files with more info" OFF)
option (USE_Plumed
"Enable interface to plumed for metadynamics")
add_subdirectory(${PROJECT_SOURCE_DIR}/external/fmt EXCLUDE_FROM_ALL)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
#if(NOT DEFINED ${CMAKE_BUILD_TYPE})
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
#endif()
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmt/include
${PROJECT_SOURCE_DIR}/external/LBFGSpp/include
${PROJECT_SOURCE_DIR}/external/ripser
${PROJECT_SOURCE_DIR}/external/eigen-3.4.0
${PROJECT_SOURCE_DIR}/external/cpp-d4/include
${PROJECT_SOURCE_DIR}/external/)
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} )
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest tag within the working branch
execute_process(
COMMAND git describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(UNIX) # dont work on windows systems, compilation fails unfortranatly ...
execute_process(
COMMAND git log -1 --format=%aD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(UNIX)
add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
add_definitions("-DGIT_BRANCH=${GIT_BRANCH}")
add_definitions("-DGIT_COMMIT_DATE=${GIT_COMMIT_DATE}")
add_definitions("-DGIT_COMMIT_TAG=${GIT_COMMIT_TAG}")
if(CMAKE_COMPILER_IS_GNUCXX)
set (_UNIX ON)
endif()
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}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
set (openMP ON)
endif()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -pedantic \
-Wextra -Wcast-align -Wcast-qual -Wchar-subscripts \
-Wcomment -Wdisabled-optimization \
-Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security\
-Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch\
-Wunsafe-loop-optimizations -Wno-missing-braces\
-Wmissing-field-initializers -Wmissing-format-attribute \
-Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses\
-Wpointer-arith -Wno-redundant-decls -Wsequence-point\
-Wsign-compare -Wstack-protector -Wstrict-aliasing\
-Wstrict-aliasing=2 -Wswitch -Wsuggest-override\
-Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code\
-Wunused -Wunused-function -Wunused-label -Wunused-parameter\
-Wunused-value -Wunused-variable -Wvariadic-macros\
-Wvolatile-register-var -Wwrite-strings -Wdeprecated-declarations\
-Wno-error=unused-local-typedefs -Wno-error=enum-compare -Wno-narrowing -Werror=return-type -Wno-sign-compare -g")
set (GCC ON)
if(WIN32) # Check if we are on Windows
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
endif(WIN32)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/json.hpp)
file(DOWNLOAD https://github.com/nlohmann/json/releases/download/v3.9.1/json.hpp ${PROJECT_SOURCE_DIR}/external/json.hpp
TIMEOUT 60 # seconds
EXPECTED_HASH SHA256=7804b38146921d03374549c9e2a5e3acda097814c43caf2b96a0278e58df26e0
TLS_VERIFY ON)
endif()
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/eigen-3.4.0.zip)
file(DOWNLOAD https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip ${PROJECT_SOURCE_DIR}/external/eigen-3.4.0.zip
TIMEOUT 60 # seconds
EXPECTED_HASH SHA256=1ccaabbfe870f60af3d6a519c53e09f3dcf630207321dffa553564a8e75c4fc8
TLS_VERIFY ON)
endif()
file(ARCHIVE_EXTRACT INPUT ${PROJECT_SOURCE_DIR}/external/eigen-3.4.0.zip DESTINATION ${PROJECT_SOURCE_DIR}/external)
configure_file (
"${PROJECT_SOURCE_DIR}/src/global_config.h.in"
"${PROJECT_BINARY_DIR}/src/global_config.h"
)
configure_file(
"${PROJECT_SOURCE_DIR}/src/version.h.in"
"${PROJECT_BINARY_DIR}/src/version.h"
)
set(curcuma_core_SRC
src/capabilities/persistentdiagram.cpp
src/capabilities/analysenciplot.cpp
src/capabilities/curcumamethod.cpp
src/capabilities/curcumaopt.cpp
src/capabilities/confscan.cpp
src/capabilities/confsearch.cpp
src/capabilities/confstat.cpp
src/capabilities/docking.cpp
src/capabilities/analysenciplot.cpp
src/capabilities/nebdocking.cpp
src/capabilities/pairmapper.cpp
src/capabilities/rmsd.cpp
src/capabilities/rmsdtraj.cpp
src/capabilities/simplemd.cpp
src/capabilities/hessian.cpp
src/capabilities/qmdfffit.cpp
src/core/energycalculator.cpp
src/core/molecule.cpp
src/core/fileiterator.cpp
src/core/eigen_uff.cpp
src/core/qmdff.cpp
src/core/eht.cpp
src/core/forcefieldthread.cpp
src/core/forcefield.cpp
src/core/forcefieldfunctions.h
src/core/forcefieldgenerator.cpp
#src/core/forcefield_terms/qmdff_terms.h
src/tools/formats.h
src/tools/geometry.h
src/tools/general.h
)
add_library(curcuma_core ${curcuma_core_SRC})
set(km_SRC
src/capabilities/c_code/hungarian.c
src/capabilities/c_code/interface.c
)
add_library(km ${km_SRC})
target_link_libraries(curcuma_core km)
add_executable(curcuma
src/main.cpp
)
if(C17)
set_property(TARGET curcuma_core PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET curcuma_core PROPERTY CXX_STANDARD 14)
endif(C17)
if(C17)
set_property(TARGET curcuma PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET curcuma PROPERTY CXX_STANDARD 14)
endif(C17)
set(target_dir "bin")
set_property(TARGET curcuma PROPERTY LINK_FLAGS_RELEASE -s)
set_property(TARGET curcuma PROPERTY LINK_FLAGS_RELWITHDEBINFO -s)
if(USE_XTB)
add_subdirectory(external/xtb)
if(NOT TARGET mctc-lib)
set("mctc-lib-url" "https://github.com/grimme-lab/mctc-lib")
message(STATUS "Retrieving mctc-lib from ${mctc-lib-url}")
include(FetchContent)
FetchContent_Declare(
"mctc-lib"
GIT_REPOSITORY "${mctc-lib-url}"
GIT_TAG "HEAD"
)
FetchContent_MakeAvailable("mctc-lib")
endif()
include_directories(SYSTEM ${PROJECT_BINARY_DIR}/_deps/tblite-src/include/)
if(HELPERS)
add_executable(xtb_helper
src/helpers/xtb_helper.cpp
)
if(C17)
set_property(TARGET xtb_helper PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET xtb_helper PROPERTY CXX_STANDARD 14)
endif(C17)
target_link_libraries(xtb_helper lib-xtb-shared pthread dl)
endif()
set(curcuma_xtb_SRC
src/core/xtbinterface.cpp
)
add_library(curcuma_xtb ${curcuma_xtb_SRC})
target_link_libraries(curcuma_xtb PUBLIC "mctc-lib" lib-xtb-shared gfortran)
target_link_libraries(curcuma_core curcuma_xtb)
endif()
if(USE_TBLITE)
if(NOT TARGET mctc-lib)
set("mctc-lib-url" "https://github.com/grimme-lab/mctc-lib")
message(STATUS "Retrieving mctc-lib from ${mctc-lib-url}")
include(FetchContent)
FetchContent_Declare(
"mctc-lib"
GIT_REPOSITORY "${mctc-lib-url}"
GIT_TAG "HEAD"
)
FetchContent_MakeAvailable("mctc-lib")
endif()
if(NOT TARGET tblite-lib)
add_subdirectory(external/tblite)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/tblite/include)
elseif()
# include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/tblite/include)
endif()
if(HELPERS)
add_executable(tblite_helper
src/helpers/tblite_helper.cpp
)
if(C17)
set_property(TARGET tblite_helper PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET tblite_helper PROPERTY CXX_STANDARD 14)
endif(C17)
target_link_libraries(tblite_helper PUBLIC tblite-lib gfortran pthread)
endif()
set(curcuma_tblite_SRC
src/core/tbliteinterface.cpp
)
add_library(curcuma_tblite ${curcuma_tblite_SRC})
target_link_libraries(curcuma_tblite PUBLIC "mctc-lib" tblite-lib gfortran)
target_link_libraries(curcuma_core curcuma_tblite)
endif()
if(USE_D3)
if(NOT TARGET s-dftd3)
add_subdirectory(external/simple-dftd3)
endif()
if(HELPERS)
add_executable(dftd3_helper
src/helpers/dftd3_helper.cpp
)
target_link_libraries(dftd3_helper PUBLIC s-dftd3 gfortran pthread)
endif()
set(curcuma_D3_SRC
src/core/dftd3interface.cpp
)
add_library(curcuma_D3 ${curcuma_D3_SRC})
target_link_libraries(curcuma_D3 s-dftd3)
target_link_libraries(curcuma_core curcuma_D3 gfortran pthread)
endif()
if(USE_D4)
if(NOT DEFINED D4LIBS_DIR AND NOT DEFINED D4INCLUDE_DIR)
#find_package(LAPACKE REQUIRED)
#find_package(CBLAS CONFIG REQUIRED)
else()
include_directories(${INCLUDE_DIR})
endif(NOT DEFINED D4LIBS_DIR AND NOT DEFINED D4INCLUDE_DIR)
add_subdirectory(external/cpp-d4)
if(HELPERS)
add_executable(dftd4_helper
src/helpers/dftd4_helper.cpp
)
if(C17)
set_property(TARGET dftd4_helper PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET dftd4_helper PROPERTY CXX_STANDARD 14)
endif(C17)
if(DEFINED D4LIBS_DIR AND DEFINED D4INCLUDE_DIR)
link_directories(${LIBS_DIR})
target_link_libraries(dftd4_helper PRIVATE libcpp_d4 cblas lapacke pthread)
else()
target_link_libraries(dftd4_helper PRIVATE libcpp_d4 ${LAPACKE_LIBRARIES} ${CBLAS_LIBRARIES} pthread)
endif(DEFINED D4LIBS_DIR AND DEFINED D4INCLUDE_DIR)
endif()
set(curcuma_d4_SRC
src/core/dftd4interface.cpp
)
add_library(curcuma_d4 ${curcuma_d4_SRC})
if(DEFINED D4LIBS_DIR AND DEFINED D4INCLUDE_DIR)
target_link_libraries(curcuma_d4 PUBLIC libcpp_d4 cblas lapacke )
else()
target_link_libraries(curcuma_d4 PUBLIC libcpp_d4 ${LAPACKE_LIBRARIES} ${CBLAS_LIBRARIES} )
endif(DEFINED D4LIBS_DIR AND DEFINED D4INCLUDE_DIR)
target_link_libraries(curcuma_core curcuma_d4)
endif()
if(USE_Plumed)
target_link_libraries(curcuma_core ${PROJECT_SOURCE_DIR}/external/plumed2/src/lib/libplumed.so)
endif()
target_link_libraries(curcuma_core pthread fmt::fmt-header-only )
if(WIN32) # Check if we are on Windows
else()
target_link_libraries(curcuma_core dl )
endif(WIN32)
target_link_libraries(curcuma fmt::fmt-header-only)
target_link_libraries(curcuma curcuma_core)
add_executable(curcuma_helper
src/helpers/main.cpp)
target_link_libraries(curcuma_helper fmt::fmt-header-only)
target_link_libraries(curcuma_helper curcuma_core)
set_property(TARGET curcuma_helper PROPERTY LINK_FLAGS_RELEASE -s)
set_property(TARGET curcuma_helper PROPERTY LINK_FLAGS_RELWITHDEBINFO -s)
if(C17)
set_property(TARGET curcuma_helper PROPERTY CXX_STANDARD 17)
else()
set_property(TARGET curcuma_helper PROPERTY CXX_STANDARD 14)
endif(C17)
add_subdirectory(test_cases)
include(CTest)
target_sources(Continuous
PRIVATE
src/core/qmdff_par.h
)
add_test(NAME AAAbGal_mtemplate COMMAND AAAbGal mtemplate WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test_cases)
add_test(NAME AAAbGal_mhybrid COMMAND AAAbGal mhybrid WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test_cases)
add_test(NAME AAAbGal_template COMMAND AAAbGal template WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test_cases)
add_test(NAME AAAbGal_hybrid COMMAND AAAbGal hybrid WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test_cases)
add_test(NAME AAAbGal_incremental COMMAND AAAbGal incr WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test_cases)
set_tests_properties(AAAbGal_incremental PROPERTIES TIMEOUT 300)
install(TARGETS curcuma RUNTIME DESTINATION bin)
install(TARGETS curcuma_helper RUNTIME DESTINATION bin)