-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
850 lines (762 loc) · 29.9 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
PROJECT(qmcpack)
#####################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
######################################################################
# Version
######################################################################
SET(QMCPACK_VERSION_MAJOR 3)
SET(QMCPACK_VERSION_MINOR 1)
SET(QMCPACK_VERSION_PATCH 0)
SET(QMCPACK_VERSION "${QMCPACK_VERSION_MAJOR}.${QMCPACK_VERSION_MINOR}.${QMCPACK_VERSION_PATCH}")
######################################################################
# 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 3600 CACHE STRING "Maximum time for one test")
ENABLE_TESTING()
INCLUDE( CTest )
######################################################################
# Build level
######################################################################
SET(QMC_BUILD_LEVEL 5 CACHE INTEGER
"QMC Build Level: 1=bare, 2=developer, 3=experimental, 4=minimal, 5=miniapps")
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}")
######################################################################
#define the paths for library and executable for out-of-soruce compilation
######################################################################
SET (LIBRARY_OUTPUT_PATH ${qmcpack_BINARY_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${qmcpack_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
######################################################################
# build include and library paths required for the projects
# For XYZ library, set an environment as
# export XYZ_HOME='root-of-the-library'
# XYZ_HOME/include
# XYZ_HOME/lib
# IF XYZ library is found, XYZ_FOUND is set to true
#
# find_package is used with cmake 2.8 and higher
######################################################################
#if(APPLE)
# set(QMC_INCLUDE_PATHS ${QMC_INCLUDE_PATHS} /sw/include)
# set(QMC_LIBRARY_PATHS ${QMC_LIBRARY_PATHS} /sw/lib)
#endif(APPLE)
######################################################################
# Set the compiler-time parameters
# 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
# QMC_COMPLEX = true if using complex wavefunctions
# QMC_MPI = enable MPI
# QMC_OMP = enable OMP
# QMC_BITS = 32/64 bit
######################################################################
SET(OHMMS_DIM 3 CACHE INTEGER "Select physical dimension")
SET(OHMMS_INDEXTYPE int)
MESSAGE(STATUS "defining the float point precision")
SET(OHMMS_PRECISION_FULL double)
SET(QMC_MIXED_PRECISION 0 CACHE BOOL "Enable/disable mixed precision")
IF(QMC_MIXED_PRECISION)
SET(OHMMS_PRECISION float)
SET(MIXED_PRECISION 1)
ELSE(QMC_MIXED_PRECISION)
SET(OHMMS_PRECISION double)
ENDIF(QMC_MIXED_PRECISION)
MESSAGE(" Base precision = ${OHMMS_PRECISION}")
MESSAGE(" Full precision = ${OHMMS_PRECISION_FULL}")
# Code coverage
SET(GCOV_SUPPORTED FALSE)
SET(ENABLE_GCOV FALSE CACHE BOOL "Enable code coverage")
######################################################################
# enable MPI and OPNEMP if possible
######################################################################
SET(QMC_MPI 1 CACHE BOOL "Enable/disable MPI")
SET(QMC_OMP 1 CACHE BOOL "Enable/disable OpenMP")
SET(QMC_BITS 64 CACHE INTEGER "Select OS bit")
SET(QMC_COMPLEX 1 CACHE INTEGER "Build for complex binary")
SET(PRINT_DEBUG 0 CACHE BOOL "Enable/disable debug printing")
######################################################################
# set debug printout
# DEBUG_PSIBUFFER_ON keep track buffer's locator
######################################################################
SET(DEBUG_PSIBUFFER_ON 0 CACHE BOOL "Build with GPU support through CUDA")
######################################################################
# check environment variables
# todo: disallow environment
######################################################################
IF($ENV{QMC_MPI})
SET(QMC_MPI $ENV{QMC_MPI})
MESSAGE(STATUS "Found environment QMC_MPI=${QMC_MPI}")
ENDIF($ENV{QMC_MPI})
IF($ENV{QMC_OMP})
SET(QMC_OMP $ENV{QMC_OMP})
MESSAGE(STATUS "Found environment QMC_OMP=${QMC_OMP}")
ENDIF($ENV{QMC_OMP})
IF($ENV{QMC_BITS})
SET(QMC_BITS $ENV{QMC_BITS})
MESSAGE(STATUS "Found environment QMC_BITS=${QMC_BITS}")
ENDIF($ENV{QMC_BITS})
IF($ENV{QMC_COMPLEX})
SET(QMC_COMPLEX $ENV{QMC_COMPLEX})
MESSAGE(STATUS "Found environment QMC_COMPLEX=${QMC_COMPLEX}")
ENDIF($ENV{QMC_COMPLEX})
######################################################################
# Standard test
######################################################################
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
######################################################################
# add macros to compile einspline if necessary
######################################################################
INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
CHECK_FUNCTION_EXISTS(sincos HAVE_SINCOS)
CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN)
CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H)
CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H)
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
######################################################################
# Build options
# QMC_BUILD_STATIC build static/dynamic libraries
# BUILD_QMCTOOLS build utility programs
# BUILD_SANDBOX build test programs
# BUILD_MINIAPPS build miniapps (Incomplete)
# MPIP_PROFILE profile mpi performance
######################################################################
SET(QMC_ADIOS 0 CACHE BOOL "Build with ADIOS")
SET(BUILD_UNIT_TESTS 1 CACHE BOOL "Build unit tests")
SET(BUILD_MINIAPPS 1 CACHE BOOL "Build miniapps")
SET(BUILD_LMYENGINE_INTERFACE 1 CACHE BOOL "Build LMY engine")
iF(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE)
MESSAGE(STATUS "LMY engine is not compatiable with CPU mixed precision build! Disabling LMY engine")
SET(BUILD_LMYENGINE_INTERFACE 0)
ENDIF()
SET(BUILD_AFQMC 1 CACHE BOOL "Build with AFQMC")
SET(QMC_BUILD_STATIC 0 CACHE BOOL "Link to static libraries")
SET(ENABLE_TIMERS 1 CACHE BOOL "Enable internal timers")
######################################################################
# Performance-related macros
# QMC_SK_USE_RECURSIVE enable/disable recursive evalaution of SK
######################################################################
SET(QMC_SK_USE_RECURSIVE 0)
IF($ENV{QMC_SK_RECURSIVE})
MESSAGE(STATUS "SK structure factor uses a recursive algorithm.")
SET(QMC_SK_USE_RECURSIVE $ENV{QMC_SK_RECURSIVE})
ENDIF($ENV{QMC_SK_RECURSIVE})
######################################################################
# FIXED PARAMETERS for test and legacy reasons
# DO NOT TOUCH THESE
# QMC_ORTHO = 0 for general unit cell, 1 for orthogonal cells
# QMC_FASTWALKER = true, when operation is faster for each walker
######################################################################
SET(QMC_FASTWALKER 1)
SET(OHMMS_ORTHO 0)
######################################################################
#list of options to determine libraries. First, try to use libraries available
#FindXYZ.cmake will set the values if successful
######################################################################
#SET(ENABLE_PHDF5 0 CACHE BOOL "Enable phdf5 for output")
SET(HAVE_LIBXML2 1)
SET(HAVE_LIBFFTW 0)
SET(HAVE_LIBXMLPP 0)
SET(HAVE_LIBHDF5 0)
SET(HAVE_LIBSPRNG 0)
SET(HAVE_LIBBLITZ 0)
SET(HAVE_LIBGSL 0)
SET(MAC_VECLIB 0)
SET(ENABLE_GTK_GUI 0)
set(ENABLE_TAU_PROFILE 0 CACHE BOOL "Enable tau for profiling")
set(TAU_HOME $ENV{TAU_HOME})
######################################################
# Directory where customize cmake files reside
######################################################
SET (PROJECT_CMAKE ${qmcpack_SOURCE_DIR}/CMake)
######################################################
# set ADIOS flags
######################################################
IF(QMC_ADIOS)
IF(NOT HAVE_ADIOS)
SET (ADIOS_FOUND 0)
INCLUDE(${PROJECT_CMAKE}/FindADIOS.cmake)
IF (${ADIOS_FOUND} EQUAL 1)
INCLUDE_DIRECTORIES(${ADIOS_INCLUDES})
MESSAGE(STATUS "Found ADIOS")
LINK_LIBRARIES(${ADIOS_LIBRARIES})
ADD_DEFINITIONS(-DHAVE_ADIOS)
ELSE()
MESSAGE(STATUS "Couldn't find required library ADIOS")
MESSAGE(FATAL_ERROR "ADIOS_HOME: export ADIOS_HOME=/path/to/adios")
ENDIF()
ELSE()
ADD_DEFINITIONS(-DHAVE_ADIOS)
ENDIF()
ENDIF(QMC_ADIOS)
SET(QMCPACK_UNIT_TEST_DIR ${qmcpack_BINARY_DIR}/tests/bin)
######################################################
# Git information (see src/CMakeLists.txt for the
# command to get repository information)
######################################################
FIND_PACKAGE(Git)
SET(IS_GIT_PROJECT false)
IF (EXISTS "${PROJECT_SOURCE_DIR}/.git")
SET(IS_GIT_PROJECT true)
ENDIF()
######################################################
#COMPILER choose one of the cmake files to customize the compiler options
#If nothing is chosen, default settings by cmake will be used.
#If the automatic detection does not work, comment out everything
#upto COMPILER MANUAL SELECTION and use one of the customized cmake file.
######################################################
INCLUDE(${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXCompilerFlag.cmake)
######################################################
# DO NOT MODIFY BELOW
# If you like to customize your build, create a toolchain as instructed
######################################################
######################################################
# now set the compiler flags and the macros in src/config.h
######################################################
IF(CMAKE_TOOLCHAIN_FILE)
MESSAGE(STATUS "Using ${CMAKE_TOOLCHAIN_FILE} toolchain ")
ELSE(CMAKE_TOOLCHAIN_FILE)
MESSAGE(STATUS "Trying to figure out .....")
SET(ENABLE_OPENMP 0)
SET(HAVE_MPI 0)
SET(INTEL_COMPILER 0)
SET(HAVE_MKL 0)
SET(HAVE_MKL_VML 0)
SET(HAVE_ACML 0)
SET(HAVE_SSE 0)
SET(HAVE_SSE2 0)
SET(HAVE_SSE3 0)
SET(HAVE_SSSE3 0)
SET(USE_PREFETCH 0)
SET(PREFETCH_AHEAD 12)
SET(HAVE_C_VARARRAYS 1)
######################################################
# Try to identify CPU identity
######################################################
SET(CPU_IDENTITY "generic")
#INCLUDE(${PROJECT_CMAKE}/CheckProcessorID.cmake)
#------------------------
# On Cray's machine
#------------------------
IF($ENV{CRAYPE_VERSION} MATCHES ".")
MESSAGE(STATUS "Running on a Cray machine.")
SET(CMAKE_SKIP_RPATH TRUE)
# Flags for ctest
SET(USE_EXT_MPI_FOR_SERIAL_TESTS 1)
FIND_PROGRAM(MPIEXEC aprun)
IF(NOT MPIEXEC)
# For slurm use srun
FIND_PROGRAM(MPIEXEC srun)
ENDIF(NOT MPIEXEC)
SET(MPIEXEC_NUMPROC_FLAG "-n")
IF(QMC_BUILD_STATIC)
MESSAGE(STATUS "Building CPU code. Linking statically.")
SET(BUILD_SHARED_LIBS off)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE)
SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-static")
SET(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-Bstatic")
SET(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-static")
ENDFOREACH(type)
ELSE(QMC_BUILD_STATIC)
MESSAGE(STATUS "Building CPU code. Linking dynamically.")
SET(CMAKE_EXE_LINKER_FLAGS "-dynamic")
ENDIF(QMC_BUILD_STATIC)
ENDIF($ENV{CRAYPE_VERSION} MATCHES ".")
#------------------------------------
# Identify the compiler
#------------------------------------
IF( $ENV{CXX} MATCHES "icpc" )
SET( COMPILER Intel )
ELSEIF($ENV{CXX} MATCHES "xlC" OR CMAKE_C_COMPILER_ID MATCHES "XL")
SET( COMPILER IBM )
ELSEIF ( CMAKE_C_COMPILER_WORKS OR CMAKE_C_COMPILER_WORKS )
IF( CMAKE_COMPILE_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
SET( COMPILER GNU )
ELSEIF( MSVC OR MSVC_IDE OR MSVC60 OR MSVC70 OR MSVC71 OR MSVC80 OR CMAKE_COMPILER_2005 OR MSVC90 OR MSVC10 )
SET( COMPILER Microsoft )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "Intel") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Intel") )
SET( COMPILER Intel )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "PGI") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "PGI") )
SET( COMPILER PGI )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "CRAY") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "CRAY") OR
(${CMAKE_C_COMPILER_ID} MATCHES "Cray") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Cray") )
SET( COMPILER Cray )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "CLANG") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "CLANG") OR
(${CMAKE_C_COMPILER_ID} MATCHES "Clang") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") )
SET( COMPILER Clang )
ELSE()
SET(USING_DEFAULT TRUE)
MESSAGE("${CMAKE_C_COMPILER_ID}")
MESSAGE(WARNING "Unknown C/C++ compiler, default flags will be used")
ENDIF()
ELSE()
MESSAGE(WARNING "No compiler identified")
ENDIF()
MESSAGE(STATUS "Compiler: ${COMPILER}")
#------------------------------------
# Include compiler-specific cmake file
#------------------------------------
IF( ${COMPILER} MATCHES "IBM" )
INCLUDE(${PROJECT_CMAKE}/IBMCompilers.cmake)
ELSEIF( ${COMPILER} MATCHES "Intel" )
INCLUDE(${PROJECT_CMAKE}/IntelCompilers.cmake)
ELSEIF( ${COMPILER} MATCHES "GNU" )
INCLUDE(${PROJECT_CMAKE}/GNUCompilers.cmake)
ELSEIF( ${COMPILER} MATCHES "Clang" )
INCLUDE(${PROJECT_CMAKE}/ClangCompilers.cmake)
ELSE()
MESSAGE(WARNING "No default file for compiler (${COMPILER})")
ENDIF()
#-------------------------------------------------------------------
# check MPI installation
#-------------------------------------------------------------------
IF(QMC_MPI)
## mpi compilers
GET_FILENAME_COMPONENT(BASE_CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
if(${BASE_CXX_COMPILER_NAME} MATCHES "^mp")
SET(HAVE_MPI 1)
SET(HAVE_OOMPI 1)
SET(MPI_FOUND TRUE)
elseif($ENV{CRAYPE_VERSION} MATCHES ".")
SET(HAVE_MPI 1)
SET(HAVE_OOMPI 1)
SET(MPI_FOUND TRUE)
else()
include(FindMPI)
IF(MPI_FOUND)
MESSAGE(STATUS "Found mpi.h and libraries. Check for working mpi compiler ")
INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH})
FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx
"#include <mpi.h>"
"int main(int argc, char** argv){MPI_Init(&argc,&argv); MPI_Finalize();return 0;}\n")
#TRY_COMPILE(MPI_WORKS ${CMAKE_BINARY_DIR}
#${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx
#OUTPUT_VARIABLE OUTPUT)
set(MPI_WORKS 1)
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})
IF(MPI_WORKS)
MESSAGE(STATUS "MPI is enabled")
SET(HAVE_MPI 1)
SET(HAVE_OOMPI 1)
LINK_LIBRARIES(${MPI_CXX_LIBRARIES})
ELSE(MPI_WORKS)
MESSAGE(STATUS "MPI is disabled")
SET(HAVE_MPI 0)
SET(HAVE_OOMPI 0)
SET(MPI_LIBRARY "")
ENDIF(MPI_WORKS)
ELSE(MPI_FOUND)
MESSAGE(STATUS "MPI not found")
SET(MPI_LIBRARY "")
ENDIF(MPI_FOUND)
ENDIF()
ENDIF(QMC_MPI)
#-------------------------------------------------------------------
# check lapack/blas
#-------------------------------------------------------------------
# Quick search for MKL (this will need to be improved). Currently only for Intel compilers
IF (INTEL_COMPILER)
INCLUDE(CMake/FindMKL.cmake)
ENDIF(INTEL_COMPILER)
IF ( HAVE_MKL )
# We found MKL, add the link library
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MKL_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MKL_FLAGS}")
SET(LAPACK_FOUND 1)
SET(LAPACK_LIBRARIES "${MKL_LIBRARIES}")
SET(LAPACK_LINKER_FLAGS "${MKL_LINKER_FLAGS}")
ELSEIF ( $ENV{CRAYPE_VERSION} MATCHES "." )
# Cray specific environment variable indicates we are on a cray. Assume libsci will be linked
# preferable to attempt a compile/link
SET(LAPACK_FOUND 1)
MESSAGE(STATUS "Assuming Cray libsci or other BLAS/LAPACK will be linked by compiler wrappers")
ELSE()
# Search for Blas/Lapack
find_package(LAPACK)
# When cmake finds and sets up the MKL libraries with a non-Intel compiler, set the flag
# This should be tidied up when FindMKL.cmake supports non-Intel compilers.
IF("${LAPACK_LIBRARIES}" MATCHES "mkl")
MESSAGE(STATUS "MKL found via LAPACK/BLAS")
SET( MKL_FOUND 1 )
SET( HAVE_MKL 1 )
ENDIF()
ENDIF()
IF(LAPACK_FOUND)
MESSAGE(STATUS "LAPACK libraries: ${LAPACK_LIBRARIES}")
MESSAGE(STATUS "LAPACK linker flags: ${LAPACK_LINKER_FLAGS}")
SET(LAPACK_LIBRARY ${LAPACK_LIBRARIES} ${LAPACK_LINKER_FLAGS})
ELSE()
MESSAGE(FATAL_ERROR "Could not find required libraries LAPACK &/or BLAS")
ENDIF()
INCLUDE(CMake/FindVectorMath.cmake)
ENDIF(CMAKE_TOOLCHAIN_FILE)
IF (ENABLE_GCOV)
IF (NOT GCOV_SUPPORTED)
MESSAGE(FATAL_ERROR "ENABLE_GCOV was specified but compiler does not support GCC coverage flag")
ENDIF()
ENDIF(ENABLE_GCOV)
# check if C++11 is needed by QMCPACK features
#SET(CXX11_NEEDED FALSE)
#IF(BUILD_LMYENGINE_INTERFACE OR BUILD_MINIAPPS OR BUILD_AFQMC OR ENABLE_AA_SOA)
SET(CXX11_NEEDED TRUE)
#ENDIF()
# once C++11 is needed
IF(CXX11_NEEDED)
SET(CXX11_FLAG "-std=c++11")
#check if the CXX compiler supports -std=c++11 option
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11)
# Turn on C++11 for this code
# Force the flag on Cray with Intel compiler, because the Cray wrapper
# prints an warning that interferes with the flag detection code
# with older versions of CMake.
IF($ENV{CRAYPE_VERSION} MATCHES ".")
IF( ${COMPILER} MATCHES "Intel" AND NOT CXX_COMPILER_SUPPORT_CXX11)
SET(CXX_COMPILER_SUPPORT_CXX11 TRUE)
MESSAGE(STATUS "Forcing C++11 support on Cray with Intel")
ENDIF()
ENDIF()
IF (CXX_COMPILER_SUPPORT_CXX11)
# avoid repeated -std=c++11 flag
STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG})
IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH})
SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}")
ENDIF()
ELSE()
MESSAGE(STATUS "Disabling features requring C++11 due to the lack of compiler support")
SET(BUILD_LMYENGINE_INTERFACE 0)
SET(BUILD_MINIAPPS 0)
SET(BUILD_AFQMC 0)
IF(ENABLE_AA_SOA)
MESSAGE(FATAL_ERROR "ENABLE_AA_SOA requires C++11 compiler support!")
ENDIF()
ENDIF()
ENDIF(CXX11_NEEDED)
# 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()
# 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()
IF (BUILD_AFQMC AND NOT APPLE)
LINK_LIBRARIES("rt")
ENDIF()
# setup ctest variables
IF ( HAVE_MPI )
SET( USE_MPI 1 )
IF ( NOT MPIEXEC )
SET( MPIEXEC "mpirun" )
ENDIF()
IF ( NOT DEFINED MPIEXEC_NUMPROC_FLAG )
SET( MPIEXEC_NUMPROC_FLAG "-np" )
ENDIF()
IF ( NOT TEST_MAX_PROCS )
SET( TEST_MAX_PROCS 100 )
ENDIF()
MESSAGE(STATUS "MPI runner is ${MPIEXEC}")
ENDIF(HAVE_MPI)
MESSAGE(STATUS "CXX compiler flags: ${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "CC compiler flags: ${CMAKE_C_FLAGS}")
SET(HAVE_OOMPI ${HAVE_MPI})
INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake)
####################################################################
#First check the required libraries. Abort if these are not found.
#Changed the fall-back versions to use similar conventions to 2.8.0 and higher
####################################################################
# list of libraries to be linked with the main applications using I/O
SET(QMC_UTIL_LIBS ${LAPACK_LIBRARY} ${BLAS_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)
# INCLUDE_DIRECTORIES(${FFTW_INCLUDE_DIR})
# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FFTW_LIBRARIES})
# 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})
#find_package(ZLIB)
#find_package(LibXml2)
#INCLUDE(CMake/FindLibxml2QMC.cmake)
#IF(LIBXML2_FOUND)
# INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
# SET(HAVE_LIBXML2 1)
# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${LIBXML2_LIBRARIES})
#ELSE()
# MESSAGE(FATAL_ERROR "Could not find required library Libxml2")
#ENDIF(LIBXML2_FOUND)
#set(HDF5_USE_STATIC_LIBRARIES off)
#if(QMC_BUILD_STATIC)
# set(HDF5_USE_STATIC_LIBRARIES on)
#endif()
find_package(HDF5)
IF(HDF5_FOUND)
SET(HAVE_LIBHDF5 1)
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
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()
SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${HDF5_LIBRARIES})
if(ZLIB_LIBRARY)
SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${ZLIB_LIBRARY})
endif(ZLIB_LIBRARY)
#IF(SZLIB_FOUND)
# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${SZLIB_LIBRARIES})
#ENDIF(SZLIB_FOUND)
ELSE(HDF5_FOUND)
if(NOT QMC_PHI)
MESSAGE(FATAL_ERROR "Require hdf5 1.6.4 or higher. Set HDF5_ROOT")
endif()
ENDIF(HDF5_FOUND)
#make sure we can find boost if it's not in /usr
set(Boost_NO_BOOST_CMAKE on)
find_package(Boost REQUIRED)
IF(Boost_FOUND)
SET(HAVE_LIBBOOST 1)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
MESSAGE(STATUS "Setting Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}")
ELSE()
MESSAGE(FATAL_ERROR "Require boost 1.54.x or higher. Set BOOST_ROOT")
ENDIF()
#
#INCLUDE(${PROJECT_CMAKE}/FindPkgConfig.cmake)
##################################################################
# TODO:use profile tools
##################################################################
#IF(MPIP_PROFILE)
# LINK_LIBRARIES("/usr/apps/tools/mpip/lib/cmpi/libmpiP.a")
# LINK_LIBRARIES("/usr/lib/libbfd.a")
# LINK_LIBRARIES("/usr/lib/libiberty.a")
#ENDIF(MPIP_PROFILE)
#if(ENABLE_TAU_PROFILE)
# INCLUDE(${PROJECT_CMAKE}/FindTau.cmake)
#endif(ENABLE_TAU_PROFILE)
# #add tau stuff
# IF(FOUND_TAU)
# ADD_DEFINITIONS(
# -DTAU_MPI
# -DTAU_MPI_THREADED
# -DTAU_MPIGREQUEST
# -DTAU_MPIDATAREP
# -DTAU_MPIERRHANDLER
# -DTAU_MPIATTRFUNCTION
# -DTAU_MPITYPEEX
# -DTAU_MPIADDERROR
# )
# #build libtau
# subdirs(src/tau)
# LINK_LIBRARIES(tau)
# ENDIF(FOUND_TAU)
#IF(FOUND_TAU)
# INCLUDE_DIRECTORIES(${TAU_INCLUDE_DIR})
# ADD_DEFINITIONS (-DPROFILING_ON
# -DTAU_STDCXXLIB
# -DTAU_DOT_H_LESS_HEADERS
# -DTAU_CALLPATH
# -DTAU_LARGEFILE64_SOURCE
# -DTAU_BFD
# )
# if(ENABLE_OPENMP)
# ADD_DEFINITIONS(-DTAU_OPENMP)
# endif(ENABLE_OPENMP)
#ENDIF(FOUND_TAU)
######################################################
# Add optional macros
######################################################
#include qmcpack/src build/src
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
######################################################################
# Manage Einspline library
# - toolchain file can set
# - check if libeinspline can be found in $EINSPLINE_HOME/include and
# $EINSPLINE_HOME/lib
# - if not found, build it from the source directory in $EINSPLINE_HOME
# - if everything fails, do not use it
######################################################################
SET(HAVE_EINSPLINE 1)
set(build_einspline 0)
#if(HAVE_EINSPLINE_EXT)
# set(HAVE_EINSPLINE 0)
# INCLUDE(${PROJECT_CMAKE}/FindEinspline.cmake)
# IF(EINSPLINE_FOUND)
# INCLUDE_DIRECTORIES(${EINSPLINE_INCLUDE_DIR})
# SET(QMC_UTIL_LIBS ${EINSPLINE_LIBRARIES} ${QMC_UTIL_LIBS})
# set(build_einspline 0)
# endif()
#endif()
if(build_einspline)
SUBDIRS(src/einspline)
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} einspline)
endif()
#IF(BUILD_LMYENGINE_INTERFACE)
# ADD_DEFINITIONS(-DHAVE_LMY_ENGINE)
# SET(FORMIC_BINARY_DIR ${qmcpack_BINARY_DIR})
# SUBDIRS(src/formic/utils)
# SET(QMC_UTIL_LIBS formic_utils ${QMC_UTIL_LIBS})
#ENDIF(BUILD_LMYENGINE_INTERFACE)
#include(ExternalProject)
# set(einspline_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/einspline")
# set(einspline_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/einspline")
# set(einspline_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${einspline_INSTALL_DIR})
#ExternalProject_Add(
# einspline
# SVN_REPOSITORY http://qmctools.googlecode.com/svn/ext-packages/einspline
# )
# INSTALL_DIR ${einspline_INSTALL_DIR}
# CMAKE_ARGS ${einspline_CMAKE_ARGS}
# )
# find_package(einspline REQUIRED)
# set(HAVE_EINSPLINE 1)
#######################################################################
## Manage GTK+ and GTKMM packages for GUI
## search headers and libraries
## 1) -lXYZ-${XYZ_VERSION}
## 2) -lXYZ
## example: -lgtk-${GTK_VERSION} | -lgtk
#######################################################################
#SET(GTK_VERSION 2.0)
#SET(PANGO_VERSION 1.0)
#
#SET(GTKMM_VERSION 2.4)
#SET(PANGOMM_VERSION 1.4)
#SET(SIGCPP_VERSION 2.0)
#IF(ENABLE_GTK_GUI)
# INCLUDE(${PROJECT_CMAKE}/FindGTK.cmake)
# #THIS SHOULD GO TO the directory where GUI is built
# IF(GTKMM_FOUND)
# INCLUDE_DIRECTORIES(${GTKMM_INCLUDE_DIR})
# LINK_LIBRARIES(${GTKMM_LIBRARIES})
# ENDIF(GTKMM_FOUND)
#ENDIF(ENABLE_GTK_GUI)
# To connect the timer regions with VTune sampling, some Task API calls
# are present in the code. To enable them, set USE_VTUNE_TASKS and add the
# include and lib paths to VTune.
# An example for what needs to be added to the cmake command:
#
# -DUSE_VTUNE_TASKS=1 \
# -DQMC_INCLUDE=/opt/intel/vtune_amplifier_xe/include \
# -DQMC_EXTRA_LIBS="-L/opt/intel/vtune_amplifier_xe/lib64 -ldl"
#
# Some collection types may require enabling the task API with a knob.
# For the command line:
# amplxe-cl -collect advanced-hostpots -knob enable-user-tasks=true ./bin/miniqmc
# For the GUI, there is an equivalent checkbox in the collection setup.
#
IF (USE_VTUNE_TASKS)
LINK_LIBRARIES(ittnotify)
ENDIF()
###############################################################
# for specific linker in the case of profiling like hpctoolkit.
###############################################################
if(CMAKE_CXX_LINKER)
set(CMAKE_CXX_LINK_EXECUTABLE
"${CMAKE_CXX_LINKER} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
MESSAGE(STATUS "Linker is specified as '${CMAKE_CXX_LINKER}' instead of '${CMAKE_CXX_COMPILER}'")
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()
# Avoid unused variables warnings (for now) by using for information purposes
IF(QMC_DATA)
MESSAGE(STATUS "QMC_DATA is ${QMC_DATA}")
ENDIF()
IF(ENABLE_GCOV)
MESSAGE(STATUS "GCOV is enabled")
ENDIF()
###################################################
# Done searching libraries. Start building qmcpack
###################################################
MESSAGE(STATUS "Ready to build qmcpack")
####################################################################
# add definitions
# -DH5_USE_16_API for HDF5
# -DMPICH_SKIP_MPICXX : disable C++ binding of MPICH
####################################################################
ADD_DEFINITIONS(-DHAVE_CONFIG_H -DH5_USE_16_API -DUSE_REAL_STRUCT_FACTOR -DINLINE_ALL=inline)
IF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-DADD_)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
if(HAVE_MPI)
ADD_DEFINITIONS(-DMPICH_SKIP_MPICXX)
endif()
#ADD_DEFINITIONS(-DDISABLE_WS_CELL)
EXECUTE_PROCESS(COMMAND hostname OUTPUT_VARIABLE QMC_HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/qmcpack.settings ${qmcpack_BINARY_DIR}/bin/qmcpack.settings)
#########################
# add definitions for adios profile
# add definitions for adios verification
########################
IF(QMC_ADIOS)
#ADD_DEFINITIONS(-DIO_PROFILE)
#ADD_DEFINITIONS(-DADIOS_VERIFY)
ADD_DEFINITIONS(-DWRITE_GLOBAL)
ENDIF(QMC_ADIOS)
SUBDIRS(src)
#IF(NOT(QMC_BUILD_LEVEL GREATER 4))
# SUBDIRS(tests)
# SUBDIRS(examples)
#ENDIF()
#ADD_CUSTOM_TARGET(print_settings ALL
# ${CMAKE_COMMAND} -E echo "Print build settings"
# VERBATIM)
#
#add_custom_command(TARGET print_settings
# POST_BUILD
# COMMAND svn info ${qmcpack_SOURCE_DIR})
#
#file(APPEND ${qmcpack_BINARY_DIR}/bin/qmcpack.settings ${print_settings})