-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
845 lines (714 loc) · 29.3 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
#
# CMake configuration script for Elmer
#
# Authors:
# Sami Ilvonen, CSC - IT Center for Science, Ltd.
# Phil Weir, NUMA Engineering Services, Ltd.
# Mikko Byckling, CSC - IT Center for Science Ltd.
# Juhani Kataja, CSC - IT Center for Science Ltd.
# Thomas Zwinger, CSC - IT Center for Science Ltd.
#
# First public beta release 11th of October, 2013
#
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type (Release, Debug, RelWithDebugInfo, MinSizeRel)")
ENDIF()
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(Elmer Fortran C CXX)
IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()
#shamelessly borrowed from FreeCAD project: https://github.com/FreeCAD/FreeCAD/blob/master/cMake/FreeCAD_Helpers/SetupPython.cmake
# For building on OS X
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# If the user doesn't tell us which package manager they're using
if(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
# Try to find MacPorts path
find_program(MACPORTS_EXECUTABLE port)
if(EXISTS ${MACPORTS_EXECUTABLE})
string(REPLACE "/bin/port" ""
MACPORTS_PREFIX ${MACPORTS_EXECUTABLE})
message(STATUS "Detected MacPorts install at ${MACPORTS_PREFIX}")
endif(EXISTS ${MACPORTS_EXECUTABLE})
# Try to find Homebrew path
find_program(HOMEBREW_EXECUTABLE brew)
if(EXISTS ${HOMEBREW_EXECUTABLE})
string(REPLACE "/bin/brew" ""
HOMEBREW_PREFIX ${HOMEBREW_EXECUTABLE})
message(STATUS "Detected Homebrew install at ${HOMEBREW_PREFIX}")
endif()
endif(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
# In case someone tries to shoot themselves in the foot
if(DEFINED MACPORTS_PREFIX AND DEFINED HOMEBREW_PREFIX)
message(SEND_ERROR "Multiple package management systems detected - ")
message(SEND_ERROR "define either MACPORTS_PREFIX or HOMEBREW_PREFIX")
# No package manager
elseif(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
message(SEND_ERROR "No package manager detected - install MacPorts or Homebrew")
endif()
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# SET(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules;${PROJECT_SOURCE_DIR}/cmake/Modules")
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules;${CMAKE_ROOT}/Modules")
SET(CMAKE_Fortran_MODULE_DIRECTORY
${PROJECT_BINARY_DIR}/fmodules CACHE PATH "Directory for Fortran modules")
# Require minimum standard version
SET(CMAKE_C_STANDARD 99)
SET(CMAKE_C_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
# Defaults to cache variables
SET(WITH_MPI TRUE CACHE BOOL "Use MPI parallelization")
SET(MPI_TEST_MAXPROC 8 CACHE STRING "Maximum number of tasks used in parallel tests")
SET(MPI_TEST_MINPROC 1 CACHE STRING "Minimum number of tasks used in parallel tests")
SET(WITH_OpenMP FALSE CACHE BOOL "Use OpenMP thread and SIMD (if available) parallelization")
SET(WITH_MKL FALSE CACHE BOOL "Use Intel Math Kernel library")
SET(WITH_Mumps FALSE CACHE BOOL "Use Mumps sparse direct solver")
SET(WITH_Hypre FALSE CACHE BOOL "Use Hypre linear algebra library")
SET(WITH_CHOLMOD FALSE CACHE BOOL "Use CHOLMOD linear algebra library")
SET(WITH_UMFPACK TRUE CACHE BOOL "Use UMFPACK for LU factorization")
SET(WITH_ELMERGUI FALSE CACHE BOOL "Include ElmerGUI")
SET(WITH_ElmerIce FALSE CACHE BOOL "Include ElmerIce")
SET(WITH_XIOS FALSE CACHE BOOL "Include XIOS")
SET(WITH_ELMERGUITESTER FALSE CACHE BOOL "Include ElmerGUI tester")
SET(WITH_ELMERGUILOGGER FALSE CACHE BOOL "Include ElmerGUI logger")
SET(ELMER_INSTALL_LIB_DIR "lib/elmersolver" CACHE PATH "Location of elmer shared libraries relative to prefix.")
SET(WITH_Trilinos FALSE CACHE BOOL "Use Trilinos")
SET(WITH_FETI4I FALSE CACHE BOOL "Use FETI4I")
SET(WITH_ELMERPOST FALSE CACHE BOOL "Include ElmerPost (DEPRECATED)")
SET(WITH_CONTRIB FALSE CACHE BOOL "Include contributed solvers")
SET(WITH_LUA FALSE CACHE BOOL "Include LUA extensions.")
SET(WITH_MMG FALSE CACHE BOOL "Compile with MMG library.")
SET(WITH_ROCALUTION FALSE CACHE BOOL "Compile with Rocalution library.")
SET(WITH_Zoltan FALSE CACHE BOOL "Link in Zoltan mesh repartitioning library.")
SET(USE_SYSTEM_ZOLTAN FALSE CACHE BOOL "Use system Zoltan library")
SET(INCLUDE_ELMER_MODULES "" CACHE STRING "Semicolon separated list of solver modules to be compiled. If empty compile all.")
# Let user select if the contiguous attribute is used or not
SET(USE_CONTIGUOUS FALSE CACHE BOOL "Use contiguous attribute")
MARK_AS_ADVANCED(WITH_ELMERPOST)
# if("${CMAKE_VERSION}" VERSION_GREATER 2.8.12)
# CMAKE_POLICY(SET CMP0022 OLD)
# ENDIF()
OPTION (USE_NEW_POLICY_CMP0057 "Option to enable new policy CMP0057" ON)
IF (USE_NEW_POLICY_CMP0057)
CMAKE_POLICY(SET CMP0057 NEW)
ENDIF()
MARK_AS_ADVANCED(ELMER_INSTALL_LIB_DIR)
INCLUDE(CTest)
SET(ELMER_FEM_MAJOR_VERSION 9)
SET(ELMER_FEM_MINOR_VERSION 0)
SET(ELMER_FEM_VERSION
${ELMER_FEM_MAJOR_VERSION}.${ELMER_FEM_MINOR_VERSION})
IF(NOT(ELMER_FEM_REVISION))
SET(RESET_ELMER_REVISION TRUE CACHE BOOL "")
MARK_AS_ADVANCED(RESET_ELMER_REVISION)
ENDIF()
IF(RESET_ELMER_REVISION)
execute_process(
COMMAND "git" "--no-pager" "log" "-1" "--pretty=format:%h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE ELMER_FEM_REVISION_
RESULT_VARIABLE RUN_RETURN_VALUE)
IF(RUN_RETURN_VALUE EQUAL 0)
SET(ELMER_FEM_REVISION ${ELMER_FEM_REVISION_} CACHE STRING "" FORCE)
MARK_AS_ADVANCED(ELMER_FEM_REVISION)
ENDIF()
ENDIF()
SET(VERSION ${ELMER_FEM_VERSION})
SET(REVISION ${ELMER_FEM_REVISION})
SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
STRING(TIMESTAMP ELMER_FEM_COMPILATIONDATE "%Y-%m-%d")
SET(COMPILATIONDATE ${ELMER_FEM_COMPILATIONDATE})
# Check that the gfortran version is >= 7
IF(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
INCLUDE(testGFortranVersion)
IF(NOT CMAKE_Fortran_COMPILER_GNU_VERSION_OK)
MESSAGE(FATAL_ERROR "GNU Fortran major version is too old, should be at least 7")
ENDIF()
ENDIF()
IF(WITH_LUA)
IF(NOT(${USE_SYSTEM_LUA}))
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/contrib/lua-5.1.5/)
set(LUA_LIBRARIES luaelmer CACHE STRING "")
set(LUA_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/contrib/lua-5.1.5/src CACHE STRING "")
ELSE()
FIND_PACKAGE(Lua51 REQUIRED)
ENDIF()
SET(HAVE_LUA TRUE)
MARK_AS_ADVANCED(HAVE_LUA)
ENDIF()
IF(WITH_EXTOPTIM)
SET(HAVE_EXTOPTIM TRUE)
ENDIF()
IF(WITH_OpenMP)
FIND_PACKAGE(OpenMP REQUIRED)
# FIXME: Should link to the CMake targets instead
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# Set variables for supported OpenMP version
IF(OpenMP_Fortran_VERSION VERSION_GREATER_EQUAL 4.0)
SET(HAVE_OPENMP40 TRUE)
MARK_AS_ADVANCED(HAVE_OPENMP40)
IF(OpenMP_Fortran_VERSION VERSION_GREATER_EQUAL 4.5)
SET(HAVE_OPENMP45 TRUE)
MARK_AS_ADVANCED(HAVE_OPENMP45)
ENDIF()
ENDIF()
ENDIF()
# Get rid of the annoying rank mismatch warning
IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
IF(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 9.9)
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
# SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy")
ENDIF()
ENDIF()
# Import targets with information for using MPI or the MPI stub
ADD_LIBRARY(Elmer::MPI_Fortran INTERFACE IMPORTED)
ADD_LIBRARY(Elmer::MPI_C INTERFACE IMPORTED)
ADD_LIBRARY(Elmer::MPI_CXX INTERFACE IMPORTED)
IF(WITH_MPI)
# Advanced properties
MARK_AS_ADVANCED(
MPI_EXTRA_LIBRARY
MPI_LIBRARY
)
FIND_PACKAGE(MPI REQUIRED)
# Check features of found MPI
INCLUDE(testMPIcapabilities)
IF(ELMER_BROKEN_MPI_IN_PLACE)
ADD_DEFINITIONS(-DELMER_BROKEN_MPI_IN_PLACE)
ENDIF()
TARGET_LINK_LIBRARIES(Elmer::MPI_Fortran INTERFACE MPI::MPI_Fortran)
TARGET_LINK_LIBRARIES(Elmer::MPI_C INTERFACE MPI::MPI_C)
TARGET_LINK_LIBRARIES(Elmer::MPI_CXX INTERFACE MPI::MPI_CXX)
ENDIF(WITH_MPI)
IF (WITH_ROCALUTION)
IF(NOT WITH_MPI)
MESSAGE(FATAL_ERROR "Building with rocALUTION requires MPI")
ENDIF()
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS "Looking for rocALUTION installation")
FIND_PACKAGE(rocalution REQUIRED)
MESSAGE(STATUS " rocALUTION: " "${rocalution_FOUND}")
MESSAGE(STATUS " rocALUTION_INC: " "${ROCALUTION_INCLUDE_DIR}")
MESSAGE(STATUS " rocALUTION_LIB: " "${ROCALUTION_LIBRARY}")
SET(HAVE_ROCALUTION TRUE CACHE BOOL "")
MARK_AS_ADVANCED(HAVE_ROCALUTION)
ENDIF()
IF(WITH_AMGX)
FIND_PACKAGE(AMGX)
ENDIF()
IF(WITH_CHOLMOD)
FIND_PACKAGE(CHOLMOD)
FIND_PACKAGE(SPQR)
ENDIF()
# if(APPLE)
# # message(STATUS "Trying to find Accelerate library")
# # find_library(BLAS_LIBRARIES Accelerate HINTS /System/Library/Frameworks/Accelerate.framework)
# # MARK_AS_ADVANCED(BLAS_LIBRARIES)
# # set(BLAS_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -framework accelerate")
# # find_path(LAPACK_INCLUDE_DIRS
# # NAMES clapack.h
# # PATHS ${BLAS_INCLUDE_DIRS}
# # NO_DEFAULT_PATH
# # )
# # set(LAPACK_HEADER ${LAPACK_INCLUDE_DIRS}/clapack.h)
# # set(LAPACK_SUFFIX "_")
# # set(LAPACK_PREFIX)
# # message(STATUS "Using Accelerate framework on macOS")
# message("using the local blas library")
# # option(BLAS_VERBOSE "Print some additional information during BLAS libraries detection" ON)
# set(BLAS_DIR "./mathlibs/src/blas/")
# set(BLA_VENDOR "Generic")
# set(ACCELERATE_LIBS "-framework Accelerate")
# BLAS_Accelerate_LIBRARY:FILEPATH=/System/Library/Frameworks/Accelerate.framework
# else()
IF(WITH_MKL)
# Find MKL
FIND_PACKAGE(MKL REQUIRED)
SET(HAVE_MKL TRUE)
MARK_AS_ADVANCED(HAVE_MKL)
# Set BLAS and LAPACK to point to MKL
SET(BLAS_LIBRARIES ${MKL_BLAS_LIBRARIES} CACHE FILEPATH "")
SET(LAPACK_LIBRARIES ${MKL_LAPACK_LIBRARIES} CACHE FILEPATH "")
IF(MKL_SCALAPACK_LIBRARIES_FOUND)
SET(SCALAPACK_LIBRARIES ${MKL_SCALAPACK_LIBRARIES})
# Versions >11.1 of MKL include Cluster PARDISO direct solver
IF(MKL_CPARDISO_FOUND)
SET(HAVE_CPARDISO TRUE)
MARK_AS_ADVANCED(HAVE_CPARDISO)
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${MKL_INCLUDE_DIR})
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MKL_Fortran_FLAGS}")
ELSE()
IF (NOT BLAS_LIBRARIES OR NOT LAPACK_LIBRARIES)
# If BLAS/LAPACK not explicitly set, attempt to find MKL BLAS/LAPACK
FIND_PACKAGE(MKL QUIET)
IF (MKL_BLAS_LIBRARIES_FOUND AND MKL_LAPACK_LIBRARIES_FOUND)
# Set BLAS and LAPACK to point to MKL, in order to work around
# CMake FindBLAS finding wrong core library for GNU Fortran
SET(BLAS_LIBRARIES ${MKL_BLAS_LIBRARIES} CACHE FILEPATH "")
SET(LAPACK_LIBRARIES ${MKL_LAPACK_LIBRARIES} CACHE FILEPATH "")
INCLUDE_DIRECTORIES(${MKL_INCLUDE_DIR})
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MKL_Fortran_FLAGS}")
ENDIF()
ENDIF()
ENDIF()
# endif(APPLE)
# MARK_AS_ADVANCED(WITH_Trilinos)
IF(WITH_Trilinos)
IF(NOT WITH_MPI)
MESSAGE(FATAL_ERROR "Building with Trilinos requires MPI.")
ENDIF()
FIND_PACKAGE(ML REQUIRED PATHS ${TRILINOS_PATH}/lib/cmake/ML ${TRILINOS_PATH})
FIND_PACKAGE(Trilinos REQUIRED PATHS ${TRILINOS_PATH}/lib/cmake/Trilinos ${TRILINOS_PATH})
FIND_PACKAGE(Belos REQUIRED PATHS ${TRILINOS_PATH}/lib/cmake/Belos ${TRILINOS_PATH})
IF(ML_DIR)
ADD_DEFINITIONS(-DHAVE_TRILINOS)
ENDIF()
ENDIF()
IF(WITH_Zoltan)
# ZOLTAN Remeshing
MESSAGE(STATUS "------------------------------------------------")
IF(NOT USE_SYSTEM_ZOLTAN)
MESSAGE(STATUS "Building Zoltan mesh repartitioner")
ADD_SUBDIRECTORY(contrib/Zoltan_v3.83)
SET(HAVE_ZOLTAN TRUE CACHE BOOL "Has Zoltan tools for mesh (re)partitioning" )
MARK_AS_ADVANCED(HAVE_ZOLTAN)
MESSAGE(STATUS " Zoltan library: " "${ZOLTAN_LIBRARY}")
MESSAGE(STATUS "------------------------------------------------")
ELSE()
FIND_PACKAGE(Zoltan)
IF(Zoltan_FOUND)
SET(HAVE_ZOLTAN TRUE CACHE BOOL "Has Zoltan tools for mesh (re)partitioning" )
INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDE_DIR})
MESSAGE(STATUS "------------------------------------------------")
ELSE()
MESSAGE(STATUS " Zoltan library not found. ")
MESSAGE(STATUS " Missing: <ZOLTAN_INCLUDE_DIR> or <ZOLTAN_LIBRARY>")
ENDIF(Zoltan_FOUND)
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
ENDIF(WITH_Zoltan)
IF(WITH_NETCDF)
# ---------------------- #
# -- NETCDF libraries -- #
#----------------------- #
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS "Elmer/Ice package: Looking for [NETCDF] & [NETCDF Fortran] libraries")
FIND_PACKAGE(NETCDF)
IF(NETCDF_FOUND)
SET(HAVE_NETCDF TRUE CACHE BOOL "Has NETCDF for Elmer/Ice Output" )
GET_FILENAME_COMPONENT(NETCDF_LIBDIR ${NETCDF_LIBRARY} DIRECTORY)
GET_FILENAME_COMPONENT(NETCDFF_LIBDIR ${NETCDFF_LIBRARY} DIRECTORY)
MARK_AS_ADVANCED(HAVE_NETCDF)
INCLUDE_DIRECTORIES(${NETCDF_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_NETCDF)
MESSAGE(STATUS " NETCDF: " "${NETCDF_FOUND}")
MESSAGE(STATUS " NETCDF_INC: " "${NETCDF_INCLUDE_DIR}")
MESSAGE(STATUS " NETCDF_LIBS: " "${NETCDF_LIBRARIES}")
ELSE()
MESSAGE(STATUS "Library not found: >NETCDF_FOUND< ")
MESSAGE(WARNING " \n Missing: >NETCDF_INCLUDE_DIR< , >NETCDF_LIBRARY<, >NETCDFF_LIBRARY< \n some functionalities will be disabled")
ENDIF(NETCDF_FOUND)
IF(NETCDF_FOUND)
# ---------------------- #
# -- HDF5 libraries -- #
#----------------------- #
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS "Elmer/Ice package: Looking for [HDF5] & [HDF5 Fortran] libraries")
FIND_PACKAGE(PHDF5)
IF(PHDF5_FOUND)
SET(HAVE_HDF5 TRUE CACHE BOOL "Has HDF5 for Elmer/Ice Output" )
GET_FILENAME_COMPONENT(PHDF5_LIBDIR ${PHDF5_LIBRARY} DIRECTORY)
GET_FILENAME_COMPONENT(PHDF5HL_LIBDIR ${PHDF5HL_LIBRARY} DIRECTORY)
MARK_AS_ADVANCED(HAVE_HDF5)
INCLUDE_DIRECTORIES(${PHDF5_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_HDF5)
MESSAGE(STATUS " HDF5: " "${PHDF5_FOUND}")
MESSAGE(STATUS " HDF5_INC: " "${PHDF5_INCLUDE_DIR}")
MESSAGE(STATUS " HDF5_LIBS: " "${PHDF5_LIBRARIES}")
ELSE()
MESSAGE(STATUS "Library not found: >HDF5_FOUND< ")
MESSAGE(WARNING " \n Missing: >HDF5_INCLUDE_DIR< , >HDF5_LIBRARY<, >HDF5F_LIBRARY< \n some functionalities will be disabled")
ENDIF(PHDF5_FOUND)
ENDIF(NETCDF_FOUND)
ENDIF(WITH_NETCDF)
# MMG Remeshing
IF(WITH_MMG)
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS "Mesh adaptation 2D/3D looking for [Mmg] tools ")
FIND_PACKAGE(MMG)
# INCLUDE("cmake/Modules/FindMMG.cmake")
# INCLUDE_DIRECTORIES(${MMG_INCLUDE_DIR})
# TARGET_LINK_LIBRARIES( ${YOUR_TARGET} ${MMG_LIBRARY})
IF(MMG_FOUND)
SET(HAVE_MMG TRUE CACHE BOOL "Has Mmg tools for Elmer/Ice Mesh adaptation" )
GET_FILENAME_COMPONENT(MMG_LIBDIR ${MMG_LIBRARY} DIRECTORY)
MARK_AS_ADVANCED(HAVE_MMG)
MESSAGE(STATUS " Mmg: " "${MMG_FOUND}")
MESSAGE(STATUS " Mmg_INC: " "${MMG_INCLUDE_DIR}")
MESSAGE(STATUS " Mmg_LIB: " "${MMG_LIBRARY}")
MESSAGE(STATUS " Mmg_LIBDIR: " "${MMG_LIBDIR}")
MESSAGE(STATUS "Compile MMG2DSolver/MMG3DSolver")
ADD_DEFINITIONS(-DHAVE_MMG)
INCLUDE_DIRECTORIES(${MMG_INCLUDE_DIR})
MESSAGE(STATUS "------------------------------------------------")
ELSE()
MESSAGE(STATUS " Library not found: >MMG_FOUND< ")
MESSAGE(STATUS " Missing: >MMG_INCLUDE_DIR< , >MMG_LIBRARY<, to compile MMG3DSolver")
ENDIF(MMG_FOUND)
MESSAGE(STATUS "------------------------------------------------")
IF (WITH_PARMMG)
FIND_PACKAGE(PARMMG)
IF(PARMMG_FOUND)
SET(HAVE_PARMMG TRUE CACHE BOOL "Has ParMmg tools for Elmer/Ice Mesh adaptation" )
GET_FILENAME_COMPONENT(PARMMG_LIBDIR ${PARMMG_LIBRARY} DIRECTORY)
MARK_AS_ADVANCED(HAVE_PARMMG)
MESSAGE(STATUS " ParMmg: " "${PARMMG_FOUND}")
MESSAGE(STATUS " ParMmg_INC: " "${PARMMG_INCLUDE_DIR}")
MESSAGE(STATUS " ParMmg_LIB: " "${PARMMG_LIBRARY}")
MESSAGE(STATUS " ParMmg_LIBDIR: " "${PARMMG_LIBDIR}")
#MESSAGE(STATUS "Compile MMG2DSolver/MMG3DSolver")
ADD_DEFINITIONS(-DHAVE_PARMMG)
INCLUDE_DIRECTORIES(${PARMMG_INCLUDE_DIR})
MESSAGE(STATUS "------------------------------------------------")
ELSE()
MESSAGE(STATUS " Library not found: >PARMMG_FOUND< ")
MESSAGE(STATUS " Missing: >PARMMG_INCLUDE_DIR< , >PARMMG_LIBRARY<, to compile PARMMGSolver")
ENDIF(PARMMG_FOUND)
ELSE()
SET(PARMMG_FOUND FALSE)
MESSAGE(STATUS " Skipping ParMMG")
# INCLUDE("cmake/Modules/FindParMMG.cmake")
# INCLUDE_DIRECTORIES(${PARMMG_INCLUDE_DIR})
# TARGET_LINK_LIBRARIES( ${YOUR_TARGET} ${PARMMG_LIBRARY})
# SET(HAVE_PARMMG FALSE)
ENDIF(WITH_PARMMG)
ELSE()
SET(HAVE_MMG FALSE)
SET(HAVE_PARMMG FALSE)
ENDIF()
# XIOS
IF (WITH_XIOS)
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " Looking for XIOS ")
FIND_PACKAGE(XIOS)
IF(XIOS_FOUND)
SET(HAVE_XIOS TRUE)
MARK_AS_ADVANCED(HAVE_XIOS)
INCLUDE_DIRECTORIES(${XIOS_INCLUDE_DIR})
LINK_DIRECTORIES(${XIOS_LIBRARIES})
ADD_DEFINITIONS(-DHAVE_XIOS)
MESSAGE(STATUS " XIOS: " "${XIOS_FOUND}")
MESSAGE(STATUS " XIOS_INC: " "${XIOS_INCLUDE_DIR}")
MESSAGE(STATUS " XIOS_LIB : " "${XIOS_LIBRARIES}")
ELSE()
MESSAGE(STATUS " XIOS not found ")
ENDIF()
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
MESSAGE(STATUS "------------------------------------------------")
# MPI and LAPACK
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(LAPACK REQUIRED)
# BLAS and LAPACK libraries may be needed for testing
SET(CMAKE_REQUIRED_LIBRARIES
${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
IF(MPI_FOUND)
# Mumps
IF(WITH_Mumps)
FIND_PACKAGE(Mumps REQUIRED)
ENDIF()
# Hypre
IF(WITH_Hypre)
FIND_PACKAGE(Hypre REQUIRED OPTIONAL_COMPONENTS Euclid parcsr_ls ParaSails IJ_mv FEI core QUIET)
ENDIF()
# Permon
IF(WITH_FETI4I)
FIND_PACKAGE(FETI4I REQUIRED)
ENDIF()
ENDIF()
IF(Mumps_FOUND)
SET(HAVE_MUMPS TRUE)
MARK_AS_ADVANCED(HAVE_MUMPS)
# LINK_DIRECTORIES(${MUMPS_LIBRARIES})
ENDIF()
IF(Hypre_FOUND)
SET(HAVE_HYPRE TRUE)
MARK_AS_ADVANCED(HAVE_HYPRE)
INCLUDE_DIRECTORIES(${Hypre_INCLUDE_DIR})
# LINK_DIRECTORIES(${Hypre_LIBRARIES})
ENDIF()
IF(FETI4I_FOUND)
SET(HAVE_FETI4I TRUE)
MARK_AS_ADVANCED(HAVE_FETI4I)
ADD_DEFINITIONS(-DHAVE_FETI4I)
ENDIF()
IF (AMGX_FOUND)
SET(HAVE_AMGX TRUE)
MARK_AS_ADVANCED(HAVE_AMGX)
INCLUDE_DIRECTORIES(${AMGX_INCLUDE_DIR})
LINK_DIRECTORIES(${CUDA_LIBDIR})
ENDIF()
IF (CHOLMOD_FOUND AND SPQR_FOUND)
SET(HAVE_CHOLMOD TRUE)
MARK_AS_ADVANCED(HAVE_CHOLMOD)
ENDIF()
# Check if Fortran compiler supports procedure pointer
INCLUDE(testProcedurePointer)
IF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_PROCEDUREPOINTER)
MESSAGE(FATAL_ERROR "Fortran compiler does not seem to support the PROCEDURE statement.")
ENDIF()
# Check if Fortran compiler supports contiguous keyword
INCLUDE(testContiguous)
IF(USE_CONTIGUOUS AND CMAKE_Fortran_COMPILER_SUPPORTS_CONTIGUOUS)
ADD_DEFINITIONS(-DCONTIG=,CONTIGUOUS)
ELSE()
ADD_DEFINITIONS(-DCONTIG=)
ENDIF()
# Check if this is mingw toolchain.
IF(MINGW)
ADD_DEFINITIONS(-DMINGW32)
ENDIF()
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF()
# Check if Fortran compiler supports execute_command_line
INCLUDE(testExecutecommand)
IF(CMAKE_Fortran_COMPILER_SUPPORTS_EXECUTECOMMANDLINE)
ADD_DEFINITIONS(-DHAVE_EXECUTECOMMANDLINE)
ENDIF()
ADD_DEFINITIONS(-DUSE_ISO_C_BINDINGS)
SET(FC_STDCALLBULL " ")
SET(ELMER_LINKTYP 1)
#SET(FC_FUNC FC_GLOBAL)
#SET(FC_FUNC_ FC_GLOBAL_)
# Add support for arpack
ADD_DEFINITIONS(-DUSE_ARPACK)
#INCLUDE(FortranCInterface)
#FortranCInterface_HEADER(FCMangle.h MACRO_NAMESPACE "FC_")
#FortranCInterface_VERIFY(CXX)
# Set up rpaths to point ELMER_INSTALL_LIB_DIR
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(ELMERSOLVER_RPATH_STRING "\$ORIGIN/../${ELMER_INSTALL_LIB_DIR}")
SET(ELMERLIB_RPATH_STRING "\$ORIGIN/")
ELSEIF(APPLE)
SET(ELMERSOLVER_RPATH_STRING "@loader_path/../${ELMER_INSTALL_LIB_DIR}")
SET(ELMERLIB_RPATH_STRING "@loader_path/")
ENDIF()
# Uncomment these to use rpath with linked libraries
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Remove system directories (from the CMake guide)
# LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
# IF("${isSystemDir}" STREQUAL "-1")
# SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# ENDIF("${isSystemDir}" STREQUAL "-1")
ADD_SUBDIRECTORY(matc)
IF(WITH_ElmerIce)
IF(NOT WITH_MPI)
MESSAGE(FATAL_ERROR "Building ElmerIce requires MPI.")
ENDIF()
MESSAGE(STATUS "Adding optional package ElmerIce")
ADD_SUBDIRECTORY(elmerice)
ENDIF(WITH_ElmerIce)
IF (WITH_UMFPACK)
IF (EXTERNAL_UMFPACK)
MESSAGE(STATUS "Using external UMFPACK instead of built-in")
FIND_PACKAGE(UMFPACK REQUIRED)
# Check for size of "SuiteSparse_long"
INCLUDE(CheckTypeSize)
SET(old_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
SET(old_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES})
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${UMFPACK_INCLUDE_DIR}")
LIST(APPEND CMAKE_EXTRA_INCLUDE_FILES "umfpack.h")
CHECK_TYPE_SIZE("SuiteSparse_long" SIZEOF_SUITESPARSE_LONG LANGUAGE C)
SET(CMAKE_REQUIRED_INCLUDES ${old_CMAKE_REQUIRED_INCLUDES})
SET(CMAKE_EXTRA_INCLUDE_FILES ${old_CMAKE_EXTRA_INCLUDE_FILES})
IF (HAVE_SIZEOF_SUITESPARSE_LONG)
IF (SIZEOF_SUITESPARSE_LONG EQUAL 4)
SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT32_T")
ELSE()
SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT64_T")
ENDIF()
ENDIF()
ELSE()
MESSAGE(STATUS "Using built-in UMFPACK")
ADD_SUBDIRECTORY(umfpack)
ENDIF()
SET(HAVE_UMFPACK ON)
MARK_AS_ADVANCED(HAVE_UMFPACK)
ELSE()
MESSAGE(STATUS "Building without UMFPACK")
ENDIF()
IF(NOT DEFINED UMFPACK_LONG_FORTRAN_TYPE)
# Old versions of UMFPACK before "SuiteSparse_long" was defined used "long"
SET(UMFPACK_LONG_FORTRAN_TYPE "C_LONG")
ENDIF()
# Find external arpack and parpack
IF(EXTERNAL_ARPACK)
MESSAGE(STATUS "Using external arpack library instead of built-in")
FIND_PACKAGE(ARPACK REQUIRED)
SET(CMAKE_REQUIRED_LIBRARIES
${CMAKE_REQUIRED_LIBRARIES} ${ARPACK_LIBRARIES})
ENDIF()
IF(MPI_FOUND AND EXTERNAL_PARPACK)
MESSAGE(STATUS "Using external parpack library instead of built-in")
FIND_PACKAGE(PARPACK REQUIRED)
SET(CMAKE_REQUIRED_LIBRARIES
${CMAKE_REQUIRED_LIBRARIES} ${PARPACK_LIBRARIES})
ENDIF()
ADD_SUBDIRECTORY(fhutiter)
ADD_SUBDIRECTORY(meshgen2d)
ADD_SUBDIRECTORY(fem)
ADD_SUBDIRECTORY(mathlibs)
ADD_SUBDIRECTORY(elmergrid)
ADD_SUBDIRECTORY(license_texts)
IF(WITH_ELMERGUI)
MESSAGE(STATUS " Building ElmerGUI")
MESSAGE(STATUS "------------------------------------------------")
ADD_SUBDIRECTORY(ElmerGUI)
ENDIF(WITH_ELMERGUI)
IF(WITH_ELMERGUITESTER)
ADD_SUBDIRECTORY(ElmerGUItester)
ENDIF(WITH_ELMERGUITESTER)
IF(WITH_ELMERGUILOGGER)
ADD_SUBDIRECTORY(ElmerGUIlogger)
ENDIF(WITH_ELMERGUILOGGER)
#INCLUDE(FeatureSummary)
#FEATURE_SUMMARY(WHAT ENABLED_FEATURES
# INCLUDE_QUIET_PACKAGES
# DESCRIPTION "Enabled Features:"
# VAR enabledFeaturesText)
#MESSAGE(STATUS "${enabledFeaturesText}")
#
IF(CMAKE_BUILD_TYPE)
STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPCASE)
MARK_AS_ADVANCED(CMAKE_BUILD_TYPE_UPCASE)
ENDIF(CMAKE_BUILD_TYPE)
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " BLAS library: " "${BLAS_LIBRARIES}")
MESSAGE(STATUS " LAPACK library: " "${LAPACK_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
IF(WITH_UMFPACK)
IF(UMFPACK_FOUND)
MESSAGE(STATUS " UMFPACK library: " "${UMFPACK_LIBRARIES}")
MESSAGE(STATUS " UMFPACK headers: " "${UMFPACK_INCLUDE_DIR}")
MESSAGE(STATUS "------------------------------------------------")
ELSE()
MESSAGE(STATUS " UMFPACK library: Using internal Elmer library")
ENDIF()
ELSE()
MESSAGE(STATUS " UMFPACK library: Building without UMFPACK")
ENDIF()
IF(CHOLMOD_FOUND AND SPQR_FOUND)
MESSAGE(STATUS " CHOLMOD library: " "${CHOLMOD_LIBRARIES}")
MESSAGE(STATUS " CHOLMOD headers: " "${CHOLMOD_INCLUDE_DIR}")
MESSAGE(STATUS " SPQR library: " "${SPQR_LIBRARIES}")
MESSAGE(STATUS " SPQR headers: " "${SPQR_INCLUDE_DIR}")
MESSAGE(STATUS "------------------------------------------------")
MARK_AS_ADVANCED(HAVE_CHOLMOD)
ENDIF()
IF(ARPACK_FOUND)
MESSAGE(STATUS " ARPACK library: " "${ARPACK_LIBRARIES}")
MESSAGE(STATUS " ARPACK headers: " "${ARPACK_INCLUDE_DIR}")
ELSE()
MESSAGE(STATUS " ARPACK library: Using internal Elmer library")
ENDIF()
IF(PARPACK_FOUND)
MESSAGE(STATUS " PARPACK library: " "${PARPACK_LIBRARIES}")
MESSAGE(STATUS " PARPACK headers: " "${PARPACK_INCLUDE_DIR}")
MESSAGE(STATUS "------------------------------------------------")
ELSE()
MESSAGE(STATUS " PARPACK library: Using internal Elmer library")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_Zoltan AND NOT USE_SYSTEM_ZOLTAN)
MESSAGE(STATUS " Zoltan: building bundled code")
MESSAGE(STATUS "------------------------------------------------")
ELSEIF(WITH_Zoltan AND HAVE_ZOLTAN)
MESSAGE(STATUS " Zoltan library: " "${ZOLTAN_LIBRARY}")
MESSAGE(STATUS " Zoltan headers: " "${ZOLTAN_INCLUDE_DIR}")
MESSAGE(STATUS "------------------------------------------------")
ELSEIF(WITH_Zoltan AND NOT Zoltan_FOUND)
MESSAGE(STATUS " Zoltan system library not found")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
MESSAGE(STATUS " Fortran compiler: " "${CMAKE_Fortran_COMPILER}")
MESSAGE(STATUS " Fortran flags: " "${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPCASE}}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " C compiler: " "${CMAKE_C_COMPILER}")
MESSAGE(STATUS " C flags: " "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPCASE}}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " CXX compiler: " "${CMAKE_CXX_COMPILER}")
MESSAGE(STATUS " CXX flags: " "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPCASE}}")
MESSAGE(STATUS "------------------------------------------------")
IF(WITH_MPI)
MESSAGE(STATUS " MPI Fortran: " "${MPI_Fortran_FOUND}")
MESSAGE(STATUS " MPI Fortran compiler: " "${MPI_Fortran_COMPILER}")
MESSAGE(STATUS " MPI Fortran flags: " "${MPI_Fortran_COMPILE_FLAGS}")
MESSAGE(STATUS " MPI Fortran include dir: " "${MPI_Fortran_INCLUDE_PATH}")
MESSAGE(STATUS " MPI Fortran libraries: " "${MPI_Fortran_LIBRARIES}")
MESSAGE(STATUS " MPI Fortran link flags: " "${MPI_Fortran_LINK_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " MPI C: " "${MPI_C_FOUND}")
MESSAGE(STATUS " MPI C compiler: " "${MPI_C_COMPILER}")
MESSAGE(STATUS " MPI C flags: " "${MPI_C_COMPILE_FLAGS}")
MESSAGE(STATUS " MPI C include dir: " "${MPI_C_INCLUDE_PATH}")
MESSAGE(STATUS " MPI C libraries: " "${MPI_C_LIBRARIES}")
MESSAGE(STATUS " MPI C flags: " "${MPI_C_LINK_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
IF(WITH_Mumps)
MESSAGE(STATUS " Mumps: " "${Mumps_FOUND}")
MESSAGE(STATUS " Mumps include: " "${Mumps_INCLUDE_DIR}")
MESSAGE(STATUS " Mumps libraries: " "${Mumps_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_Mumps)
IF(WITH_Hypre)
MESSAGE(STATUS " Hypre: " "${Hypre_FOUND}")
MESSAGE(STATUS " Hypre include: " "${Hypre_INCLUDE_DIR}")
MESSAGE(STATUS " Hypre libraries: " "${Hypre_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_Hypre)
ENDIF(WITH_MPI)
IF(WITH_Trilinos)
MESSAGE(STATUS " Trilinos: " "${Trilinos_FOUND}")
MESSAGE(STATUS " Trilinos_DIR: " "${Trilinos_DIR}")
MESSAGE(STATUS " Trilinos_LIBRARIES: " "${Trilinos_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_Trilinos)
IF(WITH_CONTRIB)
MESSAGE(STATUS " Building contributed solvers")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_CONTRIB)
IF(WITH_ELMERGUITESTER)
MESSAGE(STATUS " Building ElmerGUI tester")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_ELMERGUITESTER)
IF(WITH_ELMERGUILOGGER)
MESSAGE(STATUS " Building ElmerGUI logger")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(WITH_ELMERGUILOGGER)
IF(WITH_ELMERPOST)
MESSAGE(WARNING " Building ElmerPost")
MESSAGE(STATUS "------------------------------------------------")
ADD_SUBDIRECTORY(post)
ENDIF(WITH_ELMERPOST)
IF(HAVE_LUA)
MESSAGE(STATUS " Building Lua")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(HAVE_LUA)
IF(HAVE_EXTOPTIM)
MESSAGE(STATUS " Building with external optimization routines")
MESSAGE(STATUS "------------------------------------------------")
ENDIF(HAVE_EXTOPTIM)
IF(NOT HAVE_UMFPACK AND NOT HAVE_MUMPS)
MESSAGE(WARNING "Elmer is configured without backend for direct solvers (UMFPACK or MUMPS).\n"
"Are you sure this is intended?")
ENDIF()
# Packaging
if(NOT BYPASS_CPACK)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cpack/ElmerCPack.cmake)
endif(NOT BYPASS_CPACK)