-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2132 lines (1983 loc) · 80.5 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
# Gmsh - Copyright (C) 1997-2020 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
# do not warn about non-definition of WIN32 on Cygwin
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# if CMAKE_BUILD_TYPE is specified use it; otherwise set the default
# build type to "RelWithDebInfo" ("-O2 -g" with gcc) prior to calling
# project()
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type")
else()
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
endif()
project(gmsh CXX C)
# this variable controls the default value of the options which are normally set
# to ON (useful if you want to configure a minimal version of Gmsh: e.g. "cmake
# -DDEFAULT=0 -DENABLE_POST=1 -DENABLE_PARSER=1")
set(DEFAULT ON CACHE INTERNAL "Default value for enabled-by-default options")
macro(opt OPTION HELP VALUE)
option(ENABLE_${OPTION} ${HELP} ${VALUE})
set(OPT_TEXI "${OPT_TEXI}\n@item ENABLE_${OPTION}\n${HELP} (default: ${VALUE})")
endmacro()
opt(3M "Enable proprietary 3M extension" OFF)
opt(ALGLIB "Enable ALGLIB (used by some mesh optimizers)" ${DEFAULT})
opt(ANN "Enable ANN (used for fast point search in mesh/post)" ${DEFAULT})
opt(BAMG "Enable Bamg 2D anisotropic mesh generator" ${DEFAULT})
opt(BLAS_LAPACK "Enable BLAS/Lapack for linear algebra (required for meshing)" ON)
opt(BLOSSOM "Enable Blossom algorithm (needed for full quad meshing)" ${DEFAULT})
opt(BUILD_LIB "Enable 'lib' target for building static Gmsh library" OFF)
opt(BUILD_SHARED "Enable 'shared' target for building shared Gmsh library" OFF)
opt(BUILD_DYNAMIC "Enable dynamic Gmsh executable (linked with shared library)" OFF)
opt(BUILD_ANDROID "Enable Android NDK library target (experimental)" OFF)
opt(BUILD_IOS "Enable iOS library target (experimental)" OFF)
opt(CGNS "Enable CGNS import/export (experimental)" ${DEFAULT})
opt(CGNS_CPEX0045 "Enable high-order CGNS import/export following CPEX0045 (experimental)" OFF)
opt(CAIRO "Enable Cairo to render fonts (experimental)" ${DEFAULT})
opt(CXX11 "Enable C++11" ON)
opt(C99 "Enable C99" ON)
opt(PROFILE "Enable profiling compiler flags" OFF)
opt(DINTEGRATION "Enable discrete integration (needed for levelsets)" ${DEFAULT})
opt(DOMHEX "Enable experimental DOMHEX code" ${DEFAULT})
opt(FLTK "Enable FLTK graphical user interface (requires mesh/post)" ${DEFAULT})
opt(GETDP "Enable GetDP solver (linked as a library, experimental)" ${DEFAULT})
opt(GMM "Enable GMM linear solvers (simple alternative to PETSc)" ${DEFAULT})
opt(GMP "Enable GMP for Kbipack (advanced)" ON)
opt(GRAPHICS "Enable building graphics lib even without GUI (advanced)" OFF)
opt(HXT "Enable HXT library (for reparametrization and meshing)" ${DEFAULT})
opt(KBIPACK "Enable Kbipack (neeeded by homology solver)" ${DEFAULT})
opt(MATHEX "Enable Mathex expression parser (used by plugins and options)" ${DEFAULT})
opt(MED "Enable MED mesh and post file formats" ${DEFAULT})
opt(MESH "Enable mesh module (required by GUI)" ${DEFAULT})
opt(METIS "Enable Metis mesh partitioner" ${DEFAULT})
opt(MMG3D "Enable MMG3D 3D anisotropic mesh refinement" ${DEFAULT})
opt(MPEG_ENCODE "Enable built-in MPEG movie encoder" ${DEFAULT})
opt(MPI "Enable MPI (experimental, not used for meshing)" OFF)
opt(MSVC_STATIC_RUNTIME "Enable static Visual C++ runtime" OFF)
opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF)
opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT})
opt(NUMPY "Enable fullMatrix and numpy array conversion for private API" OFF)
opt(PETSC4PY "Enable petsc4py wrappers for petsc matrices for private API" OFF)
opt(OCC "Enable OpenCASCADE CAD kernel" ${DEFAULT})
opt(OCC_CAF "Enable OpenCASCADE CAF module (for STEP/IGES attributes)" ${DEFAULT})
opt(OCC_STATIC "Link OpenCASCADE static instead of dynamic libraries (requires ENABLE_OCC)" OFF)
opt(OCC_TBB "Add TBB libraries in list of OCC libraries" OFF)
opt(ONELAB "Enable ONELAB solver interface" ${DEFAULT})
opt(ONELAB_METAMODEL "Enable ONELAB metamodels (experimental)" ${DEFAULT})
opt(OPENACC "Enable OpenACC" OFF)
opt(OPENMP "Enable OpenMP" OFF)
opt(OPTHOM "Enable high-order mesh optimization tools" ${DEFAULT})
opt(OS_SPECIFIC_INSTALL "Enable OS-specific (e.g. app bundle) installation" OFF)
opt(OSMESA "Enable OSMesa for offscreen rendering (experimental)" OFF)
opt(P4EST "Enable p4est for enabling automatic mesh size field (experimental)" OFF)
opt(PACKAGE_STRIP "Strip symbols in install packages to reduce install size" ON)
opt(PARSER "Enable GEO file parser (required for .geo/.pos scripts)" ${DEFAULT})
opt(PETSC "Enable PETSc linear solvers (required for SLEPc)" OFF)
opt(PLUGINS "Enable post-processing plugins" ${DEFAULT})
opt(POST "Enable post-processing module (required by GUI)" ${DEFAULT})
opt(POPPLER "Enable Poppler for displaying PDF documents (experimental)" OFF)
opt(PRIVATE_API "Enable private API" OFF)
opt(PRO "Enable PRO extensions" ${DEFAULT})
opt(QUADTRI "Enable QuadTri structured meshing extensions" ${DEFAULT})
opt(REVOROPT "Enable Revoropt (used for CVT remeshing)" OFF)
opt(RPATH "Use RPATH in dynamically linked targets" ON)
opt(SLEPC "Enable SLEPc eigensolvers" OFF)
opt(SOLVER "Enable built-in finite element solvers (required for reparametrization)" ${DEFAULT})
opt(SYSTEM_CONTRIB "Use system versions of contrib libraries, when possible" OFF)
opt(TCMALLOC "Enable libtcmalloc (fast malloc that does not release memory)" OFF)
opt(TOUCHBAR "Enable Apple Touch bar" ${DEFAULT})
opt(VISUDEV "Enable additional visualization capabilities for development purposes" OFF)
opt(VOROPP "Enable voro++ (for hex meshing, experimental)" ${DEFAULT})
opt(WRAP_JAVA "Generate SWIG Java wrappers for private API" OFF)
opt(WRAP_PYTHON "Generate SWIG Python wrappers for private API (not used by public API)" OFF)
opt(ZIPPER "Enable Zip file compression/decompression" OFF)
set(GMSH_MAJOR_VERSION 4)
set(GMSH_MINOR_VERSION 6)
set(GMSH_PATCH_VERSION 0)
set(GMSH_EXTRA_VERSION "")
set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION}")
if(NOT GMSH_RELEASE)
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ERROR_QUIET
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(GIT_COMMIT_HASH)
set(GMSH_EXTRA_VERSION "${GMSH_EXTRA_VERSION}-git-${GIT_COMMIT_HASH}")
endif()
set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION_TEXI} (development version)")
endif()
set(GMSH_SHORT_VERSION
"${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}")
set(GMSH_VERSION "${GMSH_SHORT_VERSION}${GMSH_EXTRA_VERSION}")
set(GMSH_SHORT_LICENSE "GNU General Public License")
set(GMSH_API api/gmsh.h api/gmshc.h api/gmsh.h_cwrap)
if(ENABLE_PRIVATE_API)
message(WARNING "The private API is unsupported and undocumented. It is meant "
"for expert Gmsh developers, not for regular Gmsh users, who should rely "
"on the stable public API (gmsh/api) instead. If you are repackaging Gmsh, "
"e.g. for a Linux distribution, please DO NOT distribute the private API "
"(i.e. all the internal headers) and ship the stable public API instead "
"(i.e. only the headers and modules in gmsh/api).")
file(GLOB_RECURSE HEADERS Common/*.h Numeric/*.h Geo/*.h Mesh/*.h Solver/*.h
Post/*.h Graphics/*.h contrib/kbipack/*.h contrib/DiscreteIntegration/*.h
contrib/HighOrderMeshOptimizer/*.h contrib/MeshOptimizer/*.h
contrib/MeshQualityOptimizer/*.h)
set(GMSH_PRIVATE_API ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h ${HEADERS})
get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY)
if(IAMCHILD)
set(GMSH_PRIVATE_API ${GMSH_PRIVATE_API} PARENT_SCOPE)
endif()
if(ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
set(ENABLE_BUILD_DYNAMIC ON)
message(WARNING "SWIG wrappers for the private API are unsupported and "
"undocumented. The stable public Python API does not required SWIG.")
endif()
endif()
if(NOT ENABLE_BUILD_SHARED)
endif()
set(ONELAB_PY contrib/onelab/python/onelab.py)
set(GMSH_PY api/gmsh.py)
set(GMSH_JL api/gmsh.jl)
if(${CMAKE_MAJOR_VERSION} GREATER 2)
string(TIMESTAMP DATE "%Y%m%d")
else()
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(NOT DATE)
set(DATE "unknown")
endif()
set(GMSH_DATE "${DATE}")
if(NOT GMSH_HOST)
execute_process(COMMAND hostname OUTPUT_VARIABLE HOSTNAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT HOSTNAME)
set(HOSTNAME "unknown")
endif()
set(GMSH_HOST "${HOSTNAME}")
endif()
if(NOT GMSH_PACKAGER)
execute_process(COMMAND whoami OUTPUT_VARIABLE PACKAGER
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT PACKAGER)
set(PACKAGER "unknown")
endif()
string(REPLACE "\\" " " PACKAGER ${PACKAGER})
set(GMSH_PACKAGER "${PACKAGER}")
endif()
if(APPLE)
set(GMSH_OS "MacOSX")
elseif(CYGWIN OR MSYS)
# detect if we use the MinGW compilers on Cygwin - if we do, handle the build
# as a pure Windows build
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE CXX_COMPILER_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CXX_COMPILER_MACHINE MATCHES "mingw")
set(GMSH_OS "Windows")
set(WIN32 1)
add_definitions(-DWIN32)
endif()
endif()
else()
set(GMSH_OS "${CMAKE_SYSTEM_NAME}")
endif()
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
macro(set_config_option VARNAME STRING)
set(${VARNAME} TRUE)
list(APPEND CONFIG_OPTIONS ${STRING})
message(STATUS "Found " ${STRING})
endmacro()
# check the size of size_t
check_type_size("size_t" SIZEOF_SIZE_T)
if(SIZEOF_SIZE_T EQUAL 8)
set_config_option(HAVE_64BIT_SIZE_T "64Bit")
endif()
# append 32/64 to the build name on Linux and Windows
if(NOT APPLE)
if(HAVE_64BIT_SIZE_T)
set(GMSH_OS "${GMSH_OS}64")
else()
set(GMSH_OS "${GMSH_OS}32")
endif()
endif()
if(ENABLE_BUILD_DYNAMIC)
set(GMSH_OS "${GMSH_OS}-sdk")
endif()
if(ENABLE_RPATH)
set(CMAKE_MACOSX_RPATH 1)
# make sure that dynamic libraries can be found when installing/ displacing
# the binaries: from https://gitlab.kitware.com/cmake/community/wikis/doc/
# cmake/RPATH-handling:
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already (but later on when
# installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH which point to
# directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib"
isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
if(APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
else()
set(CMAKE_INSTALL_RPATH "\\\$ORIGIN/../lib")
endif()
endif()
else()
set(CMAKE_MACOSX_RPATH 0)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
endif()
if(MSVC)
# remove annoying warning about bool/int cast performance
set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800 4244 4267)")
foreach(VAR
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(ENABLE_MSVC_STATIC_RUNTIME AND ${VAR} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
endif()
if(NOT ${VAR} MATCHES "/MP") # enable parallel compilation
set(${VAR} "${${VAR}} /MP")
endif()
endforeach()
if(ENABLE_PRIVATE_API)
if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
# automatically export .def file with all symbols (requires CMake 3.4);
# depending on the compiling options this might lead to more than 64k export
# symbols; just trim the .def file to keep the ones you need
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
endif()
endif()
if(ENABLE_OPENMP)
find_package(OpenMP)
if(OpenMP_FOUND OR OPENMP_FOUND)
set_config_option(HAVE_OPENMP "OpenMP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
elseif(APPLE AND EXISTS "/opt/local/lib/libomp")
# official Apple compiler with macports' libomp
set_config_option(HAVE_OPENMP "OpenMP[MacPorts]")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
list(APPEND EXTERNAL_LIBRARIES "-L/opt/local/lib/libomp -lomp")
elseif(APPLE AND EXISTS "/usr/local/lib/libomp.dylib")
# official Apple compiler with homebrew's libomp
set_config_option(HAVE_OPENMP "OpenMP[usr/local]")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp")
list(APPEND EXTERNAL_LIBRARIES "-lomp")
endif()
endif()
if(ENABLE_OPENACC)
find_package(OpenACC)
if(OpenACC_C_FOUND AND OpenACC_CXX_FOUND)
set_config_option(HAVE_OPENACC "OpenACC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenACC_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenACC_CXX_FLAGS}")
endif()
endif()
if(ENABLE_CXX11)
# in recent cmake versions we could do e.g. set(CMAKE_CXX_STANDARD 11)
check_cxx_compiler_flag("-std=c++11" STDCXX11)
if(STDCXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
endif()
if(ENABLE_C99)
# in recent cmake versions we could do e.g. set(CMAKE_C_STANDARD 99)
check_c_compiler_flag("-std=c99" STDC99)
if(STDC99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
endif()
endif()
if(ENABLE_PROFILE)
# Using the perf set of profiling tools doesn't work without the frame
# pointer and a common optimisation is to remove it
check_cxx_compiler_flag("-fno-omit-frame-pointer" FNOFP)
if(FNOFP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
endif()
endif()
macro(append_gmsh_src DIRNAME FILES)
foreach(FILE ${FILES})
list(APPEND LIST ${DIRNAME}/${FILE})
endforeach()
set(GMSH_SRC ${GMSH_SRC};${LIST} PARENT_SCOPE)
set(GMSH_DIRS ${GMSH_DIRS};${DIRNAME} PARENT_SCOPE)
endmacro()
macro(find_all_libraries VARNAME LISTNAME PATH SUFFIX)
set(${VARNAME})
list(LENGTH ${LISTNAME} NUM_LIST)
foreach(LIB ${${LISTNAME}})
if("${PATH}" STREQUAL "")
find_library(FOUND_LIB ${LIB} PATH_SUFFIXES ${SUFFIX})
else()
find_library(FOUND_LIB ${LIB} PATHS ${PATH} NO_DEFAULT_PATH)
endif()
if(FOUND_LIB)
list(APPEND ${VARNAME} ${FOUND_LIB})
endif()
unset(FOUND_LIB CACHE)
endforeach()
list(LENGTH ${VARNAME} NUM_FOUND_LIBRARIES)
if(NUM_FOUND_LIBRARIES LESS NUM_LIST)
set(${VARNAME})
endif()
endmacro()
macro(set_compile_flags LISTNAME FLAGS)
foreach(FILE ${${LISTNAME}})
get_source_file_property(PROP ${FILE} COMPILE_FLAGS)
if(PROP)
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${PROP} ${FLAGS}")
else()
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${FLAGS}")
endif()
endforeach()
endmacro()
if(ENABLE_BLAS_LAPACK)
if(BLAS_LAPACK_LIBRARIES)
# use libs as specified in the BLAS_LAPACK_LIBRARIES variable
set_config_option(HAVE_BLAS "Blas[custom]")
set_config_option(HAVE_LAPACK "Lapack[custom]")
set(LAPACK_LIBRARIES ${BLAS_LAPACK_LIBRARIES})
else()
if(MSVC)
# on Windows with Visual C++ try really hard to find blas/lapack *without*
# requiring a Fortran compiler: 1) try to find the Intel MKL libs using
# the standard search path; if not found 2) try to get the reference
# blas/lapack libs (useful for users with no Fortran compiler and no MKL
# license, who can just download our precompiled "gmsh-dep" package)
if(HAVE_64BIT_SIZE_T)
set(MKL_PATH em64t/lib)
set(MKL_LIBS_REQUIRED libguide40 mkl_intel_lp64 mkl_intel_thread mkl_core)
else()
set(MKL_PATH ia32/lib)
set(MKL_LIBS_REQUIRED libguide40 mkl_intel_c mkl_intel_thread mkl_core)
endif()
find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[mkl]")
set_config_option(HAVE_LAPACK "Lapack[mkl]")
else()
set(REFLAPACK_LIBS_REQUIRED lapack blas g2c gcc)
find_all_libraries(LAPACK_LIBRARIES REFLAPACK_LIBS_REQUIRED "" "")
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[ref]")
set_config_option(HAVE_LAPACK "Lapack[ref]")
endif()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# on Linux try to find the Intel MKL without a Fortran compiler
if(HAVE_64BIT_SIZE_T)
set(MKL_PATH lib/em64t)
else()
set(MKL_PATH lib/32)
endif()
set(MKL_LIBS_REQUIRED mkl_gf_lp64 iomp5 mkl_gnu_thread mkl_core guide pthread)
find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
if(NOT LAPACK_LIBRARIES)
# match lapack 9.0 on 64bit
set(MKL_LIBS_REQUIRED mkl_lapack mkl_em64t guide)
find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
endif()
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[mkl]")
set_config_option(HAVE_LAPACK "Lapack[mkl]")
else()
# on Linux also try to find ATLAS without a Fortran compiler, because
# cmake ships with a buggy FindBLAS e.g. on Ubuntu Lucid Lynx
set(ATLAS_LIBS_REQUIRED lapack f77blas cblas atlas)
find_all_libraries(LAPACK_LIBRARIES ATLAS_LIBS_REQUIRED "" "")
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[atlas]")
set_config_option(HAVE_LAPACK "Lapack[atlas]")
else()
# try with generic names
set(GENERIC_LIBS_REQUIRED lapack blas pthread)
find_all_libraries(LAPACK_LIBRARIES GENERIC_LIBS_REQUIRED "" "")
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[generic]")
set_config_option(HAVE_LAPACK "Lapack[generic]")
find_library(GFORTRAN_LIB gfortran)
if(GFORTRAN_LIB)
list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
endif()
endif()
endif()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
# on SunOS we know blas and lapack are available in sunperf
set(LAPACK_LIBRARIES -library=sunperf)
set_config_option(HAVE_BLAS "Blas[sunperf]")
set_config_option(HAVE_LAPACK "Lapack[sunperf]")
elseif(APPLE)
# on Mac we also know that blas and lapack are available
set(LAPACK_LIBRARIES "-llapack -lblas")
set_config_option(HAVE_BLAS "Blas[veclib]")
set_config_option(HAVE_LAPACK "Lapack[veclib]")
endif()
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
# if we haven't found blas and lapack check for OpenBlas
set(OPENBLAS_LIBS_REQUIRED openblas)
find_all_libraries(LAPACK_LIBRARIES OPENBLAS_LIBS_REQUIRED "" "")
if(LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas[openblas]")
set_config_option(HAVE_LAPACK "Lapack[openblas]")
find_library(GFORTRAN_LIB gfortran)
if(GFORTRAN_LIB)
list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
endif()
endif()
endif()
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
# if we still haven't found blas and lapack, use the standard cmake tests,
# which require a working Fortran compiler
enable_language(Fortran)
find_package(BLAS)
if(BLAS_FOUND)
set_config_option(HAVE_BLAS "Blas")
find_package(LAPACK)
if(LAPACK_FOUND)
set_config_option(HAVE_LAPACK "Lapack")
else()
set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
if(CMAKE_Fortran_COMPILER MATCHES "gfortran")
list(APPEND LAPACK_LIBRARIES gfortran)
elseif(CMAKE_Fortran_COMPILER MATCHES "f95")
list(APPEND LAPACK_LIBRARIES gfortran)
elseif(CMAKE_Fortran_COMPILER MATCHES "g77")
list(APPEND LAPACK_LIBRARIES g2c)
endif()
elseif(CMAKE_Fortran_COMPILER MATCHES "pgi")
list(APPEND LAPACK_LIBRARIES -pgf77libs)
endif()
endif()
endif()
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
message(WARNING "Could not find Blas or Lapack: most meshing algorithms "
"will not be functional")
endif()
endif()
endif()
if(ENABLE_TCMALLOC)
find_library(TCMALLOC tcmalloc)
if(TCMALLOC)
set_config_option(HAVE_TCMALLOC "TCMalloc")
list(APPEND EXTERNAL_LIBRARIES ${TCMALLOC})
endif()
endif()
add_subdirectory(Common)
add_subdirectory(Numeric)
add_subdirectory(Geo)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh AND ENABLE_MESH)
add_subdirectory(Mesh)
set_config_option(HAVE_MESH "Mesh")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Solver AND ENABLE_SOLVER)
add_subdirectory(Solver)
set_config_option(HAVE_SOLVER "Solver")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Post AND ENABLE_POST)
add_subdirectory(Post)
set_config_option(HAVE_POST "Post")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Plugin AND ENABLE_PLUGINS)
add_subdirectory(Plugin)
set_config_option(HAVE_PLUGINS "Plugins")
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Parser AND ENABLE_PARSER)
add_subdirectory(Parser)
set_config_option(HAVE_PARSER "Parser")
endif()
if(ENABLE_VISUDEV)
set_config_option(HAVE_VISUDEV "VisuDev")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Fltk AND ENABLE_FLTK)
# first, try to use fltk-config for fltk >= 1.3 (FindFLTK is buggy on Unix,
# where e.g. xft and xinerama options are not dealt with)
find_program(FLTK_CONFIG_SCRIPT fltk-config)
if(FLTK_CONFIG_SCRIPT)
execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --api-version
OUTPUT_VARIABLE FLTK_VERSION)
string(STRIP "${FLTK_VERSION}" FLTK_VERSION)
if(FLTK_VERSION VERSION_GREATER 1.1)
add_subdirectory(Fltk)
set_config_option(HAVE_FLTK "Fltk")
message(STATUS "Using fltk-config script for Fltk " ${FLTK_VERSION})
execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --includedir
OUTPUT_VARIABLE FLTK_INCLUDE_DIR)
string(STRIP ${FLTK_INCLUDE_DIR} FLTK_INCLUDE_DIR)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
# On linux (at least OpenSuSE) the following directories are
# not existing (everything is in /usr/include). To avoid warnings
# check existance of these directories before adding them
if(EXISTS ${FLTK_INCLUDE_DIR}/FL/images)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/FL/images)
endif()
if(EXISTS ${FLTK_INCLUDE_DIR}/jpeg)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/jpeg)
endif()
if(EXISTS ${FLTK_INCLUDE_DIR}/zlib)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/zlib)
endif()
if(EXISTS ${FLTK_INCLUDE_DIR}/png)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/png)
endif()
execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --ldflags
OUTPUT_VARIABLE FLTK_LIBRARIES)
string(STRIP ${FLTK_LIBRARIES} FLTK_LIBRARIES)
string(REGEX MATCH "fltk[_ ]jpeg" FLTK_JPEG ${FLTK_LIBRARIES})
string(REGEX MATCH "fltk[_ ]z" FLTK_Z ${FLTK_LIBRARIES})
string(REGEX MATCH "fltk[_ ]png" FLTK_PNG ${FLTK_LIBRARIES})
endif()
endif()
# then try the built-in FindFLTK module
if(NOT HAVE_FLTK)
set(FLTK_SKIP_FORMS TRUE)
set(FLTK_SKIP_FLUID TRUE)
find_package(FLTK)
if(FLTK_FOUND)
add_subdirectory(Fltk)
set_config_option(HAVE_FLTK "Fltk")
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
# find fltk jpeg
find_library(FLTK_JPEG NAMES fltk_jpeg fltkjpeg)
if(FLTK_JPEG)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_JPEG})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/jpeg)
endforeach()
endif()
# find fltk zlib
find_library(FLTK_Z NAMES fltk_z fltkz)
if(FLTK_Z)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_Z})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/zlib)
endforeach()
endif()
# find fltk png
find_library(FLTK_PNG NAMES fltk_png fltkpng)
if(FLTK_PNG)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_PNG})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/png)
endforeach()
endif()
endif()
endif()
# workaround for Fedora/Suse messing up fltk-config (see issue #417)
if(HAVE_FLTK AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
string(REGEX MATCH "X11" FLTK_X11 ${FLTK_LIBRARIES})
if(NOT FLTK_X11)
find_package(X11)
if(X11_FOUND)
list(APPEND EXTERNAL_INCLUDES ${X11_INCLUDE_DIR})
list(APPEND EXTERNAL_LIBRARIES ${X11_LIBRARIES})
endif()
endif()
endif()
endif()
if(APPLE AND HAVE_FLTK AND ENABLE_TOUCHBAR)
STRING(REGEX MATCH "([0-9]+.[0-9]+)" OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
if(OSX_SDK_VERSION)
if(${OSX_SDK_VERSION} VERSION_GREATER 10.11)
set(GMSH_SRC ${GMSH_SRC};Fltk/touchBar.mm)
set_config_option(HAVE_TOUCHBAR "TouchBar")
endif()
endif()
endif()
if(ENABLE_ONELAB)
set_config_option(HAVE_ONELAB "ONELAB")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/onelab)
if(ENABLE_ONELAB_METAMODEL)
add_subdirectory(contrib/onelab)
include_directories(contrib/onelab)
set_config_option(HAVE_ONELAB_METAMODEL "ONELABMetamodel")
endif()
file(COPY ${ONELAB_PY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
if(ENABLE_BUILD_IOS)
find_file(CMAKE_TOOLCHAIN_FILE "ios.cmake")
if(NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Cannot compile Gmsh for iOS without a toolchain")
endif()
add_definitions(-DBUILD_IOS)
endif()
if(HAVE_FLTK OR ENABLE_GRAPHICS)
if(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB)
message(SEND_ERROR "Cannot compile GUI without Mesh, Post, Plugin and ONELAB")
endif()
if(FLTK_JPEG)
set_config_option(HAVE_LIBJPEG "Jpeg[fltk]")
else()
find_package(JPEG)
if(JPEG_FOUND)
set_config_option(HAVE_LIBJPEG "Jpeg")
list(APPEND EXTERNAL_LIBRARIES ${JPEG_LIBRARIES})
list(APPEND EXTERNAL_INCLUDES ${JPEG_INCLUDE_DIR})
endif()
endif()
if(FLTK_Z)
set_config_option(HAVE_LIBZ "Zlib[fltk]")
else()
find_package(ZLIB)
if(ZLIB_FOUND)
set_config_option(HAVE_LIBZ "Zlib")
list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
list(APPEND EXTERNAL_INCLUDES ${ZLIB_INCLUDE_DIR})
endif()
endif()
if(HAVE_LIBZ)
if(FLTK_PNG)
set_config_option(HAVE_LIBPNG "Png[fltk]")
else()
find_package(PNG)
if(PNG_FOUND)
set_config_option(HAVE_LIBPNG "Png")
list(APPEND EXTERNAL_LIBRARIES ${PNG_LIBRARIES})
list(APPEND EXTERNAL_INCLUDES ${PNG_INCLUDE_DIR})
endif()
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/mpeg_encode AND
ENABLE_MPEG_ENCODE)
add_subdirectory(contrib/mpeg_encode)
include_directories(contrib/mpeg_encode/headers)
set_config_option(HAVE_MPEG_ENCODE "Mpeg")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M AND ENABLE_3M)
add_subdirectory(contrib/3M)
include_directories(contrib/3M)
set_config_option(HAVE_3M "3M")
endif()
if(ENABLE_OSMESA)
find_library(OSMESA_LIB OSMesa)
if(OSMESA_LIB)
set_config_option(HAVE_OSMESA "OSMesa")
list(APPEND EXTERNAL_LIBRARIES ${OSMESA_LIB})
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Graphics)
set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL REQUIRED)
if(OPENGL_GLU_FOUND AND OPENGL_FOUND)
add_subdirectory(Graphics)
set_config_option(HAVE_OPENGL "OpenGL")
else()
message(SEND_ERROR "Could not find GLU: disabling OpenGL support")
endif()
endif()
endif()
if(ENABLE_ANN)
find_library(ANN_LIB ANN PATH_SUFFIXES lib)
find_path(ANN_INC "ANN.h" PATH_SUFFIXES src include ANN)
if(ENABLE_SYSTEM_CONTRIB AND ANN_LIB AND ANN_INC)
message(STATUS "Using system version of ANN")
list(APPEND EXTERNAL_LIBRARIES ${ANN_LIB})
list(APPEND EXTERNAL_INCLUDES ${ANN_INC})
set_config_option(HAVE_ANN "Ann[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ANN)
add_subdirectory(contrib/ANN)
include_directories(contrib/ANN/include)
set_config_option(HAVE_ANN "Ann")
endif()
endif()
if(ENABLE_ALGLIB)
find_library(ALGLIB_LIB alglib)
find_path(ALGLIB_INC "stdafx.h" PATH_SUFFIXES libalglib)
if(ENABLE_SYSTEM_CONTRIB AND ALGLIB_LIB AND ALGLIB_INC)
list(APPEND EXTERNAL_LIBRARIES ${ALGLIB_LIB})
list(APPEND EXTERNAL_INCLUDES ${ALGLIB_INC})
set_config_option(HAVE_ALGLIB "ALGLIB[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ALGLIB)
add_subdirectory(contrib/ALGLIB)
include_directories(contrib/ALGLIB)
set_config_option(HAVE_ALGLIB "ALGLIB")
endif()
endif()
if(HAVE_FLTK AND ENABLE_CAIRO)
find_library(CAIRO_LIB cairo)
find_path(CAIRO_INC "cairo/cairo.h" PATH_SUFFIXES include)
if(CAIRO_INC AND CAIRO_LIB)
set_config_option(HAVE_CAIRO "Cairo")
list(APPEND EXTERNAL_LIBRARIES ${CAIRO_LIB})
list(APPEND EXTERNAL_INCLUDES ${CAIRO_INC})
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/DiscreteIntegration AND
ENABLE_DINTEGRATION)
add_subdirectory(contrib/DiscreteIntegration)
include_directories(contrib/DiscreteIntegration)
set_config_option(HAVE_DINTEGRATION "DIntegration")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/HighOrderMeshOptimizer AND
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshOptimizer AND
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshQualityOptimizer AND
ENABLE_OPTHOM AND HAVE_MESH)
add_subdirectory(contrib/HighOrderMeshOptimizer)
include_directories(contrib/HighOrderMeshOptimizer)
add_subdirectory(contrib/MeshOptimizer)
include_directories(contrib/MeshOptimizer)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/contrib/MeshOptimizer)
add_subdirectory(contrib/MeshQualityOptimizer)
include_directories(contrib/MeshQualityOptimizer)
set_config_option(HAVE_OPTHOM "OptHom")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/domhex AND
ENABLE_DOMHEX AND HAVE_MESH)
add_subdirectory(contrib/domhex)
include_directories(contrib/domhex)
set_config_option(HAVE_DOMHEX "DomHex")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/QuadTri AND
ENABLE_QUADTRI AND HAVE_MESH)
add_subdirectory(contrib/QuadTri)
include_directories(contrib/QuadTri)
set_config_option(HAVE_QUADTRI "QuadTri")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/kbipack AND ENABLE_KBIPACK)
set_config_option(HAVE_KBIPACK "Kbipack")
add_subdirectory(contrib/kbipack)
include_directories(contrib/kbipack)
if(ENABLE_GMP)
find_library(GMP_LIB gmp)
find_path(GMP_INC "gmp.h" PATH_SUFFIXES src include)
endif()
if(GMP_LIB AND GMP_INC)
set_config_option(HAVE_GMP "GMP")
list(APPEND EXTERNAL_LIBRARIES ${GMP_LIB})
list(APPEND EXTERNAL_INCLUDES ${GMP_INC})
else()
message(STATUS "GMP not found: Kbipack uses long int")
endif()
endif()
if(ENABLE_MATHEX)
find_library(MATHEX_LIB mathex PATH_SUFFIXES lib)
find_path(MATHEX_INC "mathex.h" PATH_SUFFIXES src include)
if(ENABLE_SYSTEM_CONTRIB AND MATHEX_LIB AND MATHEX_INC)
list(APPEND EXTERNAL_LIBRARIES ${MATHEX_LIB})
list(APPEND EXTERNAL_INCLUDES ${MATHEX_INC})
set_config_option(HAVE_MATHEX "MathEx[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MathEx)
add_subdirectory(contrib/MathEx)
include_directories(contrib/MathEx)
set_config_option(HAVE_MATHEX "MathEx")
endif()
endif()
if(ENABLE_MPI)
find_package(MPI)
if(MPI_FOUND)
set_config_option(HAVE_MPI "MPI")
list(APPEND EXTERNAL_INCLUDES ${MPI_CXX_INCLUDE_PATH})
list(APPEND EXTERNAL_LIBRARIES ${MPI_CXX_LIBRARIES})
set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_Fortran_COMPILER ${MPI_Fortran_COMPILER})
endif()
endif()
if(ENABLE_POPPLER)
find_library(POPPLER_LIB poppler)
find_library(POPPLER_CPP_LIB poppler-cpp)
find_path(POPPLER_INC "poppler/cpp/poppler-document.h" PATH_SUFFIXES src include)
if(POPPLER_LIB AND POPPLER_INC)
set_config_option(HAVE_POPPLER "Poppler")
list(APPEND EXTERNAL_LIBRARIES ${POPPLER_LIB})
list(APPEND EXTERNAL_LIBRARIES ${POPPLER_CPP_LIB})
list(APPEND EXTERNAL_INCLUDES ${POPPLER_INC})
endif()
endif()
if(ENABLE_P4EST)
find_library(P4EST_LIB p4est)
find_path(P4EST_INC "p4est.h" PATH_SUFFIXES src)
find_library(SC_LIB sc)
if(P4EST_LIB AND P4EST_INC AND SC_LIB)
set_config_option(HAVE_P4EST "P4est")
list(APPEND EXTERNAL_LIBRARIES ${P4EST_LIB} ${SC_LIB})
list(APPEND EXTERNAL_INCLUDES ${P4EST_INC})
endif()
endif()
if(HAVE_MESH OR HAVE_SOLVER)
if(ENABLE_METIS)
find_library(METIS_LIB metis PATH_SUFFIXES lib)
find_path(METIS_INC "metis.h" PATH_SUFFIXES include)
if(ENABLE_SYSTEM_CONTRIB AND METIS_LIB AND METIS_INC)
message(STATUS "Using system version of METIS")
list(APPEND EXTERNAL_LIBRARIES ${METIS_LIB})
list(APPEND EXTERNAL_INCLUDES ${METIS_INC})
set_config_option(HAVE_METIS "Metis[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/metis)
add_definitions(-DUSE_GKREGEX)
add_subdirectory(contrib/metis)
include_directories(contrib/metis/include contrib/metis/libmetis
contrib/metis/GKlib)
set_config_option(HAVE_METIS "Metis")
endif()
endif()
endif()
if(HAVE_MESH)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh/tetgenBR.cxx)
set_config_option(HAVE_TETGENBR "TetGen/BR")
endif()
if(ENABLE_VOROPP)
find_library(VOROPP_LIB voro++)
find_path(VOROPP_INC "voro++.hh" PATH_SUFFIXES voro++)
if(ENABLE_SYSTEM_CONTRIB AND VOROPP_LIB AND VOROPP_INC)
message(STATUS "Using system version of voro++")
list(APPEND EXTERNAL_LIBRARIES ${VOROPP_LIB})
list(APPEND EXTERNAL_INCLUDES ${VOROPP_INC})
set_config_option(HAVE_VOROPP "Voro++[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/voro++)
add_subdirectory(contrib/voro++)
include_directories(contrib/voro++/src)
set_config_option(HAVE_VOROPP "Voro++")
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/blossom AND ENABLE_BLOSSOM)
add_subdirectory(contrib/blossom)
include_directories(contrib/blossom/MATCH contrib/blossom/concorde97
contrib/blossom/concorde97/INCLUDE)
set_config_option(HAVE_BLOSSOM "Blossom")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Netgen AND ENABLE_NETGEN)
add_subdirectory(contrib/Netgen)
include_directories(contrib/Netgen contrib/Netgen/libsrc/include
contrib/Netgen/nglib)
set_config_option(HAVE_NETGEN "Netgen")
add_definitions(-DNO_PARALLEL_THREADS -DNOTCL)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/bamg AND ENABLE_BAMG)
add_subdirectory(contrib/bamg)
include_directories(contrib/bamg contrib/bamg/bamglib)
set_config_option(HAVE_BAMG "Bamg")
endif()
if(ENABLE_MMG3D)
find_library(MMG3D_LIB mmg3d PATH_SUFFIXES lib)
find_path(MMG3D_INC "libmmg3d.h" PATH_SUFFIXES src include)
if(ENABLE_SYSTEM_CONTRIB AND MMG3D_LIB AND MMG3D_INC)
list(APPEND EXTERNAL_LIBRARIES ${MMG3D_LIB})
list(APPEND EXTERNAL_INCLUDES ${MMG3D_INC})
set_config_option(HAVE_MMG3D "Mmg3d[system]")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/mmg3d)
add_subdirectory(contrib/mmg3d)
include_directories(contrib/mmg3d/build/sources)
set_config_option(HAVE_MMG3D "Mmg3d")
endif()
endif()
endif()
if(ENABLE_MED OR ENABLE_CGNS)
find_package(HDF5)
if(HDF5_FOUND)
set(HDF5_LIB "${HDF5_C_LIBRARIES}")
list(APPEND EXTERNAL_INCLUDES ${HDF5_INCLUDE_DIRS})
if(ENABLE_MED)
find_library(MED_LIB medC)
if(MED_LIB)
set_config_option(HAVE_MED "Med")
list(APPEND EXTERNAL_LIBRARIES ${MED_LIB})
endif()
endif()
if(ENABLE_CGNS)
find_library(CGNS_LIB cgns HINTS ENV CGNS_ROOT PATH_SUFFIXES lib)
find_path(CGNS_INC "cgnslib.h" HINTS ENV CGNS_ROOT PATH_SUFFIXES include)
if(CGNS_LIB AND CGNS_INC)
set_config_option(HAVE_LIBCGNS "Cgns")
list(APPEND EXTERNAL_LIBRARIES ${CGNS_LIB})
list(APPEND EXTERNAL_INCLUDES ${CGNS_INC})
if(ENABLE_CGNS_CPEX0045)
set_config_option(HAVE_LIBCGNS_CPEX0045 "Cgns_CPEX0045")
endif()
endif()