forked from QMCPACK/qmcpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1084 lines (970 loc) · 44.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
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
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
######################################################################
# CMake version and policies
######################################################################
cmake_minimum_required(VERSION 3.15.0)
# CMP0074: CMake find_package will use <PackageName>_ROOT CMake variable
# and environment variable in search path.
# various Find<Package>.cmake modules may not follow this policy
# CMP0075: check_include_file_cxx and other follow CMAKE_REQUIRED_LIBRARIES
# when doing link check
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0075 NEW)
######################################################################
# QMCPACK project
######################################################################
project(
qmcpack
VERSION 3.12.9
LANGUAGES C CXX)
#--------------------------------------------------------------------
# Directory where customize cmake files reside
#--------------------------------------------------------------------
set(PROJECT_CMAKE ${qmcpack_SOURCE_DIR}/CMake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_CMAKE})
include(macros)
######################################################################
# Build and install options
######################################################################
#--------------------------------------------------------------------
# Set C++ standard
#--------------------------------------------------------------------
set(QMC_CXX_STANDARD
17
CACHE STRING "QMCPACK C++ language standard")
if(NOT QMC_CXX_STANDARD EQUAL 17)
message(WARNING "C++17 is the only language standard officially supported by this QMCPACK version. "
"Using other versions of the C++ standard is unsupported and done entirely at user's own risk.")
endif()
#--------------------------------------------------------------------
# Programmind model related build options
# MPI, OpenMP, GPU acceleration
#--------------------------------------------------------------------
include(CMakeDependentOption)
option(QMC_MPI "Enable/disable MPI" ON)
option(QMC_OMP "Enable/disable OpenMP" ON)
option(QMC_COMPLEX "Build for complex binary" OFF)
option(QMC_CUDA "Build with GPU support through CUDA" OFF)
option(
ENABLE_CUDA
"Build with the second generation of GPU support through CUDA (production quality for AFQMC, experimental for real space)"
OFF)
option(QMC_CUDA2HIP "Map all CUDA kernels and library calls to HIP" OFF)
if(QMC_CUDA2HIP)
set(ENABLE_ROCM ON) # option(ENABLE_ROCM) will be no-op
endif()
# explicit HIP source codes only exist in AFQMC.
option(ENABLE_HIP "Build with with GPU support through explicit HIP source code" OFF)
option(ENABLE_ROCM "Build with with GPU support through ROCM libraries" OFF)
option(ENABLE_OFFLOAD "Enable OpenMP offload" OFF)
# Use CMake object library targets to workaround clang linker not being able to handle fat
# binary archives which contain both host and device codes, for example OpenMP offload regions.
# CMake does not propagate indirect object files by design.
# So the dependency must be explicitly specified with USE_OBJECT_TARGET.
cmake_dependent_option(USE_OBJECT_TARGET "Use CMake object library target" OFF "ENABLE_OFFLOAD" OFF)
if(ENABLE_CUDA AND QMC_CUDA)
message(FATAL_ERROR "ENABLE_CUDA=ON and QMC_CUDA=ON can not be set together!")
endif(ENABLE_CUDA AND QMC_CUDA)
if(ENABLE_OFFLOAD AND QMC_CUDA)
message(FATAL_ERROR "ENABLE_OFFLOAD=ON doesn't work together with QMC_CUDA=ON! Did you mean ENABLE_CUDA=ON?")
endif()
# set CMAKE_CUDA_ARCHITECTURES early such that offload compilers may take advantage of it
if(ENABLE_CUDA
OR QMC_CUDA
AND NOT QMC_CUDA2HIP)
if(DEFINED CUDA_ARCH)
unset(CUDA_ARCH CACHE)
message(
FATAL_ERROR "CUDA_ARCH option has been removed. Use -DCMAKE_CUDA_ARCHITECTURES=80 if -DCUDA_ARCH=sm_80 was used.")
endif()
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 70)
endif()
endif()
#--------------------------------------------------------------------
# Set compiler-time parameters
# WALKER_MAX_PROPERTIES max number of observables + 12 or so standard
# properties. Properties such forces are per particle so you may need this
# to be rather large. Each property increases walker size by
# sizeof(FULLPRECREALTYPE)
# OHMMS_DIM = dimension of the problem
# OHMMS_INDEXTYPE = type of index
# OHMMS_PRECISION = base precision, float, double etc
# OHMMS_PRECISION_FULL = full precision, double etc
#--------------------------------------------------------------------
set(WALKER_MAX_PROPERTIES
2048
CACHE STRING "Maximum number of properties tracked by walkers")
mark_as_advanced(WALKER_MAX_PROPERTIES)
set(OHMMS_DIM
3
CACHE STRING "Select physical dimension")
set(OHMMS_INDEXTYPE int)
set(OHMMS_PRECISION_FULL double)
if(QMC_VERBOSE_CONFIGURATION)
message(WARNING "QMC_VERBOSE_CONFIGURATION option has been removed. Use --log-level=VERBOSE cmake option instead.")
endif()
#--------------------------------------------------------------------
message(STATUS "Defining the float point precision")
#--------------------------------------------------------------------
if(QMC_CUDA)
option(QMC_MIXED_PRECISION "Enable/disable mixed precision" ON)
set(OHMMS_PRECISION double)
set(CUDA_PRECISION_FULL double)
if(QMC_MIXED_PRECISION)
set(CUDA_PRECISION float)
else(QMC_MIXED_PRECISION)
set(CUDA_PRECISION double)
endif(QMC_MIXED_PRECISION)
message(" Base precision = ${OHMMS_PRECISION}")
message(" Full precision = ${OHMMS_PRECISION_FULL}")
message(" CUDA base precision = ${CUDA_PRECISION}")
message(" CUDA full precision = ${CUDA_PRECISION_FULL}")
else(QMC_CUDA)
option(QMC_MIXED_PRECISION "Enable/disable mixed precision" OFF)
if(QMC_MIXED_PRECISION)
set(OHMMS_PRECISION float)
set(MIXED_PRECISION ON)
else(QMC_MIXED_PRECISION)
set(OHMMS_PRECISION double)
endif(QMC_MIXED_PRECISION)
message(" Base precision = ${OHMMS_PRECISION}")
message(" Full precision = ${OHMMS_PRECISION_FULL}")
endif(QMC_CUDA)
#--------------------------------------------------------------------
# Set debug printout
# DEBUG_PSIBUFFER_ON keep track buffer's locator
#--------------------------------------------------------------------
option(PRINT_DEBUG "Enable/disable debug printing" OFF)
option(DEBUG_PSIBUFFER_ON "Debug messages for PSIBUFFER locator" OFF)
mark_as_advanced(DEBUG_PSIBUFFER_ON)
option(DEBUG_PER_STEP_ACCEPT_REJECT "Print accepts and rejects at each step" OFF)
mark_as_advanced(DEBUG_PER_STEP_ACCEPT_REJECT)
#--------------------------------------------------------------------
# Set build feature options
#--------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_BUILD_TYPE Release)
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
option(QMC_BUILD_SANDBOX_ONLY "Build only applications in Sandbox directory" OFF)
option(ENABLE_GCOV "Enable code coverage" OFF)
option(BUILD_UNIT_TESTS "Build unit tests" ON)
option(BUILD_MICRO_BENCHMARKS "Build micro benchmarks" ON)
option(BUILD_LMYENGINE_INTERFACE "Build LMY engine" ON)
if(QMC_CUDA AND BUILD_LMYENGINE_INTERFACE)
message(STATUS "LMY engine is not compatible with CUDA build! Disabling LMY engine")
set(BUILD_LMYENGINE_INTERFACE OFF)
endif()
if(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE)
message(STATUS "LMY engine is not compatible with CPU mixed precision build! Disabling LMY engine")
set(BUILD_LMYENGINE_INTERFACE OFF)
endif()
option(BUILD_AFQMC "Build with AFQMC" OFF)
option(BUILD_AFQMC_WITH_NCCL "Build AFQMC with NCCL library." OFF)
# AFQMC requires MPI.
if(BUILD_AFQMC AND NOT QMC_MPI)
message(FATAL_ERROR "AFQMC requires building with MPI (QMC_MPI=1). Set BUILD_AFQMC=0 or configure MPI.")
endif()
option(BUILD_FCIQMC "Build with FCIQMC" OFF)
option(QMC_BUILD_STATIC "Link to static libraries" OFF)
option(ENABLE_TIMERS "Enable internal timers" ON)
option(ENABLE_STACKTRACE "Enable use of boost::stacktrace" OFF)
option(USE_VTUNE_API "Enable use of VTune ittnotify APIs" OFF)
cmake_dependent_option(USE_VTUNE_TASKS "USE VTune ittnotify task annotation" OFF "ENABLE_TIMERS AND USE_VTUNE_API" OFF)
# CMake note - complex conditionals in cmake_dependent_option must have spaces around parentheses
cmake_dependent_option(USE_NVTX_API "Enable/disable NVTX regions in CUDA code." OFF
"ENABLE_TIMERS AND ( QMC_CUDA OR ENABLE_CUDA )" OFF)
set(HAVE_EINSPLINE 1) # to be removed
option(QMC_EXP_THREADING "Experimental non openmp threading models" OFF)
mark_as_advanced(QMC_EXP_THREADING)
#--------------------------------------------------------------------
# Sanitizer options
#--------------------------------------------------------------------
# Add optional sanitizers ASAN, UBSAN, MSAN
set(VALID_SANITIZERS "none" "asan" "ubsan" "tsan" "msan")
set(ENABLE_SANITIZER
"none"
CACHE STRING "none,asan,ubsan,tsan,msan")
set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${VALID_SANITIZERS})
# Perform sanitizer option check, only works in debug mode
if(NOT ENABLE_SANITIZER IN_LIST VALID_SANITIZERS)
message(FATAL_ERROR "Invalid -DENABLE_SANITIZER=${ENABLE_SANITIZER}, value must be one of ${VALID_SANITIZERS}")
else()
message(STATUS "Enable sanitizer ENABLE_SANITIZER=${ENABLE_SANITIZER}")
endif()
#--------------------------------------------------------------------
# INSTALL_NEXUS install Nexus alongside QMCPACK
#--------------------------------------------------------------------
option(INSTALL_NEXUS "Install Nexus alongside QMCPACK" ON)
if(INSTALL_NEXUS)
install(CODE "EXECUTE_PROCESS(COMMAND ${qmcpack_SOURCE_DIR}/nexus/install --leave_paths ${CMAKE_INSTALL_PREFIX}/bin)")
endif()
######################################################################
# Set the compiler specific options/flags
######################################################################
if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using ${CMAKE_TOOLCHAIN_FILE} toolchain ")
else(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Trying to figure out compiler options ....")
set(ENABLE_OPENMP 0)
#------------------------
# On Cray's machine
#------------------------
get_filename_component(BASE_CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
if($ENV{CRAYPE_VERSION} MATCHES "." AND NOT BASE_CXX_COMPILER_NAME STREQUAL "CC")
message(WARNING "Cray Programming Environment has been detected but C++ compiler wrapper CC is not used! "
"Please use cc/CC as the C/C++ compiler to ensure correct cross-compiling for the compute nodes "
"unless you understand cross-compiling and intend not to use Cray compiler wrappers.")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "CrayLinuxEnvironment")
message(STATUS "Running on a Cray machine.")
if(NOT $ENV{CRAYPE_LINK_TYPE} STREQUAL "dynamic")
message(WARNING "Cray Programming Environment uses static linking by default. "
"We prefer dynamic linking which makes library searching easier. "
"Setting environment variable CRAYPE_LINK_TYPE to \"dynamic\" enables dynamic linking.\n")
endif()
if(NOT DEFINED MPIEXEC_EXECUTABLE)
find_program(MPIEXEC_EXECUTABLE aprun)
if(NOT MPIEXEC_EXECUTABLE)
# For slurm use srun
find_program(MPIEXEC_EXECUTABLE srun)
endif(NOT MPIEXEC_EXECUTABLE)
endif()
else()
if($ENV{CRAYPE_VERSION} MATCHES "." AND BASE_CXX_COMPILER_NAME STREQUAL "CC")
message(
FATAL_ERROR
"Cray compiler wrapper detected. Empty the build folder and rerun cmake with -DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment added."
)
endif()
endif()
include(inspectCompiler)
endif(CMAKE_TOOLCHAIN_FILE)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL CMAKE_C_COMPILER_ID)
message(FATAL_ERROR "Mixing C and C++ compilers from different vendors is not permitted. Current "
"C compiler is ${CMAKE_C_COMPILER_ID} but C++ compiler is ${CMAKE_CXX_COMPILER_ID}.")
endif()
#-----------------------------------------------------------------------
# Set C++ minimum standard and run basic checks
#-----------------------------------------------------------------------
set(CMAKE_CXX_STANDARD ${QMC_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Check that a C++ compiler is compatible with the underlying libstdc++
include(Testlibstdc++)
# Check that a C++ standard library is configured properly
include(TestCxx17Library)
#-----------------------------------------------------------------------
# SETUP SANITIZERS FLAGS
#-----------------------------------------------------------------------
if(NOT "${ENABLE_SANITIZER}" STREQUAL "none")
if(NOT ${COMPILER} MATCHES "GNU" AND NOT ${COMPILER} MATCHES "Clang")
message(FATAL_ERROR "-DENABLE_SANITIZER=${ENABLE_SANITIZER} only works with GNU or Clang compilers")
endif()
if("${ENABLE_SANITIZER}" STREQUAL "asan")
set(CMAKE_CXX_FLAGS_SAN
"-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
CACHE STRING "AddressSanitizer C++ compiler builds." FORCE)
elseif("${ENABLE_SANITIZER}" STREQUAL "ubsan")
set(CMAKE_CXX_FLAGS_SAN
"-fsanitize=undefined"
CACHE STRING "UndefinedBehaviorSanitizer C++ compiler builds." FORCE)
elseif("${ENABLE_SANITIZER}" STREQUAL "msan")
set(CMAKE_CXX_FLAGS_SAN
"-fsanitize=memory"
CACHE STRING "MemorySanitizer C++ compiler builds." FORCE)
elseif("${ENABLE_SANITIZER}" STREQUAL "tsan")
set(CMAKE_CXX_FLAGS_SAN
"-fsanitize=thread"
CACHE STRING "ThreadSanitizer C++ compiler builds." FORCE)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_SAN}")
endif()
#-----------------------------------------------------------------------
# verify code coverage compiler support
#-----------------------------------------------------------------------
if(ENABLE_GCOV)
if(GCOV_SUPPORTED)
message(STATUS "GCOV is enabled")
else()
message(FATAL_ERROR "ENABLE_GCOV was specified but compiler does not support GCC coverage flag")
endif()
endif(ENABLE_GCOV)
#-------------------------------------------------------------------------------
# Check SIMD alignment for CPU only
#-------------------------------------------------------------------------------
# This is intentionally placed before adding OpenMP offload compile options
# to avoid contamination from device compilation pass.
# When '-march=skylake-avx512 -fopenmp-targets=nvptx64 -march=sm_70' is added
# for Clang, the source code is parsed twice for both host and offload targets.
# A trap for macro __AVX512F__ always fails because the offload pass doesn't
# carry '-march=skylake-avx512' but only takes '-march=sm_70'.
#-------------------------------------------------------------------------------
include(CheckSIMDAlignment)
set(QMC_SIMD_ALIGNMENT
${default_alignment}
CACHE STRING "Cache/SIMD alignment in bytes")
math(EXPR alignment_remainder "${QMC_SIMD_ALIGNMENT} % ${default_alignment}")
if(alignment_remainder)
message(
FATAL_ERROR
"QMC_SIMD_ALIGNMENT must be a multiple of ${default_alignment}. Bad cached value is ${QMC_SIMD_ALIGNMENT}")
endif()
message(STATUS "QMC_SIMD_ALIGNMENT is set to ${QMC_SIMD_ALIGNMENT}")
#---------------------------------------------------------
# Determine if OpenMP taskloop works with the CXX compiler
#---------------------------------------------------------
include(TestOpenMPtaskloop)
option(ENABLE_OMP_TASKLOOP "Enable OpenMP taskloop" ${OMP_TASKLOOP_OKAY})
message(STATUS "ENABLE_OMP_TASKLOOP is set to ${ENABLE_OMP_TASKLOOP}")
#---------------------------------------------------------
# Set up OpenMP offload compile options
#---------------------------------------------------------
set(QMC_OFFLOAD_MEM_ASSOCIATED_DEFAULT OFF)
set(QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL_DEFAULT OFF)
if(ENABLE_OFFLOAD AND DEFINED OPENMP_OFFLOAD_COMPILE_OPTIONS)
message(STATUS "OpenMP offload CXX flags: ${OPENMP_OFFLOAD_COMPILE_OPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENMP_OFFLOAD_COMPILE_OPTIONS}")
if(${COMPILER} MATCHES "Clang"
AND OPENMP_OFFLOAD_COMPILE_OPTIONS MATCHES "amdgcn"
AND QMC_CUDA2HIP)
# As of 11/2021, QMC_OFFLOAD_MEM_ASSOCIATED=ON is needed for AMD and mainline LLVM compilers
# when using OpenMP offload to AMD GPU together with HIP.
set(QMC_OFFLOAD_MEM_ASSOCIATED_DEFAULT ON)
endif()
if(${COMPILER} MATCHES "Clang" AND OPENMP_OFFLOAD_COMPILE_OPTIONS MATCHES "amdgcn")
# As of 11/2021, QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL=ON is needed for
# ROCM/AOMP compilers when using OpenMP offload to AMD GPU.
set(QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL_DEFAULT ON)
endif()
endif()
# Some OpenMP offload runtime libraries have composibility issue with a vendor native runtime.
# A workaround is making the vendor native runtime responsible for memory allocations and OpenMP associate/disassocate them.
cmake_dependent_option(QMC_OFFLOAD_MEM_ASSOCIATED "Manage OpenMP memory allocations via the vendor runtime"
${QMC_OFFLOAD_MEM_ASSOCIATED_DEFAULT} "ENABLE_OFFLOAD;ENABLE_CUDA" OFF)
cmake_dependent_option(QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL "ROCM compiler offload bug workaround"
${QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL_DEFAULT} "ENABLE_OFFLOAD" OFF)
if(QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL)
message(WARNING "QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL=ON hurts performance. "
"As of 11/2021, QMC_OFFLOAD_ROCM_WORKAROUND_BRANCH_IN_PARALLEL=ON is needed for "
"ROCM/AOMP compilers when using OpenMP offload to AMD GPU. See bug report "
"https://github.com/ROCm-Developer-Tools/aomp/issues/255")
endif()
#-------------------------------------------------------------------------------------
# consider making this always on if OpenMP is no longer UB with Thread Support Library
# We should test out abstractions consistently and c++17 stdlib's all have support for
# std::thread and std::atomic
#-------------------------------------------------------------------------------------
if(QMC_EXP_THREADING)
include(CheckAtomic)
if(HAVE_LIBATOMIC)
link_libraries("${HAVE_LIBATOMIC}")
endif(HAVE_LIBATOMIC)
add_definitions(-DQMC_EXP_THREADING)
endif(QMC_EXP_THREADING)
#-------------------------------------------------------------------
# Check MPI installation. MPI is treated as a part of compiler
#-------------------------------------------------------------------
if(QMC_MPI)
# for backward compatibility with MPIEXEC
if(DEFINED MPIEXEC AND NOT DEFINED MPIEXEC_EXECUTABLE)
message(
WARNING
"Setting MPIEXEC_EXECUTABLE based on MPIEXEC. MPIEXEC has been deprecated! Use MPIEXEC_EXECUTABLE instead!")
set(MPIEXEC_EXECUTABLE ${MPIEXEC})
endif(DEFINED MPIEXEC AND NOT DEFINED MPIEXEC_EXECUTABLE)
set(MPI_CXX_SKIP_MPICXX
TRUE
CACHE BOOL "Must be TRUE for QMCPACK. Cached for working around CMake FindMPI issue.")
if(NOT CMAKE_CROSSCOMPILING)
set(MPI_DETERMINE_LIBRARY_VERSION TRUE)
endif()
find_package(MPI COMPONENTS CXX)
if(NOT MPI_FOUND)
message(
FATAL_ERROR
"MPI support not found! Provide MPI compiler wrappers or build without MPI by passing '-DQMC_MPI=0' to cmake.")
endif(NOT MPI_FOUND)
if(${MPI_CXX_LIBRARY_VERSION_STRING} MATCHES "MVAPICH2")
string(REGEX REPLACE "\n" ";" ONE_LINE "${MPI_CXX_LIBRARY_VERSION_STRING}")
string(REGEX REPLACE " +|\t" ";" ONE_LINE "${ONE_LINE}")
list(GET ONE_LINE 3 MVAPICH2_VERSION)
message(STATUS "MVAPICH2 version ${MVAPICH2_VERSION}")
if(${MVAPICH2_VERSION} VERSION_LESS "2.4" AND NOT ${MPI_CXX_LIBRARY_VERSION_STRING} MATCHES
"disable-registration-cache")
message(
FATAL_ERROR
"MVAPICH2 (version < 2.4) with registration cache enabled breaks QMCPACK. "
"Use a different MPI library or a MVAPICH2 >=2.4 "
"or build MVAPICH2 with --disable-registration-cache configure option.")
endif()
endif()
if(${MPI_CXX_LIBRARY_VERSION_STRING} MATCHES "Open MPI")
if(NOT MPIEXEC_PREFLAGS)
set(MPIEXEC_PREFLAGS "--bind-to;none")
message(STATUS "Detected Open MPI. Setting bind-to options for thread affinity in MPIEXEC_PREFLAGS.")
else(NOT MPIEXEC_PREFLAGS)
if(NOT "${MPIEXEC_PREFLAGS}" MATCHES "--bind-to")
message(
WARNING "Default Open MPI thread affinity policy may bind all the threads to a single core and "
"significantly slow down testing. Add proper --bind-to options via MPIEXEC_PREFLAGS. "
"If you don't know exactly what affinity to add, "
"add '--bind-to;none' to your current MPIEXEC_PREFLAGS to stop this warning.")
endif()
endif(NOT MPIEXEC_PREFLAGS)
endif()
if(NOT ${CMAKE_CXX_COMPILER} STREQUAL ${MPI_CXX_COMPILER})
set(MPI_WARNING_LIST
"Building MPI version without using MPI compiler wrappers.\n"
"This may not build qmcpack correctly. To ensure the correct version, specify the compiler wrappers to cmake.\n"
"For example: cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpic++\n"
"To build without MPI, pass '-DQMC_MPI=0' to cmake")
message(WARNING ${MPI_WARNING_LIST})
endif()
message(STATUS "MPI runner MPIEXEC_EXECUTABLE : ${MPIEXEC_EXECUTABLE}")
message(STATUS "MPIEXEC_NUMPROC_FLAG : ${MPIEXEC_NUMPROC_FLAG}")
message(STATUS "MPIEXEC_PREFLAGS : ${MPIEXEC_PREFLAGS}")
string(REPLACE ";" " " MPIEXEC_PREFLAGS_PRINT "${MPIEXEC_PREFLAGS}")
message(
STATUS "Tests run as : ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} NUM_PROCS ${MPIEXEC_PREFLAGS_PRINT} EXECUTABLE"
)
set(HAVE_MPI 1)
message(STATUS "MPI is enabled")
else(QMC_MPI)
set(HAVE_MPI 0)
message(STATUS "MPI is disabled")
endif(QMC_MPI)
#--------------------------------------------------------------
# final test for compile options before searching for libraries
#--------------------------------------------------------------
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main(){}" TEST_CXX_COMPILE_MAIN)
if (NOT TEST_CXX_COMPILE_MAIN)
unset(TEST_CXX_COMPILE_MAIN CACHE)
message(FATAL_ERROR "Failed in compiling a main() function likely due to incorrect compile options. "
"Check error in \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeError.log\".")
endif()
######################################################################
# Check external libraries.
######################################################################
#-------------------------------------------------------------------
# check OS related libraries
#-------------------------------------------------------------------
include(CheckFunctionExists)
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
#-------------------------------------------------------------------
# Check LAPACK/BLAS
#-------------------------------------------------------------------
# Add Math::BLAS_LAPACK target
add_library(Math::BLAS_LAPACK INTERFACE IMPORTED)
foreach(MKL_LIB_PATH IN ITEMS ${MKL_ROOT} $ENV{MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_HOME})
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${MKL_LIB_PATH}/lib/intel64)
endforeach()
if(NOT BLA_VENDOR)
message(STATUS "Trying to find LAPACK from Intel MKL")
if(QMC_OMP AND COMPILER STREQUAL "Intel")
set(BLA_VENDOR Intel10_64lp)
else()
set(BLA_VENDOR Intel10_64lp_seq)
endif()
find_package(LAPACK)
if(NOT LAPACK_FOUND)
message(STATUS "Intel MKL library files not found via FindLAPACK.")
message(STATUS "Trying to find alternative LAPACK libraries")
set(BLA_VENDOR All)
find_package(LAPACK REQUIRED)
endif()
else()
message(STATUS "Trying to find LAPACK library as requested BLA_VENDOR=${BLA_VENDOR}")
find_package(LAPACK REQUIRED)
endif()
message(STATUS "LAPACK linker flags: ${LAPACK_LINKER_FLAGS}")
message(STATUS "LAPACK libraries: ${LAPACK_LIBRARIES}")
set_target_properties(Math::BLAS_LAPACK PROPERTIES INTERFACE_LINK_LIBRARIES
"${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}")
#create scalar_vector_functions target
add_library(Math::scalar_vector_functions INTERFACE IMPORTED)
#create fftw3 target
add_library(Math::FFTW3 INTERFACE IMPORTED)
# Detects MKL header files and other components.
if(LAPACK_LIBRARIES MATCHES "mkl_core")
include(FindMKL)
endif()
if(MKL_FOUND)
set(MATH_VENDOR_GUESS "INTEL_VML")
endif()
# AFQMC requires MKL sparse for good performance (roughly a factor of 2x)
if(BUILD_AFQMC AND NOT MKL_FOUND)
message(
WARNING
"AFQMC - MKL not found, using simple sparse matrix routines. Link with MKL sparse libraries for better performance."
)
endif()
#-------------------------------------------------------------------
# set up scalar/vector math libraries
#-------------------------------------------------------------------
set(VALID_MATH_VENDORS "GENERIC" "INTEL_VML" "IBM_MASS" "AMD_LIBM")
if(NOT DEFINED MATH_VENDOR_GUESS)
set(MATH_VENDOR_GUESS "GENERIC")
endif()
set(QMC_MATH_VENDOR
${MATH_VENDOR_GUESS}
CACHE STRING "Vendor optimized libraries for scalar and vector math functions")
# Perform math vendor option check
if(NOT QMC_MATH_VENDOR IN_LIST VALID_MATH_VENDORS)
message(FATAL_ERROR "Invalid vendor math library ${QMC_MATH_VENDOR}, value must be one of ${VALID_MATH_VENDORS}")
else()
message(STATUS "Selected vendor math library ${QMC_MATH_VENDOR}")
endif()
# This needs to go before HAVE_SINCOS
if(QMC_MATH_VENDOR STREQUAL "INTEL_VML")
include(FindMKLVML)
elseif(QMC_MATH_VENDOR STREQUAL "IBM_MASS")
include(FindIBMMASS)
elseif(QMC_MATH_VENDOR STREQUAL "AMD_LIBM")
include(FindAMDLibM)
endif()
# CheckSincos relies on SINCOS_INCLUDE which may be modified based on vendor libraries
if(NOT SINCOS_INCLUDE)
set(SINCOS_INCLUDE cmath)
endif(NOT SINCOS_INCLUDE)
message(STATUS "SINCOS_INCLUDE : ${SINCOS_INCLUDE}")
include(CheckSincos)
#-------------------------------------------------------------------
# set up FFTW3 library
#-------------------------------------------------------------------
set(FFTW_FOUND 0)
if(HAVE_MKL)
if(HAVE_MKL_FFTW3)
set(FFTW_FOUND 1)
endif()
endif()
if(NOT FFTW_FOUND)
find_package(FFTW)
endif()
if(FFTW_FOUND)
set(HAVE_LIBFFTW 1)
message(STATUS "Found FFTW")
else(FFTW_FOUND)
# MESSAGE(STATUS "Disabling FFTW")
message(FATAL_ERROR "Could not find required library FFTW. Verify FFTW_HOME")
endif(FFTW_FOUND)
set(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES})
#-------------------------------------------------------------------
# set up Libxml2 library
#-------------------------------------------------------------------
find_package(ZLIB)
find_package(LibXml2 REQUIRED)
#-------------------------------------------------------------------
# set up HDF5 library
#-------------------------------------------------------------------
if(HAVE_MPI)
set(HDF5_PREFER_PARALLEL
TRUE
CACHE BOOL "Request parallel/serial HDF5 library")
else(HAVE_MPI)
set(HDF5_PREFER_PARALLEL
FALSE
CACHE BOOL "Request parallel/serial HDF5 library")
if(HDF5_PREFER_PARALLEL)
message(FATAL_ERROR "Parallel HDF5 library cannot be selected with QMCPACK non-MPI build. "
"Please set HDF5_PREFER_PARALLEL=0.")
endif(HDF5_PREFER_PARALLEL)
endif(HAVE_MPI)
if(QMC_BUILD_STATIC)
message(STATUS "Linking static HDF5 library")
set(HDF5_USE_STATIC_LIBRARIES on)
else()
message(STATUS "Linking dynamic HDF5 library")
set(HDF5_USE_STATIC_LIBRARIES off)
endif()
find_package(HDF5 COMPONENTS C)
if(HDF5_FOUND)
set(HAVE_LIBHDF5 1)
if(HDF5_IS_PARALLEL)
message(STATUS "Parallel HDF5 library found")
option(ENABLE_PHDF5 "Enable code paths using parallel HDF5" ON)
else(HDF5_IS_PARALLEL)
message(STATUS "Serial HDF5 library found")
option(ENABLE_PHDF5 "Enable code paths using parallel HDF5" OFF)
if(ENABLE_PHDF5)
if(HAVE_MPI)
message(FATAL_ERROR "Parallel HDF5 code paths requested but serial HDF5 library found! "
"Please either provide parallel HDF5 library or set ENABLE_PHDF5=0.")
else(HAVE_MPI)
message(FATAL_ERROR "Parallel HDF5 code paths cannot be enabled on non-MPI builds! Please set ENABLE_PHDF5=0.")
endif(HAVE_MPI)
endif(ENABLE_PHDF5)
endif(HDF5_IS_PARALLEL)
if(ENABLE_PHDF5)
message(STATUS "Using HDF5 parallel collective I/O code paths")
else(ENABLE_PHDF5)
message(STATUS "Using HDF5 non-scalable serial I/O code paths")
endif(ENABLE_PHDF5)
if(HAVE_MPI AND NOT ENABLE_PHDF5)
message(
WARNING
"MPI builds may have performance loss by not using parallel HDF5! (Safe to ignore for workstation builds).")
endif()
if(CMAKE_BUILD_TYPE AND HDF5_LIBRARIES_DEBUG)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(HDF5_LIBRARIES ${HDF5_LIBRARIES_DEBUG})
else()
set(HDF5_LIBRARIES ${HDF5_LIBRARIES_RELEASE})
endif()
endif()
add_library(IO::HDF5 INTERFACE IMPORTED)
set_target_properties(
IO::HDF5
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS
"HAVE_LIBHDF5;H5_USE_16_API" INTERFACE_LINK_LIBRARIES
"${HDF5_LIBRARIES}")
if(ENABLE_PHDF5)
set_property(TARGET IO::HDF5 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "ENABLE_PHDF5")
endif(ENABLE_PHDF5)
else(HDF5_FOUND)
message(FATAL_ERROR "HDF5 not found. Set HDF5_ROOT")
endif(HDF5_FOUND)
#-------------------------------------------------------------------
# set up libboost library, header only
#-------------------------------------------------------------------
set(Boost_NO_BOOST_CMAKE on)
find_package(Boost 1.61.0 REQUIRED)
if(Boost_FOUND)
set_property(TARGET Boost::boost APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "HAVE_LIBBOOST")
message(STATUS "Setting Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "Need boost 1.61.0 or higher. Set BOOST_ROOT")
endif()
#-------------------------------------------------------------------
# set up CUDA compiler options and libraries
#-------------------------------------------------------------------
set(HAVE_CUDA 0)
if(QMC_CUDA OR ENABLE_CUDA)
if(QMC_CUDA2HIP)
message(STATUS "CUDA2HIP enabled") # all the HIP and ROCm settings will be handled by ENABLE_ROCM
else(QMC_CUDA2HIP)
if(CMAKE_VERSION VERSION_LESS 3.18.0)
message(FATAL_ERROR "QMC_CUDA or ENABLE_CUDA require CMake 3.18.0 or later")
endif()
# a few production machines use CUDA 10 which only supports C++14.
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14)
endif()
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
set(CMAKE_CUDA_EXTENSIONS OFF)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
if(NOT TARGET CUDA::cublas)
message(FATAL_ERROR "Found an incomplete CUDA toolkit installation. "
"This often happens when CMake failed in recognizing the NVHPC internal CUDA toolkit. "
"Set CMAKE_CUDA_COMPILER to the full path of nvcc from a complete CUDA toolkit installation.")
endif()
# Automatically set the default NVCC flags
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Drestrict=__restrict__ -DNO_CUDA_MAIN")
if(QMC_COMPLEX)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DQMC_COMPLEX=${QMC_COMPLEX}")
endif()
set(HAVE_CUDA 1)
message("Project CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}")
endif()
else(QMC_CUDA OR ENABLE_CUDA)
if(QMC_CUDA2HIP)
message(FATAL_ERROR "QMC_CUDA2HIP requires QMC_CUDA=ON or ENABLE_CUDA=ON.")
endif()
message(STATUS "CUDA disabled")
endif(QMC_CUDA OR ENABLE_CUDA)
if(USE_NVTX_API)
message(STATUS "Enabling use of CUDA NVTX APIs")
find_library(
NVTX_API_LIB NAME nvToolsExt
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64)
if(NOT NVTX_API_LIB)
message(FATAL_ERROR "USE_NVTX_API set but NVTX_API_LIB not found")
endif(NOT NVTX_API_LIB)
message("CUDA nvToolsExt library: ${NVTX_API_LIB}")
link_libraries(${NVTX_API_LIB})
else()
message(STATUS "CUDA NVTX APIs disabled")
endif(USE_NVTX_API)
#-------------------------------------------------------------------
# set up ROCM compiler options and libraries
#-------------------------------------------------------------------
if(ENABLE_ROCM)
if(ROCM_ROOT)
message(STATUS "ROCM_ROOT provided. Searching for FindHIP.cmake file")
find_path(
HIP_MODULE_FILE_DIR FindHIP.cmake
HINTS ${ROCM_ROOT}
PATH_SUFFIXES hip/cmake REQUIRED
NO_DEFAULT_PATH)
else()
message(STATUS "ROCM_ROOT not provided. Searching for FindHIP.cmake file.")
find_path(
HIP_MODULE_FILE_DIR FindHIP.cmake
HINTS /opt/rocm
PATH_SUFFIXES hip/cmake)
if(HIP_MODULE_FILE_DIR)
message(STATUS "Found FindHIP.cmake file. ROCM_ROOT will be derived.")
else()
message(FATAL_ERROR "Failed to find FindHIP.cmake file. Please set ROCM_ROOT to your ROCm installation.")
endif()
string(REGEX REPLACE "\/hip\/cmake" "" ROCM_ROOT "${HIP_MODULE_FILE_DIR}")
endif()
message(STATUS "Using ROCM_ROOT: ${ROCM_ROOT}")
list(APPEND CMAKE_MODULE_PATH ${HIP_MODULE_FILE_DIR})
list(APPEND CMAKE_PREFIX_PATH ${ROCM_ROOT})
# need FindHIP for hip_add_library similar to deprecated FindCUDA style
find_package(HIP MODULE REQUIRED)
# need hip in config mode for hip::host target.
find_package(hip CONFIG REQUIRED)
find_package(hipblas CONFIG REQUIRED)
find_package(rocsolver CONFIG REQUIRED)
find_package(rocthrust CONFIG REQUIRED)
# architecture flags
set(HIP_ARCH
"gfx906,gfx908"
CACHE STRING "HIP architecture gfxXXX")
list(APPEND HIP_HIPCC_FLAGS "-fPIC -ffast-math -O3 -std=c++14")
list(APPEND HIP_HIPCC_FLAGS "--amdgpu-target=${HIP_ARCH}")
list(APPEND HIP_HIPCC_FLAGS "--gpu-max-threads-per-block=256")
# warning suppression
list(APPEND HIP_HIPCC_FLAGS "-Wno-vla")
list(APPEND HIP_HIPCC_FLAGS "-Wno-deprecated-declarations")
list(APPEND HIP_HIPCC_FLAGS "-Wno-unused-command-line-argument")
if(BUILD_AFQMC)
find_package(rocrand CONFIG REQUIRED)
# connect ROCm shipped libraries
add_library(ROCM::libraries INTERFACE IMPORTED)
# temporarily put rocsolver rocrand here for convenience, should be moved to Platforms.
target_link_libraries(ROCM::libraries INTERFACE roc::rocsolver roc::rocrand)
endif()
endif(ENABLE_ROCM)
#-------------------------------------------------------------------
# set up HIP compiler options
#-------------------------------------------------------------------
if(ENABLE_HIP)
if(NOT ENABLE_ROCM)
message(FATAL_ERROR "ROCM is required to use HIP. Please set ENABLE_ROCM=ON.")
endif()
find_package(hipsparse CONFIG REQUIRED)
add_library(HIP::HIP INTERFACE IMPORTED)
# temporarily put hipsparse hipblas here for convenience, should be moved to Platforms.
target_link_libraries(HIP::HIP INTERFACE roc::hipsparse roc::hipblas)
target_compile_definitions(HIP::HIP INTERFACE "ENABLE_HIP")
# FindHIP sets HIP_PLATFORM to amd or nvcc
message(STATUS "FindHIP determined HIP_PLATFORM is ${HIP_PLATFORM}.")
if(HIP_PLATFORM STREQUAL "amd")
target_compile_definitions(HIP::HIP INTERFACE "__HIP_PLATFORM_AMD__")
elseif(HIP_PLATFORM STREQUAL "nvcc")
target_compile_definitions(HIP::HIP INTERFACE "__HIP_PLATFORM_NVIDIA__")
else()
message(FATAL_ERROR "Unknown HIP platform ${HIP_PLATFORM} only support 'amd' or 'nvcc'")
endif()
endif(ENABLE_HIP)
#-------------------------------------------------------------------
# set up VTune ittnotify library
#-------------------------------------------------------------------
if(USE_VTUNE_API)
message(STATUS "Enabling use of VTune ittnotify APIs")
find_path(
VTUNE_ITTNOTIFY_INCLUDE_DIR ittnotify.h
HINTS ${VTUNE_ROOT} $ENV{VTUNE_ROOT}
PATH_SUFFIXES include REQUIRED)
message(STATUS "Found VTUNE_ITTNOTIFY_INCLUDE_DIR ${VTUNE_ITTNOTIFY_INCLUDE_DIR}")
find_library(
VTUNE_ITTNOTIFY_LIBRARY ittnotify
HINTS ${VTUNE_ROOT} $ENV{VTUNE_ROOT}
PATH_SUFFIXES lib64 lib REQUIRED)
message(STATUS "Found VTUNE_ITTNOTIFY_LIBRARY ${VTUNE_ITTNOTIFY_LIBRARY}")
include_directories(${VTUNE_ITTNOTIFY_INCLUDE_DIR})
link_libraries(${VTUNE_ITTNOTIFY_LIBRARY})
if(USE_VTUNE_TASKS)
message(STATUS "VTune ittnotify tasks enabled")
endif()
else()
message(STATUS "VTune ittnotify APIs disabled")
endif()
#-------------------------------------------------------------------
# Add user extra flags
#-------------------------------------------------------------------
if(QMC_INCLUDE)
foreach(tmp ${QMC_INCLUDE})
message(STATUS "Adding '${tmp}' to include directories")
include_directories("${tmp}")
endforeach()
endif()
if(QMC_EXTRA_LIBS)
string(REPLACE " " ";" QMC_EXTRA_LIBS ${QMC_EXTRA_LIBS})
set(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${QMC_EXTRA_LIBS})
message("QMC_UTIL_LIBS=${QMC_UTIL_LIBS}")
endif()
if(BUILD_AFQMC AND NOT APPLE)
link_libraries("rt")
endif()
######################################################################
# All the settings related to building QMCPACK are complete
######################################################################
#include build/src
include_directories(${qmcpack_BINARY_DIR}/src)
#include qmcpack/src
include_directories(${PROJECT_SOURCE_DIR}/src)
#-------------------------------------------------------------------
# add definitions DO NOT EXPAND
#-------------------------------------------------------------------
add_definitions(-DHAVE_CONFIG_H -DUSE_REAL_STRUCT_FACTOR -DADD_)
#-------------------------------------------------------------------
# qmcpack.settings
#-------------------------------------------------------------------
execute_process(
COMMAND hostname
OUTPUT_VARIABLE QMC_HOSTNAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(${qmcpack_SOURCE_DIR}/src/qmcpack.settings ${qmcpack_BINARY_DIR}/bin/qmcpack.settings)
install(FILES ${qmcpack_BINARY_DIR}/bin/qmcpack.settings DESTINATION bin)
#-------------------------------------------------------------------
# FLAGS at the project level
#-------------------------------------------------------------------
#this might be redundant but maybe not in all CMake versions.
string(TOUPPER "${CMAKE_BUILD_TYPE}" THIS_CONFIG)
foreach(lang IN ITEMS C CXX)
set(PROJECT_CMAKE_${lang}_FLAGS ${CMAKE_${lang}_FLAGS})
#pre 3.0 cmake does not have string CONCAT
set(TMP_PROJECT_CMAKE_${lang}_FLAGS "${PROJECT_CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${THIS_CONFIG}}")
message("Project ${lang}_FLAGS: ${TMP_PROJECT_CMAKE_${lang}_FLAGS}")
endforeach(lang IN ITEMS C CXX)
get_directory_property(TMP_PROJECT_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES)
message("Project INCLUDE_DIRECTORIES: ${TMP_PROJECT_INCLUDE_DIRECTORIES}")
foreach(target_type IN ITEMS EXE SHARED)
set(PROJECT_CMAKE_${target_type}_LINKER_FLAGS ${CMAKE_${target_type}_LINKER_FLAGS})
set(TMP_PROJECT_CMAKE_${target_type}_LINKER_FLAGS
"${PROJECT_CMAKE_${target_type}_LINKER_FLAGS} ${CMAKE_${target_type}_LINKER_FLAGS_${THIS_CONFIG}}")
message("Project ${target_type}_LINKER_FLAGS: ${TMP_PROJECT_CMAKE_${target_type}_LINKER_FLAGS}")
endforeach(target_type IN ITEMS EXE SHARED)
#-------------------------------------------------------------------
# Git information (see src/CMakeLists.txt for the
# command to get repository information)
#-------------------------------------------------------------------
find_package(Git)
if(GIT_FOUND AND EXISTS "${qmcpack_SOURCE_DIR}/.git")
set(IS_GIT_PROJECT 1)
endif()
# set up config.h
configure_file(${qmcpack_SOURCE_DIR}/src/config.h.cmake.in ${qmcpack_BINARY_DIR}/src/config.h)
######################################################################
# Testing related settings
######################################################################
# The following option disables the extremely slow setup of full system run tests
# This is a developer option
# It offers a more reasonable compile debug loop if CMakeLists.txt files are being changed
# These constom commands execution time far exceeds even the feature and compiler checks for time consumed
# when rerunning cmake.
#
# On leconte: rerun of cmake with
# slow custom commands 27 secs
# without 8 secs
option(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS "Disable the slow cmake custom commands for integration tests." OFF)
mark_as_advanced(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
if(NOT TEST_MAX_PROCS)
set(TEST_MAX_PROCS 100)
endif()
option(QMC_SYMLINK_TEST_FILES "Use symbolic links for test files to save space. Set to false to copy files instead."
ON)
if(QMC_SYMLINK_TEST_FILES)
set(SYMLINK_MSG
"Using symbolic links for large test files may cause test failures if the build is installed on a separate filesystem from the source."
)
else()
set(SYMLINK_MSG "Copying large test files uses more disk space than using symbolic links.")
endif()
message(STATUS "QMC_SYMLINK_TEST_FILES = ${QMC_SYMLINK_TEST_FILES}. ${SYMLINK_MSG}")
if(QMC_DATA)
message(STATUS "QMC_DATA is ${QMC_DATA}")
endif()
#-------------------------------------------------------------------
# CTest
#-------------------------------------------------------------------
set(DROP_METHOD "http")
set(DROP_SITE "cdash.qmcpack.org")
set(DROP_LOCATION "/CDash/submit.php?project=QMCPACK")
set(TRIGGER_SITE "")
set(DROP_SITE_CDASH TRUE)
# Increase timeout per test over the default of 1500 seconds (25 minutes)
set(DART_TESTING_TIMEOUT