-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
813 lines (732 loc) · 31.6 KB
/
CMakeLists.txt
File metadata and controls
813 lines (732 loc) · 31.6 KB
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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
cmake_minimum_required(VERSION 3.28) # 3.28 required for EXCLUDE_FROM_ALL for FetchContent_Declare
# 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 3)
set(SEQUANT_MICRO_VERSION 0)
set(SEQUANT_PRERELEASE_ID alpha)
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)
# make SeQuant project
project(SeQuant LANGUAGES CXX VERSION "${SEQUANT_VERSION}" DESCRIPTION "SEcond QUANTization toolkit")
# need C++20, insist on strict standard
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ ISO Standard version")
if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "C++ 2020 ISO Standard or higher is required to build 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/")
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(CTest)
include(FetchContent)
include(AddCustomTargetSubproject)
include(FeatureSummary)
include(CMakePackageConfigHelpers)
include(compiler)
# Helper: creates SeQuant-${module} target, sets EXPORT_NAME, creates SeQuant::${module} alias,
# and applies warning flags (for non-INTERFACE targets)
macro(sequant_add_library _module)
add_library(SeQuant-${_module} ${ARGN})
set_target_properties(SeQuant-${_module} PROPERTIES EXPORT_NAME ${_module})
set_target_properties(SeQuant-${_module} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
add_library(SeQuant::${_module} ALIAS SeQuant-${_module})
get_target_property(_type SeQuant-${_module} TYPE)
if (NOT _type STREQUAL "INTERFACE_LIBRARY")
target_set_warning_flags(SeQuant-${_module})
endif()
endmacro()
# extract git metadata
include(GetGitMetadata)
vgkit_cmake_git_metadata()
##########################
# 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_BENCHMARKS "Enable SeQuant benchmarks" ${PROJECT_IS_TOP_LEVEL})
option(SEQUANT_UTILITIES "Enable SeQuant utility programs" ${PROJECT_IS_TOP_LEVEL})
option(SEQUANT_EVAL_TESTS "OBSOLETE: use SEQUANT_TILEDARRAY and SEQUANT_BTAS" OFF)
option(SEQUANT_BTAS "Enable BTAS eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_BTAS SEQUANT_BTAS "Enable BTAS eval backend")
option(SEQUANT_TILEDARRAY "Enable TiledArray eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_TILEDARRAY SEQUANT_TILEDARRAY "Enable TiledArray eval backend")
option(SEQUANT_TAPP "Enable TAPP eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_TAPP SEQUANT_TAPP "Enable TAPP eval backend")
option(SEQUANT_IWYU "Whether to use the include-what-you-use tool (if found)" OFF)
option(SEQUANT_WARNINGS_AS_ERRORS "Whether to treat compiler warnings as errors" ${PROJECT_IS_TOP_LEVEL})
# SEQUANT_ASSERT
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set (SEQUANT_ASSERT_BEHAVIOR_DEFAULT ABORT)
else ()
set (SEQUANT_ASSERT_BEHAVIOR_DEFAULT IGNORE)
endif()
set (SEQUANT_ASSERT_BEHAVIOR ${SEQUANT_ASSERT_BEHAVIOR_DEFAULT} CACHE STRING "Controls the behavior of SEQUANT_ASSERT; THROW causes SEQUANT_ASSERT to throw, ABORT causes SEQUANT_ASSERT to abort, IGNORE makes SEQUANT_ASSERT a no-op")
set_property(
CACHE SEQUANT_ASSERT_BEHAVIOR PROPERTY
STRINGS THROW ABORT IGNORE)
if (NOT ($CACHE{SEQUANT_ASSERT_BEHAVIOR} STREQUAL THROW OR $CACHE{SEQUANT_ASSERT_BEHAVIOR} STREQUAL ABORT OR $CACHE{SEQUANT_ASSERT_BEHAVIOR} STREQUAL IGNORE))
message(FATAL_ERROR "SEQUANT_ASSERT_BEHAVIOR is set to $CACHE{SEQUANT_ASSERT_BEHAVIOR} but must be one of THROW, ABORT, or IGNORE")
endif()
##########################
# SeQuant package options
##########################
option(ENABLE_TBB "Enable TBB as an optional prerequisite for C++'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++'s parallel STL")
option(SEQUANT_PYTHON "Build SeQuant python module" OFF)
add_feature_info(PYTHON SEQUANT_PYTHON "PySeQuant: Python bindings to SeQuant")
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_CONTEXT_MANIPULATION_THREADSAFE "Controls if the default context can be changed from multiple threads; recommended to set to OFF and setting context from main thread" ON)
add_feature_info(SEQUANT_CONTEXT_MANIPULATION_THREADSAFE SEQUANT_CONTEXT_MANIPULATION_THREADSAFE "The default context can be changed from multiple threads")
##########################
# Prerequisites
##########################
# Apple Clang 16 and earlier do not correctly implement P0522R0
# (relaxed matching of template template arguments), which SeQuant requires
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message(FATAL_ERROR "SeQuant requires Apple Clang 17 or later (found ${CMAKE_CXX_COMPILER_VERSION}). "
"Upgrade Xcode or use a different compiler (e.g., LLVM Clang from Homebrew).")
endif()
include(CheckCXXFeatures)
if (PROJECT_IS_TOP_LEVEL)
vgkit_check_libcxx_linker_mismatch(MODIFY_GLOBAL_FLAGS)
else()
vgkit_check_libcxx_linker_mismatch()
endif()
# Clang < 19 needs -frelaxed-template-template-args for P0522R0;
# sets VGKIT_P0522R0_COMPILE_FLAG, applied to SeQuant-symb below
vgkit_check_p0522r0()
if (PROJECT_IS_TOP_LEVEL AND NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# 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 if <execution> header is usable
vgkit_check_cxx_execution_header(SEQUANT)
# Ranges-V3
include(FindOrFetchRangeV3)
# Boost will be added after defining SeQuant
include(external/boost.cmake)
if(NOT SEQUANT_USE_SYSTEM_BOOST_HASH) # 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()
# polymorphic_variant
include(FindOrFetchPolymorphicVariant)
# LibPerm
include(FindOrFetchLibPerm)
# Utfcpp
include(FindOrFetchUtfcpp)
# Eigen
include(FindOrFetchEigen)
# 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_target_properties(SeQuant-bliss PROPERTIES EXPORT_NAME bliss)
set_target_properties(SeQuant-bliss PROPERTIES CXX_SCAN_FOR_MODULES OFF)
add_library(SeQuant::bliss ALIAS SeQuant-bliss)
target_link_libraries(SeQuant-bliss PUBLIC range-v3::range-v3 Boost::headers)
if (SEQUANT_USE_SYSTEM_BOOST_HASH)
target_compile_definitions(SeQuant-bliss PUBLIC SEQUANT_USE_SYSTEM_BOOST_HASH=1)
else()
target_include_directories(SeQuant-bliss ${SEQUANT_SYSTEM} PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
endif()
# modularized Boost has finer grained targets than just Boost::headers
if (Boost_IS_MODULARIZED)
target_link_libraries(SeQuant-bliss PUBLIC
Boost::container
Boost::container_hash
)
endif()
##########################
# Partitioned source lists
##########################
# Symbolic layer sources (no eval/export dependencies)
set(SeQuant_symb_src
SeQuant/core/algorithm.hpp
SeQuant/core/asy_cost.cpp
SeQuant/core/asy_cost.hpp
SeQuant/core/attr.hpp
SeQuant/core/binary_node.hpp
SeQuant/core/bitset.hpp
SeQuant/core/bliss.hpp
SeQuant/core/complex.hpp
SeQuant/core/container.hpp
SeQuant/core/context.cpp
SeQuant/core/context.hpp
SeQuant/core/expressions/abstract_tensor.cpp
SeQuant/core/expressions/abstract_tensor.hpp
SeQuant/core/expressions/expr.cpp
SeQuant/core/expressions/expr.hpp
SeQuant/core/expressions/expr_algorithms.cpp
SeQuant/core/expressions/expr_algorithms.hpp
SeQuant/core/expressions/expr_operators.hpp
SeQuant/core/expressions/expr_range.hpp
SeQuant/core/expressions/result_expr.cpp
SeQuant/core/expressions/result_expr.hpp
SeQuant/core/expressions/tensor.cpp
SeQuant/core/expressions/tensor.hpp
SeQuant/core/hash.cpp
SeQuant/core/hash.hpp
SeQuant/core/hugenholtz.hpp
SeQuant/core/index.cpp
SeQuant/core/index.hpp
SeQuant/core/index_space_registry.cpp
SeQuant/core/index_space_registry.hpp
SeQuant/core/interval.hpp
SeQuant/core/io/concepts.hpp
SeQuant/core/io/shorthands.hpp
SeQuant/core/io/latex/latex.cpp
SeQuant/core/io/latex/latex.hpp
SeQuant/core/logger.hpp
SeQuant/core/math.hpp
SeQuant/core/meta.hpp
SeQuant/core/op.cpp
SeQuant/core/op.hpp
SeQuant/core/options.cpp
SeQuant/core/options.hpp
SeQuant/core/io/serialization/serialization.cpp
SeQuant/core/io/serialization/serialization.hpp
SeQuant/core/io/serialization/v1/ast.cpp
SeQuant/core/io/serialization/v1/ast.hpp
SeQuant/core/io/serialization/v1/ast_conversions.hpp
SeQuant/core/io/serialization/v1/deserialize.cpp
SeQuant/core/io/serialization/v1/semantic_actions.hpp
SeQuant/core/io/serialization/v1/serialize.cpp
SeQuant/core/ranges.hpp
SeQuant/core/rational.hpp
SeQuant/core/runtime.cpp
SeQuant/core/runtime.hpp
SeQuant/core/space.cpp
SeQuant/core/space.hpp
SeQuant/core/slotted_index.hpp
SeQuant/core/tag.hpp
SeQuant/core/tensor_canonicalizer.cpp
SeQuant/core/tensor_canonicalizer.hpp
SeQuant/core/tensor_network.hpp
SeQuant/core/tensor_network/canonicals.hpp
SeQuant/core/tensor_network/slot.hpp
SeQuant/core/tensor_network/typedefs.hpp
SeQuant/core/tensor_network/utils.hpp
SeQuant/core/tensor_network/vertex.hpp
SeQuant/core/tensor_network/vertex_painter.cpp
SeQuant/core/tensor_network/vertex_painter.hpp
SeQuant/core/tensor_network/v1.cpp
SeQuant/core/tensor_network/v1.hpp
SeQuant/core/tensor_network/v2.cpp
SeQuant/core/tensor_network/v2.hpp
SeQuant/core/tensor_network/v3.cpp
SeQuant/core/tensor_network/v3.hpp
SeQuant/core/utility/atomic.hpp
SeQuant/core/utility/context.hpp
SeQuant/core/utility/debug.hpp
SeQuant/core/utility/exception.hpp
SeQuant/core/utility/expr.cpp
SeQuant/core/utility/expr.hpp
SeQuant/core/utility/indices.hpp
SeQuant/core/utility/macros.cpp
SeQuant/core/utility/macros.hpp
SeQuant/core/utility/memoize.hpp
SeQuant/core/utility/nodiscard.hpp
SeQuant/core/utility/overloads.hpp
SeQuant/core/utility/permutation.hpp
SeQuant/core/utility/scope.hpp
SeQuant/core/utility/singleton.hpp
SeQuant/core/utility/string.cpp
SeQuant/core/utility/string.hpp
SeQuant/core/utility/swap.hpp
SeQuant/core/utility/tensor.hpp
SeQuant/core/utility/timer.hpp
SeQuant/core/utility/tuple.hpp
SeQuant/core/reserved.hpp
SeQuant/core/wick.hpp
SeQuant/core/wick.impl.hpp
SeQuant/core/wick.cpp
)
# MBPT domain sources
set(SeQuant_mbpt_src
SeQuant/domain/mbpt/antisymmetrizer.cpp
SeQuant/domain/mbpt/antisymmetrizer.hpp
SeQuant/domain/mbpt/biorthogonalization.cpp
SeQuant/domain/mbpt/biorthogonalization.hpp
SeQuant/domain/mbpt/context.cpp
SeQuant/domain/mbpt/context.hpp
SeQuant/domain/mbpt/convention.cpp
SeQuant/domain/mbpt/convention.hpp
SeQuant/domain/mbpt/detail/concepts.hpp
SeQuant/domain/mbpt/models/cc.cpp
SeQuant/domain/mbpt/models/cc.hpp
SeQuant/domain/mbpt/op_registry.hpp
SeQuant/domain/mbpt/op_registry.cpp
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/rules/csv.cpp
SeQuant/domain/mbpt/rules/csv.hpp
SeQuant/domain/mbpt/rules/df.cpp
SeQuant/domain/mbpt/rules/df.hpp
SeQuant/domain/mbpt/rules/thc.cpp
SeQuant/domain/mbpt/rules/thc.hpp
SeQuant/domain/mbpt/space_qns.hpp
SeQuant/domain/mbpt/spin.cpp
SeQuant/domain/mbpt/spin.hpp
SeQuant/domain/mbpt/vac_av.hpp
SeQuant/domain/mbpt/vac_av.cpp
SeQuant/domain/mbpt/utils.hpp
SeQuant/domain/mbpt/utils.cpp
)
# Eval framework sources (backend-agnostic)
set(SeQuant_eval_src
SeQuant/core/eval/cache_manager.cpp
SeQuant/core/eval/cache_manager.hpp
SeQuant/core/eval/eval.hpp
SeQuant/core/eval/eval_expr.cpp
SeQuant/core/eval/eval_expr.hpp
SeQuant/core/eval/eval_node.hpp
SeQuant/core/eval/eval_node_compare.hpp
SeQuant/core/eval/result.cpp
SeQuant/core/eval/result.hpp
SeQuant/core/eval/fwd.hpp
)
# Optimize sources (depends on eval)
set(SeQuant_optimize_src
SeQuant/core/optimize/common_subexpression_elimination.hpp
SeQuant/core/optimize/fusion.cpp
SeQuant/core/optimize/fusion.hpp
SeQuant/core/optimize/optimize.cpp
SeQuant/core/optimize/optimize.hpp
SeQuant/core/optimize/single_term.hpp
SeQuant/core/optimize/sum.cpp
SeQuant/core/optimize/sum.hpp
)
# Export sources (depends on eval)
set(SeQuant_export_src
SeQuant/core/export/compute_selection.cpp
SeQuant/core/export/compute_selection.hpp
SeQuant/core/export/context.cpp
SeQuant/core/export/context.hpp
SeQuant/core/export/export.cpp
SeQuant/core/export/export.hpp
SeQuant/core/export/export_expr.cpp
SeQuant/core/export/export_expr.hpp
SeQuant/core/export/generator.cpp
SeQuant/core/export/generator.hpp
SeQuant/core/export/itf.cpp
SeQuant/core/export/itf.hpp
SeQuant/core/export/julia_itensor.hpp
SeQuant/core/export/julia_tensor_kit.hpp
SeQuant/core/export/julia_tensor_operations.cpp
SeQuant/core/export/julia_tensor_operations.hpp
SeQuant/core/export/reordering_context.cpp
SeQuant/core/export/reordering_context.hpp
SeQuant/core/export/text_generator.hpp
)
# TiledArray backend sources
set(SeQuant_eval_ta_src
SeQuant/core/eval/backends/tiledarray/eval_expr.hpp
SeQuant/core/eval/backends/tiledarray/result.hpp
SeQuant/core/eval/backends/tiledarray/result.cpp
)
# BTAS backend sources (header-only)
set(SeQuant_eval_btas_src
SeQuant/core/eval/backends/btas/eval_expr.hpp
SeQuant/core/eval/backends/btas/result.hpp
)
# TAPP backend sources (header-only)
set(SeQuant_eval_tapp_src
SeQuant/core/eval/backends/tapp/tensor.hpp
SeQuant/core/eval/backends/tapp/ops.hpp
SeQuant/core/eval/backends/tapp/eval_expr.hpp
SeQuant/core/eval/backends/tapp/result.hpp
)
# Core sources (just version info)
set(SeQuant_core_src
${PROJECT_BINARY_DIR}/SeQuant/version.hpp
SeQuant/version.cpp
)
#### disable unity_build for v2:
set_source_files_properties(
SeQuant/core/tensor_network/v2.cpp
SeQuant/core/tensor_network/v2.hpp
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE
)
### optional prereqs
if (SEQUANT_TILEDARRAY)
if (NOT TARGET tiledarray)
include(FindOrFetchTiledArray)
endif()
set(SEQUANT_HAS_TILEDARRAY ON)
endif ()
if (SEQUANT_BTAS)
if (NOT TARGET BTAS::BTAS)
include(FindOrFetchBTAS)
endif()
set(SEQUANT_HAS_BTAS ON)
endif ()
if (SEQUANT_TAPP)
if (NOT TARGET tapp::reference)
include(FindOrFetchTAPP)
endif()
set(SEQUANT_HAS_TAPP ON)
endif ()
if (NOT PROJECT_IS_TOP_LEVEL)
set(SEQUANT_SYSTEM "SYSTEM")
endif()
##########################
# SeQuant-symb: core symbolic layer
##########################
sequant_add_library(symb ${SeQuant_symb_src})
if (VGKIT_P0522R0_COMPILE_FLAG)
target_compile_options(SeQuant-symb PUBLIC ${VGKIT_P0522R0_COMPILE_FLAG})
endif()
target_compile_definitions(SeQuant-symb PUBLIC SEQUANT_ASSERT_BEHAVIOR_=${SEQUANT_ASSERT_BEHAVIOR})
if (NOT SEQUANT_ASSERT_BEHAVIOR STREQUAL "IGNORE")
target_compile_definitions(SeQuant-symb PUBLIC SEQUANT_ASSERT_ENABLED)
endif()
if (SEQUANT_CONTEXT_MANIPULATION_THREADSAFE)
target_compile_definitions(SeQuant-symb PRIVATE SEQUANT_CONTEXT_MANIPULATION_THREADSAFE)
endif()
if (SEQUANT_USE_SYSTEM_BOOST_HASH)
target_compile_definitions(SeQuant-symb PUBLIC SEQUANT_USE_SYSTEM_BOOST_HASH=1)
endif()
if (SEQUANT_HAS_EXECUTION_HEADER_STANDALONE OR SEQUANT_HAS_EXECUTION_HEADER_WITH_TBB)
target_compile_definitions(SeQuant-symb PUBLIC SEQUANT_HAS_EXECUTION_HEADER)
if (SEQUANT_HAS_EXECUTION_HEADER_WITH_TBB)
target_link_libraries(SeQuant-symb PRIVATE ${TBB_LIBRARIES})
endif()
endif()
target_link_libraries(SeQuant-symb
PUBLIC
range-v3::range-v3
Boost::headers
Boost::locale
polymorphic_variant::polymorphic_variant
PRIVATE
SeQuant-bliss
Threads::Threads
libperm::libperm
$<BUILD_LOCAL_INTERFACE:utfcpp>
Eigen3::Eigen)
if (Boost_IS_MODULARIZED)
target_link_libraries(SeQuant-symb PUBLIC
Boost::container
Boost::container_hash
Boost::hana
Boost::multiprecision
Boost::numeric_conversion
Boost::numeric_interval
Boost::range
Boost::spirit)
endif()
target_include_directories(SeQuant-symb ${SEQUANT_SYSTEM} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
target_include_directories(SeQuant-symb SYSTEM PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
target_compile_features(SeQuant-symb INTERFACE "cxx_std_20")
##########################
# SeQuant-eval: backend-agnostic evaluation framework
##########################
sequant_add_library(eval ${SeQuant_eval_src})
target_link_libraries(SeQuant-eval PUBLIC SeQuant-symb PRIVATE SeQuant-bliss)
if (SEQUANT_EVAL_TRACE)
target_compile_definitions(SeQuant-eval PUBLIC SEQUANT_EVAL_TRACE=1)
endif()
##########################
# SeQuant-optimize: expression optimization (STO, CSE, fusion)
##########################
sequant_add_library(optimize ${SeQuant_optimize_src})
target_link_libraries(SeQuant-optimize PUBLIC SeQuant-eval SeQuant-symb SeQuant-bliss)
##########################
# SeQuant-eval-ta: TiledArray backend
##########################
if (SEQUANT_HAS_TILEDARRAY)
add_library(SeQuant-eval-ta ${SeQuant_eval_ta_src})
set_target_properties(SeQuant-eval-ta PROPERTIES EXPORT_NAME eval::ta)
set_target_properties(SeQuant-eval-ta PROPERTIES CXX_SCAN_FOR_MODULES OFF)
add_library(SeQuant::eval::ta ALIAS SeQuant-eval-ta)
target_link_libraries(SeQuant-eval-ta PUBLIC SeQuant-eval SeQuant-symb tiledarray)
target_compile_definitions(SeQuant-eval-ta PUBLIC SEQUANT_HAS_TILEDARRAY=1)
endif()
##########################
# SeQuant-eval-btas: BTAS backend (header-only)
##########################
if (SEQUANT_HAS_BTAS)
add_library(SeQuant-eval-btas INTERFACE)
set_target_properties(SeQuant-eval-btas PROPERTIES EXPORT_NAME eval::btas)
set_target_properties(SeQuant-eval-btas PROPERTIES CXX_SCAN_FOR_MODULES OFF)
add_library(SeQuant::eval::btas ALIAS SeQuant-eval-btas)
target_link_libraries(SeQuant-eval-btas INTERFACE SeQuant-eval SeQuant-symb BTAS::BTAS)
target_compile_definitions(SeQuant-eval-btas INTERFACE SEQUANT_HAS_BTAS=1)
endif()
##########################
# SeQuant-eval-tapp: TAPP backend (header-only)
##########################
if (SEQUANT_HAS_TAPP)
add_library(SeQuant-eval-tapp INTERFACE)
set_target_properties(SeQuant-eval-tapp PROPERTIES EXPORT_NAME eval::tapp)
set_target_properties(SeQuant-eval-tapp PROPERTIES CXX_SCAN_FOR_MODULES OFF)
add_library(SeQuant::eval::tapp ALIAS SeQuant-eval-tapp)
target_link_libraries(SeQuant-eval-tapp INTERFACE SeQuant-eval SeQuant-symb tapp::reference)
target_compile_definitions(SeQuant-eval-tapp INTERFACE SEQUANT_HAS_TAPP=1)
endif()
##########################
# SeQuant-export: code generation/export (depends on eval)
##########################
sequant_add_library(export ${SeQuant_export_src})
target_link_libraries(SeQuant-export PUBLIC SeQuant-optimize SeQuant-eval SeQuant-symb)
##########################
# SeQuant-core: version info, links symb + export
##########################
sequant_add_library(core ${SeQuant_core_src})
target_link_libraries(SeQuant-core PUBLIC SeQuant-symb SeQuant-eval SeQuant-optimize SeQuant-export)
# 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}\""
)
##########################
# SeQuant-mbpt: MBPT domain code
##########################
sequant_add_library(mbpt ${SeQuant_mbpt_src})
target_link_libraries(SeQuant-mbpt PUBLIC SeQuant-core SeQuant-optimize)
target_link_libraries(SeQuant-mbpt PRIVATE Eigen3::Eigen libperm::libperm)
if (SEQUANT_CONTEXT_MANIPULATION_THREADSAFE)
target_compile_definitions(SeQuant-mbpt PRIVATE SEQUANT_CONTEXT_MANIPULATION_THREADSAFE)
endif()
##########################
# All SeQuant modules (used for install, IWYU, etc.)
##########################
set(SEQUANT_MODULES SeQuant-bliss SeQuant-symb SeQuant-eval SeQuant-optimize SeQuant-export SeQuant-core SeQuant-mbpt SeQuant)
if (SEQUANT_HAS_TILEDARRAY)
list(APPEND SEQUANT_MODULES SeQuant-eval-ta)
endif()
if (SEQUANT_HAS_BTAS)
list(APPEND SEQUANT_MODULES SeQuant-eval-btas)
endif()
if (SEQUANT_HAS_TAPP)
list(APPEND SEQUANT_MODULES SeQuant-eval-tapp)
endif()
##########################
# SeQuant: umbrella INTERFACE target (backwards compatibility)
##########################
add_library(SeQuant INTERFACE)
target_link_libraries(SeQuant INTERFACE ${SEQUANT_MODULES})
set_target_properties(SeQuant PROPERTIES EXPORT_NAME SeQuant)
add_library(SeQuant::SeQuant ALIAS SeQuant)
##########################
# Installation
##########################
install(TARGETS ${SEQUANT_MODULES}
EXPORT sequant COMPONENT sequant
LIBRARY DESTINATION ${SEQUANT_INSTALL_LIBDIR})
install(DIRECTORY SeQuant
COMPONENT sequant
DESTINATION "${SEQUANT_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.hpp"
PATTERN "*.hh")
if (SEQUANT_MIMALLOC)
find_package(mimalloc REQUIRED)
target_link_libraries(SeQuant-symb PUBLIC mimalloc)
target_compile_definitions(SeQuant-symb PUBLIC SEQUANT_HAS_MIMALLOC=1)
endif ()
# build all of boost before SeQuant-symb, including parts it does not use
if (Boost_BUILT_FROM_SOURCE AND TARGET build-boost-in-SeQuant)
add_dependencies(SeQuant-symb 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 --cxx20ns
-Xiwyu --no_comments
)
foreach(_target ${SEQUANT_MODULES})
get_target_property(_type ${_target} TYPE)
if (NOT _type STREQUAL "INTERFACE_LIBRARY")
set_property(TARGET ${_target} PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_options_and_path})
endif()
endforeach()
endif()
endif()
add_subdirectory(tests)
add_subdirectory(doc)
if (SEQUANT_UTILITIES)
add_subdirectory(utilities)
endif()
if (SEQUANT_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
####### 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 ()
##########################
# 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)
# Make SeQuant consumable from the build directory without installation
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)
# Copy CheckCXXFeatures.cmake to build dir so sequant-config.cmake can find it
configure_file("${vg_cmake_kit_SOURCE_DIR}/modules/CheckCXXFeatures.cmake"
"${PROJECT_BINARY_DIR}/CheckCXXFeatures.cmake" COPYONLY)
## 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"
"${vg_cmake_kit_SOURCE_DIR}/modules/CheckCXXFeatures.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)