forked from kkmaute/moris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
1140 lines (888 loc) · 36.6 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
#
# Copyright (c) 2022 University of Colorado
# Licensed under the MIT license. See LICENSE.txt file in the MORIS root for details.
#
# -------------------------------------------------------------------------
# MORIS CMakeLists.txt ----------------------------------------------------
# -------------------------------------------------------------------------
# NOTES:
# The command 'add_library(${MORIS} STATIC ${SOURCES})' automatically
# adds the 'lib' prefix to the library and the 'a' file extension.
# The extension 'a' is added for a static library.
# Result is 'Linking CXX static library libmoris.a'.
# Require CMake 3.1
cmake_minimum_required(VERSION 3.3.2)
# Guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt from this directory.")
endif()
# Project name and version
project(MORIS VERSION 1.0.0)
set(MORIS_VERSION_RELEASE 0)
if(NOT MORIS_VERSION_RELEASE)
set(MORIS_VERSION "${MORIS_VERSION}.dbg")
endif()
# -------------------------------------------------------------------------
## MORIS Directories
# Top directory
set(MORIS "moris")
# Project directories
set(BIN "bin")
set(BUILD "build")
set(CMAKE "cmake")
set(INC "include")
set(LIB "lib")
set(SHARE "share")
set(SRC "projects")
set(TMP "tmp")
set(TEST "test")
set(REGRESSION "regression")
set(UNIT "unit")
set(MAIN "mains")
# Source directories
set(ALG "ALG")
set(ASR "ASR")
set(CHR "CHR")
set(COM "COM")
set(CNT "CNT")
set(COR "COR")
set(DLA "DLA")
set(EXA "EXA")
set(EXC "EXC")
set(FEM "FEM")
#set(GE "GE")
set(GEN "GEN")
set(GEN_CORE "GEN_CORE")
set(GEN_MAIN "GEN_MAIN")
set(HIA "Hierarchical")
set(HMR "HMR")
set(INT "INT")
set(IOS "IOS")
set(MAP "MAP")
set(MDL "MDL")
set(LINALG "LINALG")
set(MOD "MOD")
set(MRS "MRS")
set(MSI "MSI")
set(MTK "MTK")
set(NLA "NLA")
set(OPT "OPT")
set(PRM "PRM")
set(ENM "ENM")
set(SDF "SDF")
set(SOL "SOL")
set(SOL_CORE "SOL_CORE")
# set(TIN "TIN")
set(TOL "TOL")
set(TSA "TSA")
set(VIS "VIS")
set(WRK "WRK")
set(XTK "XTK")
set(MIG "MIG")
# Common paths
set(MORIS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MORIS_CMAKE_DIR ${MORIS_DIR}/${SHARE}/${CMAKE})
set(MORIS_DEPENDS_DIR ${MORIS_CMAKE_DIR}/dependencies)
set(MORIS_TPL_DIR ${MORIS_CMAKE_DIR}/find_wrappers)
set(MORIS_PACKAGE_DIR ${MORIS_DIR}/projects)
# Build directories
set(CONFIG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE})
set(LIB_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${LIB})
set(EXE_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${BIN})
set(HEADER_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${INC})
set(TEST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TEST})
set(REGRESSION_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${REGRESSION})
# Output path for all static and shared libraries.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BIN})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LIB})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LIB})
# Installation directories
set(CONFIG_INSTALL_DIR ${SHARE})
set(LIB_INSTALL_DIR ${LIB})
set(EXE_INSTALL_DIR ${BIN})
set(HEADER_INSTALL_DIR ${INC})
# -------------------------------------------------------------------------
## CMake Paths
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/${SHARE}/${CMAKE}/find_modules"
"${CMAKE_SOURCE_DIR}/${SHARE}/${CMAKE}/find_wrappers" )
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
# -------------------------------------------------------------------------
## MORIS Important Include Directories
list(APPEND MORIS_INCDIRS "${SRC}" "snippets" "${INC}" "/usr/include")
# -------------------------------------------------------------------------
## Options
# MPI support.
option(MORIS_HAVE_PARALLEL
"Build MORIS with support for MPI communication." ON )
# MPI package.
set(MORIS_MPI_LIBS "MPICH" "OPENMPI")
set(MORIS_USE_MPI "OPENMPI" CACHE STRING "Set MPI package: ${MORIS_MPI_LIBS}")
# MPI execution command
set(MORIS_EXECUTE_COMMAND "mpirun" CACHE STRING "The command used to execute MORIS tests.")
option(MORIS_USE_ARMA
"Use the Armadillo library as the dense linear algebra package." ON )
option(MORIS_USE_EIGEN
"Use the Eigen3 library as the dense linear algebra package." OFF )
option(MORIS_USE_32BIT
"Use 32bit numbers for identifiers and sizes." ON )
option(MORIS_USE_LTO
"Use LTO optimization." ON )
option(MORIS_HAVE_DEBUG
"Use the debug version of the code." OFF )
option(MORIS_USE_VALGRIND
"Use valgrind to run tests." OFF )
option(MORIS_USE_MATRIX_FILL
"Fill matrices by default with NANs or MaxValues." OFF )
option(MORIS_USE_CHECK_MEMORY
"Check memory usage for matrices and cells." OFF )
option(MORIS_USE_XTK "Have XTK Library" ON)
option(MORIS_HAVE_SYMBOLIC
"Use symbolic information in executable." OFF )
option(MORIS_HAVE_SYMBOLIC_STRONG
"Use symbolic information (strong) in executable." OFF )
option(MORIS_USE_ACML
"Use the AMD ACML library as the linear algebra package." OFF )
option(MORIS_USE_OPENBLAS
"Use the open blas library as the linear algebra package." ON )
option(MORIS_USE_LAPACK
"Use the lapack library as the linear algebra package." OFF )
option(MORIS_USE_MKL
"Use the Inel Math kernel library as the linear algebra package." OFF )
option(MORIS_USE_PARDISO
"Build MORIS with PARDISO used in Trilinos and Petsc." ON )
option(MORIS_USE_MUMPS
"Build MORIS with MUMPS used in Trilinos and Petsc." ON )
option(MORIS_HAVE_TRILINOS_OLD
"Build MORIS with support for old Trilinos version." OFF )
option(MORIS_HAVE_TRILINOS_NEW_CMAKE
"Build MORIS with support for old Trilinos version." OFF )
option(MORIS_HAVE_PETSC
"Build MORIS with support for PETSC." ON )
option(MORIS_HAVE_SLEPC
"Build MORIS with support for SLEPC." OFF )
option(MORIS_HAVE_GCMMA
"Build MORIS with support for GCMMA." ON )
option(MORIS_HAVE_SNOPT
"Build MORIS with support for SNOPT." ON )
option(MORIS_HAVE_LBFGS
"Build MORIS with support for LBFGS." ON )
# option(MORIS_HAVE_PERF_MAT
# "Run matrix performance tests." OFF )
#
# option(MORIS_HAVE_PERF_SP_MAT
# "Run sparse matrix performance tests." OFF )
#
# option(MORIS_HAVE_PERF_LIN_SOLVE
# "Run linear solver performance tests." OFF )
option(MORIS_USE_TESTS
"Compile unit tests." ON )
option(MORIS_USE_PERF_TESTS
" Build the performance tests" OFF)
option(MORIS_USE_EXAMPLES
"Build the examples." ON)
option(MORIS_HAVE_PARALLEL_TESTS
"Run unit tests in parallel. MORIS_USE_TESTS must be ON." ON)
option(MORIS_PERFORM_CHECK
"Use performance check." ON )
option(MORIS_USE_INTEL "USE BLANCA" OFF)
option(MORIS_USE_OPENMP "Use OpenMP" OFF)
# -------------------------------------------------------------------------
# Package Options
option(BUILD_MAIN "Build main executable." OFF)
option(BUILD_ALL "Build all executables." OFF)
option(BUILD_NONE "Build no executables." OFF)
option(BUILD_ALG "Build the algorithms executable." OFF)
option(BUILD_ASR "Build the assert executable." OFF)
option(BUILD_CHR "Build the chronos executable." OFF)
option(BUILD_COM "Build the communication executable." OFF)
option(BUILD_CNT "Build the containers executable." OFF)
option(BUILD_DLA "Build the distributed linear algebra executable." OFF)
option(BUILD_EXC "Build the exceptions executable." OFF)
option(BUILD_FEM "Build the FEM executable." OFF)
#option(BUILD_GE "Build the geometry engine executable." OFF)
option(BUILD_GEN "Build the geometry engine executable." OFF)
option(BUILD_HMR "Build the HMR executable." OFF)
option(BUILD_INT "Build the integration and interpolation executable." OFF)
option(BUILD_IOS "Build the IOS executable." OFF)
option(BUILD_LINALG "Build the linear algebra executable." OFF)
option(BUILD_MAP "Build the MTK mapper." OFF)
option(BUILD_MOD "Build the model executable." OFF)
option(BUILD_MSI "Build the model solver interface executable." OFF)
option(BUILD_MDL "Build the model executable." OFF)
option(BUILD_MTK "Build the MTK executable." OFF)
option(BUILD_NLA "Build the non-linear algebra executable." OFF)
option(BUILD_OPT "Build the optimization executable." OFF)
option(BUILD_PRM "Build the PRM executable." OFF)
option(BUILD_SDF "Build the SDF executable." OFF)
option(BUILD_STK "Build the STK executable." OFF)
# option(BUILD_TIN "Build the TIN executable." OFF)
option(BUILD_TOL "Build the tools executable." OFF)
option(BUILD_TSA "Build the time solver algebra executable." OFF)
option(BUILD_TUTORIALS "Build the tutorial executables." OFF)
option(BUILD_VIS "Build the visualization executable." OFF)
option(BUILD_WRK "Build the workflow executable." OFF)
option(BUILD_XTK "Build the XTK executable." OFF)
option(BUILD_MIG "Build the MIG executable." ON)
# -------------------------------------------------------------------------
# Macros
include(${MORIS_CMAKE_DIR}/utilities/moris_macros.cmake)
# ------------------------------------------------------------------------
## Dynamic link test function
include(${MORIS_CMAKE_DIR}/utilities/dynamic_link_input.cmake)
# -------------------------------------------------------------------------
# Compiler ----------------------------------------------------------------
# -------------------------------------------------------------------------
# Set default C compiler.
if (NOT MORIS_C_COMPILER )
set(MORIS_C_COMPILER "mpicc" )
endif()
# Set default C++ compiler
if (NOT MORIS_CXX_COMPILER )
if (MORIS_USE_INTEL )
set(MORIS_CXX_COMPILER "mpicxx" )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wunused-variable -Wsign-compare" )
endif()
else()
set(MORIS_CXX_COMPILER "mpic++")
message(STATUS "MORIS_CXX_COMPILER is set to ${MORIS_CXX_COMPILER}")
endif()
endif()
set(MORIS_C_LINK_EXECUTABLE ${MORIS_C_COMPILER} )
set(MORIS_CXX_LINK_EXECUTABLE ${MORIS_CXX_COMPILER})
message(STATUS "MORIS recognized the C compiler type MORIS_C_COMPILER=${MORIS_C_COMPILER}.")
message(STATUS "MORIS recognized the C++ compiler type MORIS_CXX_COMPILER=${MORIS_CXX_COMPILER}.")
# Check for compiler flags.
include(CheckCXXCompilerFlag)
# Allow for mutliple defintions for the same routine
#set(CMAKE_EXE_LINKER_FLAGS "-Wl,--allow-multiple-definition")
# set libaries to be linked for all targets
# note: should be done similar to find_modules find_library
# generate search path from LD_LIBRARY_PATH
string(REPLACE ":" ";" LIB_SEARCH_PATH "$ENV{LD_LIBRARY_PATH}")
list(REMOVE_DUPLICATES LIB_SEARCH_PATH)
message(STATUS "Library search path: ${LIB_SEARCH_PATH}")
if (MORIS_USE_INTEL)
find_library(MORIS_LIB_Ifcore NAMES libifcore.so HINTS ${LIB_SEARCH_PATH})
message(STATUS "MORIS_LIB_Ifcore = ${MORIS_LIB_Ifcore}")
link_libraries(${MORIS_LIB_Ifcore})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Ifcore})
find_library(MORIS_LIB_Ifcoremt NAMES libifcoremt.so HINTS ${LIB_SEARCH_PATH})
message(STATUS "MORIS_LIB_Ifcoremt = ${MORIS_LIB_Ifcoremt}")
link_libraries(${MORIS_LIB_Ifcoremt})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Ifcoremt})
find_library(MORIS_LIB_GFortran NAMES $ENV{GFORTLIB} HINTS ${LIB_SEARCH_PATH})
message(STATUS "MORIS_LIB_GFortran = ${MORIS_LIB_GFortran}")
link_libraries(${MORIS_LIB_GFortran})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_GFortran})
find_library(MORIS_LIB_Rt NAMES rt HINTS ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Rt = ${MORIS_LIB_Rt}")
link_libraries(${MORIS_LIB_Rt})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Rt})
find_library(MORIS_LIB_Dl NAMES dl HINTS ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Dl = ${MORIS_LIB_Dl}")
link_libraries(${MORIS_LIB_Dl})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Dl})
find_library(MORIS_LIB_Ssl NAMES ssl HINTS ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Ssl = ${MORIS_LIB_Ssl}")
link_libraries(${MORIS_LIB_Ssl})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Ssl})
find_library(MORIS_LIB_Crypto NAMES crypto HINTS ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Crypto = ${MORIS_LIB_Crypto}")
link_libraries(${MORIS_LIB_Crypto})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Crypto})
else(MORIS_USE_INTEL)
if ( DEFINED ENV{GFORTLIB} )
find_library(MORIS_LIB_GFortran NAMES $ENV{GFORTLIB} HINTS $ENV{GFORTLIB_PATH} ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_GFortran = ${MORIS_LIB_GFortran}")
link_libraries(${MORIS_LIB_GFortran})
else()
foreach(ver RANGE 3 6)
find_library(MORIS_LIB_GFortran NAMES libgfortran.so.${ver} HINTS ${LIB_SEARCH_PATH} )
if ( MORIS_LIB_GFortran )
message(STATUS "MORIS_LIB_GFortran = ${MORIS_LIB_GFortran}")
link_libraries(${MORIS_LIB_GFortran})
break()
endif()
endforeach()
endif()
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_GFortran})
find_library(MORIS_LIB_Dl NAMES dl HINTS ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Dl = ${MORIS_LIB_Dl}")
link_libraries(${MORIS_LIB_Dl})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Dl})
find_library(MORIS_LIB_Ssl NAMES ssl HINTS $ENV{SSL_LIBRARY_DIR} ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Ssl = ${MORIS_LIB_Ssl}")
link_libraries(${MORIS_LIB_Ssl})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Ssl})
find_library(MORIS_Lib_Crypto NAMES crypto HINTS $ENV{SSL_LIBRARY_DIR} ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_Lib_Crypto = ${MORIS_Lib_Crypto}")
link_libraries(${MORIS_Lib_Crypto})
#list(APPEND MORIS_BASE_LIBS ${MORIS_Lib_Crypto})
find_library(MORIS_LIB_Z NAMES z HINTS $ENV{ZLIB_LIBRARY_DIR} ${LIB_SEARCH_PATH} )
message(STATUS "MORIS_LIB_Z = ${MORIS_LIB_Z}")
link_libraries(${MORIS_LIB_Z})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_Z})
endif(MORIS_USE_INTEL)
list(APPEND MORIS_DEFINITIONS "-DF77ADD_")
if(MORIS_USE_OPENMP)
check_cxx_compiler_flag(-fopenmp HAVE_OPENMP)
message("CHECK FOPENMP")
if(HAVE_OPENMP)
message("SETTING FOPENMP")
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -fopenmp")
endif()
endif()
# -g Request that the compiler and linker generate
# and retain symbol information in the executable itself,
# for debugging purposes.
# Set optimization type.
# Compile with -O compiler optimizations.
# Debug flags.
if (MORIS_HAVE_DEBUG)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_DEBUG")
endif()
if (MORIS_HAVE_SYMBOLIC)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type Debug" FORCE)
if (MORIS_HAVE_SYMBOLIC_STRONG)
# add here option to ease debugging
else()
check_cxx_compiler_flag(-Og HAVE_DEBUG)
if (HAVE_DEBUG)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Og")
endif()
endif()
check_cxx_compiler_flag(-g3 HAVE_DEBUG_3)
if (HAVE_DEBUG_3)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -g3")
else()
check_cxx_compiler_flag(-g HAVE_DEBUG)
if (HAVE_DEBUG)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -g")
endif()
endif()
check_cxx_compiler_flag(-ggdb HAVE_DEBUG_DBG)
if (HAVE_DEBUG_DBG)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -ggdb")
endif()
#check_cxx_compiler_flag(-fanalyzer HAVE_ANALYZER_DBG)
#if (HAVE_ANALYZER_DBG)
# set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -fanalyzer")
#endif()
else()
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type Release" FORCE)
check_cxx_compiler_flag(-O3 HAVE_O3_OPTIMISATION)
if (HAVE_O3_OPTIMISATION)
if (MORIS_USE_INTEL)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -O3 -xCORE-AVX2 -mkl:sequential -ip")
else()
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -O3 -m64")
endif()
endif()
# check_cxx_compiler_flag(-ffast-math HAVE_FASTMATH_OPTIMISATION)
# if (HAVE_FASTMATH_OPTIMISATION)
# set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -ffast-math")
# endif()
check_cxx_compiler_flag(-flto HAVE_LTO_OPTIMISATION)
if (HAVE_LTO_OPTIMISATION AND MORIS_USE_LTO)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -flto=auto")
# -ffat-lto-objects
endif()
endif()
if (MORIS_USE_MATRIX_FILL)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -DMATRIX_FILL ")
endif()
if (MORIS_USE_CHECK_MEMORY)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -DCHECK_MEMORY ")
endif()
if (MORIS_HAVE_PARALLEL)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -DMORIS_HAVE_PARALLEL ")
endif()
# # Performace test flags
# if (MORIS_HAVE_PERF_MAT)
# list(APPEND MORIS_DEFINITIONS "-DPERF_MAT")
# endif()
#
# if (MORIS_HAVE_PERF_SP_MAT)
# list(APPEND MORIS_DEFINITIONS "-DPERF_SP_MAT")
# endif()
#
# if (MORIS_HAVE_PERF_LIN_SOLVE)
# list(APPEND MORIS_DEFINITIONS "-DPERF_LIN_SOLVE")
# endif()
# Performace check flag for logger
if(MORIS_PERFORM_CHECK)
list(APPEND MORIS_DEFINITIONS "-DMORIS_PERFORM_CHECK")
endif()
if (MORIS_HAVE_TRILINOS_OLD)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -DMORIS_HAVE_TRILINOS_OLD ")
endif()
# Add some strict compiler checks.
check_cxx_compiler_flag("-pedantic" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -pedantic" )
endif()
check_cxx_compiler_flag("-pedantic-errors" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -pedantic-errors" )
endif()
check_cxx_compiler_flag("-Wall" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wall" )
endif()
check_cxx_compiler_flag("-Wextra" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
#set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wextra" )
endif()
check_cxx_compiler_flag("-Werror" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Werror" )
endif()
# Define exceptions to strict error checking
check_cxx_compiler_flag("-Wno-unused-parameter" HAVE_EXCEPTION )
if (HAVE_EXCEPTION)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wno-unused-parameter" )
endif()
check_cxx_compiler_flag("-Wno-format-security" HAVE_EXCEPTION )
if (HAVE_EXCEPTION)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wno-format-security" )
endif()
# Check for C++17 and lower version support.
check_cxx_compiler_flag(-std=c++17 HAVE_STD_CPP17)
if (HAVE_STD_CPP17)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -std=c++17")
else()
check_cxx_compiler_flag(-std=c++14 HAVE_STD_CPP14)
if (HAVE_STD_CPP14)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -std=c++14")
else()
check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11)
if (HAVE_STD_CPP11)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -std=c++11")
else()
check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0x)
if (HAVE_STD_CPP0x)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -std=c++0x")
endif()
endif()
endif()
endif()
# Build 64-bit binaries.
check_cxx_compiler_flag(-m64 HAVE_M64)
if (HAVE_M64)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -m64")
endif()
# Add UTF-8 support for identifier names.
check_cxx_compiler_flag(-fextended-identifiers HAVE_FEXT_IDENTIFIERS)
if (HAVE_FEXT_IDENTIFIERS)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -fextended-identifiers")
endif()
# Add support to use shared libraries as input files.
# -rdynamic Pass the flag -export-dynamic to the ELF linker,
# on targets that support it. This instructs the linker
# to add all symbols, not only used ones,
# to the dynamic symbol table. This option is needed for
# some uses of dlopen or to allow obtaining backtraces
# from within a program.
# -fPIC Generate position-independent code (PIC) suitable
# for use in a shared library, if supported for the target machine.
check_cxx_compiler_flag(-rdynamic HAVE_RDYNAMIC)
if (HAVE_RDYNAMIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -rdynamic")
endif()
check_cxx_compiler_flag(-fPIC HAVE_FPIC)
if (HAVE_FPIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -fPIC")
endif()
# Attempt
find_package(Threads)
# -------------------------------------------------------------------------
# GPERFTOOLS : Make sure that paths are set correctly.
# -------------------------------------------------------------------------
option(MORIS_USE_GPERFTOOLS "Use Google Profiling tools (check paths in CMakeLists.txt)." OFF)
if (MORIS_USE_GPERFTOOLS)
set( MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -I/usr/include/gperftools/ -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" )
link_libraries("-Wl,--no-as-needed -lprofiler -Wl,--as-needed -ltcmalloc")
endif()
# -------------------------------------------------------------------------
# MEMKIND : for memory profiling.
# -------------------------------------------------------------------------
option(MORIS_USE_MEMORY_DEBUG "Use memkind library for memory debugging)." OFF)
if (MORIS_USE_MEMORY_DEBUG)
find_library(MORIS_LIB_MemKind NAMES libmemkind.so.0 HINTS /usr/lib64)
if ( NOT MORIS_LIB_MemKind )
message( FATAL_ERROR "memkind lib not found - do not use MORIS_USE_MEMORY_DEBUG}")
endif()
message(STATUS "MORIS_LIB_MemKind = ${MORIS_LIB_MemKind}")
link_libraries(${MORIS_LIB_MemKind})
#list(APPEND MORIS_BASE_LIBS ${MORIS_LIB_MemKind})
endif()
# -------------------------------------------------------------------------
# SACADO : Make sure that paths are set correctly.
# -------------------------------------------------------------------------
option(MORIS_USE_SACADO "UseSacado (check paths in CMakeLists.txt)." OFF)
if (USE_SACADO)
set( MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -I$ENV{HOME}/codes/Sacado/Trilinos-master/packages/sacado/src" )
set( MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -I$ENV{HOME}/codes/Sacado/Trilinos-master/packages/sacado/src/mpl" )
set( MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -I$ENV{HOME}/codes/Sacado/Trilinos-master/packages/sacado/src/parameter" )
endif() #> clean this up eventually
# -------------------------------------------------------------------------
# XTK --------------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_XTK)
# list(APPEND MORIS_INCDIRS "$ENV{HOME}/codes/xtk/include") #> ask if this is separate from the files in MORIS/src/xtk#
# list(APPEND MORIS_INCDIRS "$ENV{HOME}/codes/xtk/src")
list(APPEND MORIS_DEFINITIONS "-DUSE_XTK")
list(APPEND MORIS_DEFINITIONS "-DXTK_USE_MORIS")
endif()
# -------------------------------------------------------------------------
# ACML/MKL/LAPACK libraries -----------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_ACML)
IF (MORIS_USE_MKL OR MORIS_USE_OPENBLAS OR MORIS_USE_LAPACK)
message(FATAL_ERROR "Use either MKL or ACML, OPENBLAS, LAPACK")
endif()
endif()
if (MORIS_USE_OPENBLAS)
IF (MORIS_USE_MKL OR MORIS_USE_ACML OR MORIS_USE_LAPACK)
message(FATAL_ERROR "Use either MKL or ACML, OPENBLAS, LAPACK")
endif()
endif()
if (MORIS_USE_LAPACK)
IF (MORIS_USE_MKL OR MORIS_USE_ACML OR MORIS_USE_OPENBLAS)
message(FATAL_ERROR "Use either MKL or ACML, OPENBLAS, LAPACK")
endif()
endif()
if (MORIS_USE_ACML)
#include(${SHARE}/${CMAKE}/acml.cmake)
set(ACML_LAPACK_MKL_OPENBLAS "acml")
elseif(MORIS_USE_MKL)
#include(${SHARE}/${CMAKE}/mkl.cmake)
set(ACML_LAPACK_MKL_OPENBLAS "mkl")
elseif(MORIS_USE_LAPACK)
#include(${SHARE}/${CMAKE}/lapack.cmake)
set(ACML_LAPACK_MKL_OPENBLAS "lapack")
elseif(MORIS_USE_OPENBLAS)
#include(${SHARE}/${CMAKE}/openblas.cmake)
set(ACML_LAPACK_MKL_OPENBLAS "openblas")
else()
message(FATAL_ERROR "MORIS only supports the ACML, OPENBLAS, LAPACK, and MKL linear algebra libraries." )
endif()
if (MORIS_USE_32BIT)
list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_32BIT")
endif()
# -------------------------------------------------------------------------
# PETSC -------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_HAVE_PETSC)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_PETSC")
endif()
if (MORIS_HAVE_SLEPC)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_SLEPC")
endif()
# -------------------------------------------------------------------------
# Armadillo / Eigen -------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_ARMA AND MORIS_USE_EIGEN)
message(FATAL_ERROR "Can only set MORIS_USE_EIGEN or MORIS_USE_ARMA; not both" )
endif()
set(ARMADILLO_EIGEN)
if (MORIS_USE_ARMA)
list(APPEND ARMADILLO_EIGEN "armadillo")
list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_ARMA")
if (NOT MORIS_HAVE_DEBUG)
list(APPEND MORIS_DEFINITIONS "-DARMA_NO_DEBUG")
endif()
# include(${MORIS_TPL_DIR}/armadillo.cmake)
# find_package(Armadillo REQUIRED HINTS "$ENV{Armadillo_DIR}")
# list(APPEND MORIS_INCDIRS "${ARMADILLO_INCLUDE_DIRS}")
# list(APPEND MORIS_LDFLAGS "${ARMADILLO_LIBRARY_DIRS}")
# list(APPEND MORIS_BASE_LIBS "-larmadillo")
# list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_ARMA")
endif()
# -------------------------------------------------------------------------
# Eigen3 ------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_EIGEN)
list(APPEND ARMADILLO_EIGEN "eigen")
list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_EIGEN")
endif()
# -------------------------------------------------------------------------
# PARDISO -----------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_PARDISO)
list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_PARDISO")
endif()
# -------------------------------------------------------------------------
# MUMPS -------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_USE_MUMPS)
list(APPEND MORIS_DEFINITIONS "-DMORIS_USE_MUMPS")
endif()
# -------------------------------------------------------------------------
# ARPACK ------------------------------------------------------------------
# -------------------------------------------------------------------------
#include(${MORIS_TPL_DIR}/arpack.cmake)
# -------------------------------------------------------------------------
# GCMMA -------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_HAVE_GCMMA)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_GCMMA")
endif()
# -------------------------------------------------------------------------
# SNOPT -------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_HAVE_SNOPT)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_SNOPT")
endif()
# -------------------------------------------------------------------------
# LBFGS -------------------------------------------------------------------
# -------------------------------------------------------------------------
if (MORIS_HAVE_LBFGS)
list(APPEND MORIS_DEFINITIONS "-DMORIS_HAVE_LBFGS")
endif()
# -------------------------------------------------------------------------
# MORIS variable handling ------------------------------------------------------
# -------------------------------------------------------------------------
IF(CMAKE_CXX_COMPILER_ID MATCHES "^GNU$")
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "GCC_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
if( CMAKE_CXX_COMPILER_VERSION MATCHES "^([0-9]+).*")
message(STATUS "Major version = ${CMAKE_MATCH_1}")
set(MORIS_GCC_MAJOR_VERSION "${CMAKE_MATCH_1}")
if (EXISTS "/usr/bin/gcc-ar-${MORIS_GCC_MAJOR_VERSION}" )
set(CMAKE_AR "/usr/bin/gcc-ar-${MORIS_GCC_MAJOR_VERSION}")
set(CMAKE_RANLIB "/usr/bin/gcc-ranlib-${MORIS_GCC_MAJOR_VERSION}")
set (CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-${MORIS_GCC_MAJOR_VERSION}")
set (CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-${MORIS_GCC_MAJOR_VERSION}")
set (CMAKE_CXX_COMPILER_AR "/usr/bin/gcc-ar-${MORIS_GCC_MAJOR_VERSION}")
set (CMAKE_CXX_COMPILER_RANLIB "/usr/bin/gcc-ranlib-${MORIS_GCC_MAJOR_VERSION}")
else()
set(CMAKE_AR "${CMAKE_C_COMPILER_AR}")
set(CMAKE_RANLIB "${CMAKE_C_COMPILER_RANLIB}")
endif()
message(STATUS "CMAKE_AR = ${CMAKE_AR}")
message(STATUS "CMAKE_RANLIB = ${CMAKE_RANLIB}")
message(STATUS "CMAKE_C_COMPILER_AR = ${CMAKE_C_COMPILER_AR}")
message(STATUS "CMAKE_C_COMPILER_RANLIB = ${CMAKE_C_COMPILER_RANLIB}")
message(STATUS "CMAKE_CXX_COMPILER_AR = ${CMAKE_CXX_COMPILER_AR}")
message(STATUS "CMAKE_CXX_COMPILER_RANLIB = ${CMAKE_CXX_COMPILER_RANLIB}")
endif()
# special case for gcc-10.2
if( CMAKE_CXX_COMPILER_VERSION MATCHES "10.2.*")
check_cxx_compiler_flag("-Wno-type-limits" HAVE_PEDANTIC )
if (HAVE_PEDANTIC)
set(MORIS_CXX_FLAGS "${MORIS_CXX_FLAGS} -Wno-type-limits" )
endif()
endif()
endif()
# C++ compiler flags.
set(CMAKE_C_COMPILER ${MORIS_C_COMPILER})
set(CMAKE_CXX_COMPILER ${MORIS_CXX_COMPILER})
set(CMAKE_CXX_FLAGS ${MORIS_CXX_FLAGS})
# Check compiler version.
# Check for GCC version - earlier versions have insufficient C++11
# support, or bugs. Version info is only available in CMake 2.8.0 and
# later.
# if (NOT CMAKE_VERSION VERSION_LESS 2.8.10)
# if (CMAKE_COMPILER_IS_GNUCXX)
# if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
# message(FATAL_ERROR "GCC version must be at least 4.8 (for sufficient C++11 support. You have version ${CMAKE_CXX_COMPILER_VERSION}" )
# endif()
# endif()
# endif()
# Linker directories.
#link_directories(${MORIS_LDFLAGS})
# Preprocessor definitions.
add_definitions(${MORIS_DEFINITIONS})
# Include directories.
include_directories(${MORIS_INCDIRS})
# Executable.
set(EXECUTABLE "${MORIS}.exe")
message(STATUS "MORIS recognized the C++ flags MORIS_CXX_FLAGS=${MORIS_CXX_FLAGS}.")
message(STATUS "MORIS recognized the C++ linker libraries MORIS_BASE_LIBS=${MORIS_BASE_LIBS}.")
message(STATUS "MORIS recognized the C++ definitions MORIS_DEFINITIONS=${MORIS_DEFINITIONS}.")
#message(STATUS "MORIS recognized the C++ linker directories MORIS_LDFLAGS=${MORIS_LDFLAGS}.")
message(STATUS "MORIS recognized the C++ include directories MORIS_INCDIRS=${MORIS_INCDIRS}.")
# Enable verbose output from Makefile builds.
set(CMAKE_VERBOSE_MAKEFILE ON)
# -------------------------------------------------------------------------
# Depends files
#include_directories(${MORIS_DEPENDS_DIR})
include(${MORIS_DEPENDS_DIR}/MRS_includes.cmake)
if(MORIS_USE_TESTS)
include(${MORIS_DEPENDS_DIR}/test_includes.cmake)
endif()
if(BUILD_MAIN)
include(${MORIS_DEPENDS_DIR}/main_includes.cmake)
else()
set(MORIS_USE_EXAMPLES OFF CACHE BOOL "Build the examples." FORCE)
endif()
if(BUILD_ALL)
include(${MORIS_CMAKE_DIR}/utilities/build_all_exe.cmake)
endif()
if(BUILD_NONE)
include(${MORIS_CMAKE_DIR}/utilities/build_none_exe.cmake)
endif()
if(BUILD_ALG)
include(${MORIS_DEPENDS_DIR}/ALG_Depends.cmake)
endif()
if(BUILD_COM)
include(${MORIS_DEPENDS_DIR}/COM_Depends.cmake)
endif()
if(BUILD_DLA)
include(${MORIS_DEPENDS_DIR}/DLA_Depends.cmake)
endif()
if(BUILD_FEM)
include(${MORIS_DEPENDS_DIR}/FEM_Depends.cmake)
endif()
#if(BUILD_GE)
# include(${MORIS_DEPENDS_DIR}/GE_Depends.cmake)
#endif()
if(BUILD_GEN)
include(${MORIS_DEPENDS_DIR}/GEN_Depends.cmake)
endif()
if(BUILD_HMR)
include(${MORIS_DEPENDS_DIR}/HMR_Depends.cmake)
endif()
if(BUILD_INT)
include(${MORIS_DEPENDS_DIR}/INT_Depends.cmake)
endif()
if(BUILD_LINALG)
include(${MORIS_DEPENDS_DIR}/LINALG_Depends.cmake)
endif()
if(BUILD_MAP)
include(${MORIS_DEPENDS_DIR}/MAP_Depends.cmake)
endif()
if(BUILD_MDL)
include(${MORIS_DEPENDS_DIR}/MDL_Depends.cmake)
endif()
#if(BUILD_MOD)
# include(${MORIS_DEPENDS_DIR}/MOD_Depends.cmake)
#endif()
if(BUILD_MSI)
include(${MORIS_DEPENDS_DIR}/MSI_Depends.cmake)
endif()
if(BUILD_MTK)
include(${MORIS_DEPENDS_DIR}/MTK_Depends.cmake)
endif()
if(BUILD_NLA)
include(${MORIS_DEPENDS_DIR}/NLA_Depends.cmake)
endif()
if(BUILD_OPT)
include(${MORIS_DEPENDS_DIR}/OPT_Depends.cmake)
endif()
if(BUILD_PRM)
include(${MORIS_DEPENDS_DIR}/PRM_Depends.cmake)
endif()
if(BUILD_STK)