-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
658 lines (588 loc) · 25.7 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
cmake_minimum_required(VERSION 3.15.0) # need list(PREPEND for toolchains
# Preload versions/tags of all dependencies ====================================
include(external/versions.cmake)
###############################################################################
# CMake defaults to address key pain points
###############################################################################
# safety net for dev workflow: accidental install will not affect FindOrFetch*
if (NOT DEFINED CACHE{CMAKE_FIND_NO_INSTALL_PREFIX})
set(CMAKE_FIND_NO_INSTALL_PREFIX ON CACHE BOOL "Whether find_* commands will search CMAKE_INSTALL_PREFIX and CMAKE_STAGING_PREFIX; see https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_NO_INSTALL_PREFIX.html#variable:CMAKE_FIND_NO_INSTALL_PREFIX")
endif()
###############################################################################
# Bring ValeevGroup cmake toolkit
###############################################################################
include(FetchContent)
if (DEFINED PROJECT_BINARY_DIR)
set(VG_CMAKE_KIT_PREFIX_DIR PROJECT_BINARY_DIR)
else ()
set(VG_CMAKE_KIT_PREFIX_DIR CMAKE_CURRENT_BINARY_DIR)
endif ()
FetchContent_Declare(
vg_cmake_kit
QUIET
GIT_REPOSITORY https://github.com/ValeevGroup/kit-cmake.git
GIT_TAG ${SEQUANT_TRACKED_VGCMAKEKIT_TAG}
SOURCE_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg
BINARY_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-build
SUBBUILD_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-subbuild
)
FetchContent_MakeAvailable(vg_cmake_kit)
list(APPEND CMAKE_MODULE_PATH "${vg_cmake_kit_SOURCE_DIR}/modules")
# Set SeQuant version
set(SEQUANT_MAJOR_VERSION 2)
set(SEQUANT_MINOR_VERSION 0)
set(SEQUANT_MICRO_VERSION 0)
set(SEQUANT_PRERELEASE_ID alpha.1)
set(SEQUANT_VERSION "${SEQUANT_MAJOR_VERSION}.${SEQUANT_MINOR_VERSION}.${SEQUANT_MICRO_VERSION}")
if (SEQUANT_PRERELEASE_ID)
set(SEQUANT_EXT_VERSION "${SEQUANT_VERSION}-${SEQUANT_PRERELEASE_ID}")
else (SEQUANT_PRERELEASE_ID)
set(SEQUANT_EXT_VERSION "${SEQUANT_VERSION}")
endif (SEQUANT_PRERELEASE_ID)
# extract git metadata
include(GetGitMetadata)
vgkit_cmake_git_metadata()
# make SeQuant project
project(SeQuant LANGUAGES CXX VERSION "${SEQUANT_VERSION}" DESCRIPTION "SEcond QUANTization toolkit")
# need C++17, insist on strict standard
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ ISO Standard version")
if (NOT (CMAKE_CXX_STANDARD EQUAL 17 OR CMAKE_CXX_STANDARD EQUAL 20))
message(FATAL_ERROR "C++ 2017 ISO Standard or higher is required to compile SeQuant")
endif ()
# C++20 is only configurable via compile features with cmake 3.12 and older
if (CMAKE_CXX_STANDARD EQUAL 20 AND CMAKE_VERSION VERSION_LESS 3.12.0)
cmake_minimum_required(VERSION 3.12.0)
endif ()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Whether to use extensions of C++ ISO Standard version")
# Enable ccache if not already enabled by symlink masquerading
if (NOT CMAKE_CXX_COMPILER MATCHES ".*/ccache$")
find_program(CCACHE_EXECUTABLE ccache)
if (CCACHE_EXECUTABLE)
mark_as_advanced(CCACHE_EXECUTABLE)
message(STATUS "Found ccache: ${CCACHE_EXECUTABLE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" CACHE STRING "Compiler launcher to use for compiling C++")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" CACHE STRING "Compiler launcher to use for compiling C")
else ()
set(CCACHE_EXECUTABLE "")
endif ()
endif ()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules/")
set(FETCHCONTENT_UPDATES_DISCONNECTED OFF CACHE BOOL "Enables UPDATE_DISCONNECTED behavior for all content population")
include(FetchContent)
include(AddCustomTargetSubproject)
include(FeatureSummary)
include(CMakePackageConfigHelpers)
##########################
# Standard build variables
##########################
set(SEQUANT_INSTALL_BINDIR "bin"
CACHE PATH "SeQuant BIN install directory")
set(SEQUANT_INSTALL_INCLUDEDIR "include"
CACHE PATH "SeQuant INCLUDE install directory")
set(SEQUANT_INSTALL_LIBDIR "lib"
CACHE PATH "SeQuant LIB install directory")
set(SEQUANT_INSTALL_SHAREDIR "share/sequant/${SEQUANT_MAJOR_VERSION}.${SEQUANT_MINOR_VERSION}.${SEQUANT_MICRO_VERSION}"
CACHE PATH "SeQuant SHARE install directory")
set(SEQUANT_INSTALL_DATADIR "${SEQUANT_INSTALL_SHAREDIR}/data"
CACHE PATH "SeQuant DATA install directory")
set(SEQUANT_INSTALL_DOCDIR "${SEQUANT_INSTALL_SHAREDIR}/doc"
CACHE PATH "SeQuant DOC install directory")
set(SEQUANT_INSTALL_CMAKEDIR "lib/cmake/sequant"
CACHE PATH "SeQuant CMAKE install directory")
############################
# Additional build variables
############################
option(SEQUANT_IWYU "Whether to use the include-what-you-use tool (if found)" OFF)
##########################
# SeQuant package options
##########################
option(ENABLE_TBB "Enable TBB as an optional prerequisite for C++17's parallel STL (if PSTL is not supported will use of standard C++11 concurrency)" OFF)
add_feature_info(TBB ENABLE_TBB "Intel Thread-Building Blocks is an optional prerequisite for C++17's parallel STL")
option(SEQUANT_EVAL_TESTS "Enable building of evaluation tests (if true, will look for and/or build TiledArray)" OFF)
add_feature_info(EVAL_TESTS SEQUANT_EVAL_TESTS "Build evaluation tests (if true, will look for and/or build TiledArray)")
option(SEQUANT_PYTHON "Build SeQuant python module" OFF)
add_feature_info(PYTHON SEQUANT_PYTHON "PySeQuant: Python bindings to SeQuant")
option(SEQUANT_EVAL_TRACE "Enable tracing of the expression interpretation (configure TiledArray with TA_TENSOR_MEM_PROFILE=ON to trace memory use)" OFF)
add_feature_info(EVAL_TRACE SEQUANT_EVAL_TRACE "Trace expression interpretation")
option(SEQUANT_USE_SYSTEM_BOOST_HASH "Use system Boost for hashing? Set to OFF to make hashing independent of Boost, thus value-portable" ON)
add_feature_info(SEQUANT_USE_SYSTEM_BOOST_HASH SEQUANT_USE_SYSTEM_BOOST_HASH "SeQuant uses system Boost for hashing (thus results depend on the Boost version)")
option(SEQUANT_BUILD_DOCS "Build SeQuant documentation using Doxygen and Sphinx" OFF)
add_feature_info(BUILD_DOCS SEQUANT_BUILD_DOCS "Build SeQuant documentation. Doxygen and Sphinx are required.")
##########################
# Prerequisites
##########################
# std::thread requires (on some platforms?) thread support which is not
# provided automatically
find_package(Threads REQUIRED)
# PSTL (used by g++-9 and clang++-8 in c++17 mode) needs TBB
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND
${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 9) OR
(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND
${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8))
if (ENABLE_TBB) # but user must enable the search for TBB since this is an additional source of build entropy
find_package(TBB REQUIRED)
# TBB::tbb by default is not GLOBAL, so to allow users of LINALG_LIBRARIES to safely use it we need to make it global
# more discussion here: https://gitlab.kitware.com/cmake/cmake/-/issues/17256
set_target_properties(TBB::tbb PROPERTIES IMPORTED_GLOBAL TRUE)
endif (ENABLE_TBB)
endif ()
# check of <execution> header is usable
include(CheckCXXFeatures)
check_cxx_execution_header(SEQUANT)
# Ranges-V3
include(FindOrFetchRangeV3)
# Boost will be added after defining SeQuant
include(external/boost.cmake)
# LibPerm
include(FindOrFetchLibPerm)
# embedded bliss-0.73
add_library(SeQuant-bliss
SeQuant/external/bliss/defs.cc
SeQuant/external/bliss/defs.hh
SeQuant/external/bliss/graph.cc
SeQuant/external/bliss/graph.hh
SeQuant/external/bliss/partition.cc
SeQuant/external/bliss/partition.hh
SeQuant/external/bliss/orbit.cc
SeQuant/external/bliss/orbit.hh
SeQuant/external/bliss/uintseqhash.cc
SeQuant/external/bliss/uintseqhash.hh
SeQuant/external/bliss/heap.cc
SeQuant/external/bliss/heap.hh
SeQuant/external/bliss/timer.cc
SeQuant/external/bliss/timer.hh
SeQuant/external/bliss/utils.cc
SeQuant/external/bliss/utils.hh
SeQuant/external/bliss/bliss_C.cc
SeQuant/external/bliss/bliss_C.h
)
set(SeQuant_src
${PROJECT_BINARY_DIR}/SeQuant/version.hpp
SeQuant/version.cpp
SeQuant/core/abstract_tensor.cpp
SeQuant/core/abstract_tensor.hpp
SeQuant/core/algorithm.hpp
SeQuant/core/any.hpp
SeQuant/core/asy_cost.cpp
SeQuant/core/asy_cost.hpp
SeQuant/core/attr.hpp
SeQuant/core/binary_node.hpp
SeQuant/core/bliss.hpp
SeQuant/core/complex.hpp
SeQuant/core/container.hpp
SeQuant/core/context.cpp
SeQuant/core/context.hpp
SeQuant/core/eval_expr.cpp
SeQuant/core/eval_expr.hpp
SeQuant/core/eval_node.hpp
SeQuant/core/export/itf.cpp
SeQuant/core/export/itf.hpp
SeQuant/core/expr.cpp
SeQuant/core/expr.hpp
SeQuant/core/expr_algorithm.hpp
SeQuant/core/expr_operator.hpp
SeQuant/core/hash.hpp
SeQuant/core/hugenholtz.hpp
SeQuant/core/index.cpp
SeQuant/core/index.hpp
SeQuant/core/index_space_registry.hpp
SeQuant/core/interval.hpp
SeQuant/core/latex.cpp
SeQuant/core/latex.ipp
SeQuant/core/latex.hpp
SeQuant/core/logger.hpp
SeQuant/core/math.hpp
SeQuant/core/meta.hpp
SeQuant/core/op.cpp
SeQuant/core/op.hpp
SeQuant/core/optimize.hpp
SeQuant/core/optimize/fusion.cpp
SeQuant/core/optimize/fusion.hpp
SeQuant/core/optimize/optimize.cpp
SeQuant/core/parse/deparse.cpp
SeQuant/core/parse/parse.cpp
SeQuant/core/parse.hpp
SeQuant/core/ranges.hpp
SeQuant/core/rational.hpp
SeQuant/core/runtime.cpp
SeQuant/core/runtime.hpp
SeQuant/core/space.hpp
SeQuant/core/tag.hpp
SeQuant/core/tensor.cpp
SeQuant/core/tensor.hpp
SeQuant/core/tensor_network.cpp
SeQuant/core/tensor_network.hpp
SeQuant/core/timer.hpp
SeQuant/core/utility/context.hpp
SeQuant/core/utility/indices.hpp
SeQuant/core/utility/macros.hpp
SeQuant/core/utility/nodiscard.hpp
SeQuant/core/utility/singleton.hpp
SeQuant/core/utility/string.hpp
SeQuant/core/utility/string.cpp
SeQuant/core/wick.hpp
SeQuant/core/wick.impl.hpp
SeQuant/core/wolfram.hpp
SeQuant/core/wstring.hpp
SeQuant/domain/mbpt/antisymmetrizer.cpp
SeQuant/domain/mbpt/antisymmetrizer.hpp
SeQuant/domain/mbpt/context.hpp
SeQuant/domain/mbpt/context.cpp
SeQuant/domain/mbpt/convention.cpp
SeQuant/domain/mbpt/convention.hpp
SeQuant/domain/mbpt/models/cc.cpp
SeQuant/domain/mbpt/models/cc.hpp
SeQuant/domain/mbpt/op.cpp
SeQuant/domain/mbpt/op.hpp
SeQuant/domain/mbpt/op.ipp
SeQuant/domain/mbpt/rdm.cpp
SeQuant/domain/mbpt/rdm.hpp
SeQuant/domain/mbpt/spin.cpp
SeQuant/domain/mbpt/spin.hpp
SeQuant/domain/mbpt/vac_av.ipp)
### optional prereqs
if (SEQUANT_EVAL_TESTS)
include(FindOrFetchTiledArray)
endif (SEQUANT_EVAL_TESTS)
if (NOT TARGET Eigen3::Eigen)
# use TA's Eigen, if available
if (TARGET TiledArray_Eigen)
add_library(Eigen3::Eigen ALIAS TiledArray_Eigen)
else()
# re:NO_CMAKE_PACKAGE_REGISTRY: eigen3 registers its *build* tree with the user package registry ...
# to avoid issues with wiped build directory look for installed eigen
find_package(Eigen3 3.0 NO_MODULE NO_CMAKE_PACKAGE_REGISTRY)
endif()
endif()
if (TARGET Eigen3::Eigen)
set(SEQUANT_HAS_EIGEN ON)
endif()
if (TARGET tiledarray)
set(SEQUANT_HAS_TILEDARRAY ON)
list(APPEND SeQuant_src
SeQuant/domain/eval/cache_manager.cpp
SeQuant/domain/eval/cache_manager.hpp
SeQuant/domain/eval/eval.cpp
SeQuant/domain/eval/eval.hpp
SeQuant/domain/eval/eval_result.cpp
SeQuant/domain/eval/eval_result.hpp
)
endif ()
add_library(SeQuant
${SeQuant_src}
)
# feed SEQUANT_GIT_REVISION and SEQUANT_GIT_DESCRIPTION to SeQuant/version.cpp only to avoid recompiling everything
set_source_files_properties(
SeQuant/version.cpp
PROPERTIES COMPILE_DEFINITIONS
"SEQUANT_GIT_REVISION=\"${SEQUANT_GIT_REVISION}\";SEQUANT_GIT_DESCRIPTION=\"${SEQUANT_GIT_DESCRIPTION}\""
)
target_link_libraries(SeQuant PUBLIC range-v3::range-v3 Boost::regex Boost::locale Boost::headers SeQuant-bliss Threads::Threads)
# modularized Boost has finer grained targets than just Boost::headers
if (Boost_IS_MODULARIZED)
target_link_libraries(SeQuant PUBLIC
Boost::container
Boost::container_hash
Boost::hana
Boost::multiprecision
Boost::numeric_conversion
Boost::numeric_interval
Boost::range
Boost::spirit
)
endif()
if (TARGET tiledarray)
target_link_libraries(SeQuant PUBLIC tiledarray)
endif ()
if (TARGET Eigen3::Eigen)
target_link_libraries(SeQuant PUBLIC Eigen3::Eigen)
target_compile_definitions(SeQuant PUBLIC SEQUANT_HAS_EIGEN=1)
endif()
if (SEQUANT_HAS_EXECUTION_HEADER_STANDALONE OR SEQUANT_HAS_EXECUTION_HEADER_WITH_TBB)
target_compile_definitions(SeQuant PUBLIC SEQUANT_HAS_EXECUTION_HEADER)
if (SEQUANT_HAS_EXECUTION_HEADER_WITH_TBB)
target_link_libraries(SeQuant PUBLIC ${TBB_LIBRARIES})
target_include_directories(SeQuant PUBLIC ${TBB_INCLUDE_DIRS})
endif ()
endif ()
target_include_directories(SeQuant PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
target_compile_features(SeQuant INTERFACE "cxx_std_17")
if (SEQUANT_EVAL_TRACE)
target_compile_definitions(SeQuant PUBLIC SEQUANT_EVAL_TRACE=1)
endif ()
if (SEQUANT_USE_SYSTEM_BOOST_HASH)
target_compile_definitions(SeQuant PUBLIC SEQUANT_USE_SYSTEM_BOOST_HASH=1)
else()
# if not to use Boost Hash, unpack bundled Boost ContainerHash 1.81
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/SeQuant/external)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/SeQuant/external/boost.tar.gz
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/SeQuant/external
RESULT_VARIABLE UNPACK_BOOST_RESULT
OUTPUT_VARIABLE UNPACK_BOOST_OUTPUT
ERROR_VARIABLE UNPACK_BOOST_OUTPUT
)
if (NOT UNPACK_BOOST_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to unpack the bundled Boost! The tar command output:\n${UNPACK_BOOST_OUTPUT}")
endif()
install(DIRECTORY ${PROJECT_BINARY_DIR}/SeQuant
COMPONENT sequant
DESTINATION "${SEQUANT_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.hpp"
)
endif ()
install(TARGETS SeQuant-bliss EXPORT sequant COMPONENT sequant LIBRARY DESTINATION ${SEQUANT_INSTALL_LIBDIR})
install(TARGETS SeQuant EXPORT sequant COMPONENT sequant LIBRARY DESTINATION ${SEQUANT_INSTALL_LIBDIR})
install(DIRECTORY SeQuant
COMPONENT sequant
DESTINATION "${SEQUANT_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.hpp"
PATTERN "*.hh"
)
add_library(SeQuant::SeQuant ALIAS SeQuant) # to be able to use as subproject
if (SEQUANT_MIMALLOC)
find_package(mimalloc REQUIRED)
target_link_libraries(SeQuant PUBLIC mimalloc)
target_compile_definitions(SeQuant PUBLIC SEQUANT_HAS_MIMALLOC=1)
endif ()
# build all of boost before SeQuant, including parts it does not use
if (Boost_BUILT_FROM_SOURCE AND TARGET build-boost-in-SeQuant)
add_dependencies(SeQuant build-boost-in-SeQuant)
endif()
if (SEQUANT_IWYU)
find_program(iwyu_path NAMES include-what-you-use iwyu)
if (iwyu_path)
set(iwyu_options_and_path
"${iwyu_path}"
-Xiwyu --cxx17ns
-Xiwyu --no_comments
)
set_property(TARGET SeQuant PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_options_and_path})
endif()
endif()
### unit tests
include(CTest)
if (BUILD_TESTING)
# need catch2
include(FindOrFetchCatch2)
set(utests_src
tests/unit/test_space.cpp
tests/unit/test_index.cpp
tests/unit/test_op.cpp
tests/unit/test_wick.cpp
tests/unit/test_tensor.cpp
tests/unit/test_bliss.cpp
tests/unit/test_expr.cpp
tests/unit/test_iterator.cpp
tests/unit/test_mbpt.cpp
tests/unit/test_mbpt_cc.cpp
tests/unit/test_tensor_network.cpp
tests/unit/test_spin.cpp
tests/unit/test_canonicalize.cpp
tests/unit/test_expr.cpp
tests/unit/test_parse.cpp
tests/unit/test_eval_expr.cpp
tests/unit/test_binary_node.cpp
tests/unit/test_asy_cost.cpp
tests/unit/test_eval_node.cpp
tests/unit/test_optimize.cpp
tests/unit/test_fusion.cpp
tests/unit/test_runtime.cpp
tests/unit/test_math.cpp
tests/unit/test_string.cpp
tests/unit/test_latex.cpp
tests/unit/test_utilities.cpp
tests/unit/test_export.cpp
tests/unit/test_meta.cpp
)
if (TARGET tiledarray)
list(APPEND utests_src
tests/unit/test_eval_ta.cpp
tests/unit/test_eval_btas.cpp
tests/unit/test_cache_manager.cpp
)
set_source_files_properties(
tests/unit/test_eval_btas.cpp tests/unit/test_eval_ta.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif (TARGET tiledarray)
set(utests_deps SeQuant Catch2::Catch2)
set(unit_test_executable unit_tests-sequant)
add_executable(${unit_test_executable} EXCLUDE_FROM_ALL
tests/unit/test_main.cpp
tests/unit/test_config.hpp
${utests_src})
target_link_libraries(${unit_test_executable} ${utests_deps})
if (TARGET tiledarray)
target_link_libraries(${unit_test_executable} tiledarray)
target_compile_definitions(${unit_test_executable} PRIVATE SEQUANT_HAS_TILEDARRAY)
endif (TARGET tiledarray)
add_test(sequant/unit/build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR}
--target ${unit_test_executable})
add_test(NAME sequant/unit/run
COMMAND ${unit_test_executable})
set_tests_properties(sequant/unit/run
PROPERTIES DEPENDS sequant/unit/build
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/unit)
####### Integration tests aka "examples" ########
# if target examples-sequant does not exist yet, create it
if (NOT TARGET examples-sequant)
add_custom_target_subproject(sequant examples)
endif()
# Single-Reference Coupled-Cluster equation generation
# (spin-orbital)
set(example0 srcc)
add_executable(${example0} EXCLUDE_FROM_ALL
examples/${example0}/${example0}.cpp)
target_link_libraries(${example0} SeQuant)
# N.B. empty space, to appease foreach
set(${example0}_cmdline_args " ;3 t std so;3 t csv so;3 lambda std so;3 lambda csv so;2 t std sf;2 t csv sf;2 lambda std sf;2 lambda csv sf")
if (TARGET Eigen3::Eigen) # these examples require Eigen for full functionality
# Single-Reference closed-shell Coupled-Cluster equation
# generation (fast spin-traced)
set(example1 stcc)
add_executable(${example1} EXCLUDE_FROM_ALL
examples/${example1}/${example1}.cpp)
target_link_libraries(${example1} SeQuant)
# Single-Reference closed-shell Coupled-Cluster equation
# generation (rigorous spin-traced)
set(example2 stcc_rigorous)
add_executable(${example2} EXCLUDE_FROM_ALL
examples/${example2}/${example2}.cpp)
target_link_libraries(${example2} SeQuant)
endif()
# Single-Reference open-shell equation generation (spin-traced)
set(example3 osstcc)
add_executable(${example3} EXCLUDE_FROM_ALL
examples/${example3}/${example3}.cpp)
target_link_libraries(${example3} SeQuant)
# uccf12 example moved to MPQC
set(example_eval_src
examples/eval/eval_utils.hpp
examples/eval/options.hpp
examples/eval/options.cpp
examples/eval/data_info.hpp
examples/eval/data_info.cpp
examples/eval/calc_info.hpp
examples/eval/calc_info.cpp
examples/eval/scf.hpp
examples/eval/scf.cpp
)
if (TARGET tiledarray)
set(example5 eval_ta)
add_executable(${example5} EXCLUDE_FROM_ALL
${example_eval_src}
examples/eval/ta/data_world_ta.hpp
examples/eval/ta/scf_ta.hpp
examples/eval/ta/main.cpp)
target_link_libraries(${example5} SeQuant tiledarray)
endif (TARGET tiledarray)
set(example6 antisymmetrizer_test)
add_executable(${example6} EXCLUDE_FROM_ALL
examples/${example6}/${example6}.cpp)
target_link_libraries(${example6} SeQuant)
target_compile_definitions(${example6} PRIVATE SEQUANT_HAS_TILEDARRAY)
if (BTAS_SOURCE_DIR)
set(example7 eval_btas)
add_executable(${example7} EXCLUDE_FROM_ALL
${example_eval_src}
examples/eval/btas/data_world_btas.hpp
examples/eval/btas/scf_btas.hpp
examples/eval/btas/main.cpp)
target_include_directories(${example7} PUBLIC ${BTAS_SOURCE_DIR})
target_link_libraries(${example7} SeQuant)
endif (BTAS_SOURCE_DIR)
set(lastexample 13)
foreach (i RANGE 8 ${lastexample})
math(EXPR s "${i} - 7") # map 8..13 -> 1..6
set(example${i} synopsis${s})
add_executable(${example${i}} EXCLUDE_FROM_ALL
examples/synopsis/${example${i}}.cpp)
target_link_libraries(${example${i}} SeQuant)
endforeach ()
# add tests for running examples
foreach (i RANGE ${lastexample})
if (TARGET ${example${i}})
add_dependencies(examples-sequant ${example${i}})
add_test(sequant/example/${example${i}}/build "${CMAKE_COMMAND}"
--build ${CMAKE_BINARY_DIR} --target ${example${i}})
if (NOT DEFINED ${example${i}}_cmdline_args)
set(${example${i}}_cmdline_args " ") # N.B. empty space, to appease foreach
endif()
set(${example${i}}_run_counter 0)
foreach (args ${${example${i}}_cmdline_args})
string(REPLACE " " ";" args "${args}")
add_test(NAME sequant/example/${example${i}}/run/${${example${i}}_run_counter}
COMMAND ${example${i}} ${args}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples)
set_tests_properties(sequant/example/${example${i}}/run/${${example${i}}_run_counter}
PROPERTIES DEPENDS sequant/example/${example${i}}/build)
math(EXPR ${example${i}}_run_counter "${${example${i}}_run_counter} + 1")
endforeach()
endif ()
endforeach ()
# target for running ALL tests
add_custom_target_subproject(sequant check
USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} -V -R "'sequant/(unit|example)'")
else (BUILD_TESTING)
add_custom_target_subproject(sequant check USES_TERMINAL COMMAND echo "WARNING: SeQuant testing disabled. To enable, give -DBUILD_TESTING=ON to cmake")
endif (BUILD_TESTING)
####### Python ########
if (SEQUANT_PYTHON)
if (NOT CMAKE_POSITION_INDEPENDENT_CODE)
message(FATAL_ERROR "Python module requires CMAKE_POSITION_INDEPENDENT_CODE=ON")
endif ()
add_subdirectory(python)
endif ()
####### DOCS ########
if (SEQUANT_BUILD_DOCS)
add_subdirectory(doc)
endif ()
##########################
# export SeQuant
##########################
configure_file(
${PROJECT_SOURCE_DIR}/SeQuant/version.hpp.in
${PROJECT_BINARY_DIR}/SeQuant/version.hpp
)
install(FILES ${PROJECT_BINARY_DIR}/SeQuant/version.hpp
DESTINATION "${SEQUANT_INSTALL_INCLUDEDIR}/SeQuant")
# Create the version file
write_basic_package_version_file(sequant-config-version.cmake
VERSION ${SEQUANT_VERSION} COMPATIBILITY AnyNewerVersion)
# Create the targets file
export(EXPORT sequant
NAMESPACE SeQuant::
FILE "${PROJECT_BINARY_DIR}/sequant-targets.cmake")
## Create the configure file
configure_package_config_file(cmake/sequant-config.cmake.in
"${PROJECT_BINARY_DIR}/sequant-config.cmake"
INSTALL_DESTINATION "${SEQUANT_INSTALL_CMAKEDIR}"
PATH_VARS CMAKE_INSTALL_PREFIX SEQUANT_INSTALL_BINDIR
SEQUANT_INSTALL_INCLUDEDIR SEQUANT_INSTALL_LIBDIR
SEQUANT_INSTALL_DOCDIR SEQUANT_INSTALL_CMAKEDIR)
## Install config, version, and target files
install(EXPORT sequant
FILE "sequant-targets.cmake"
DESTINATION "${SEQUANT_INSTALL_CMAKEDIR}"
NAMESPACE SeQuant::
COMPONENT sequant-config)
install(FILES
"${PROJECT_BINARY_DIR}/sequant-config.cmake"
"${PROJECT_BINARY_DIR}/sequant-config-version.cmake"
DESTINATION "${SEQUANT_INSTALL_CMAKEDIR}"
COMPONENT sequant-config)
add_custom_target_subproject(sequant install-config
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=sequant-config -P ${PROJECT_BINARY_DIR}/cmake_install.cmake
COMMENT "Installing SeQuant config components")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
feature_summary(WHAT ALL
DESCRIPTION "=== SeQuant Package/Feature Info ===")
feature_summary(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/features.log WHAT ALL)
endif()
###############################################################################
# appendix: misc details
###############################################################################
SET(CMAKE_COLOR_MAKEFILE ON)