Newer
Older
# Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to the public mailing list <gmsh@geuz.org>.
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(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
endif(DEFINED CMAKE_BUILD_TYPE)
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")

Christophe Geuzaine
committed
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)
opt(ACIS "Enable ACIS geometrical models (experimental)" ${DEFAULT})
opt(ANN "Enable ANN (used for fast point search in mesh/post)" ${DEFAULT})
opt(BAMG "Enable Bamg 2D anisotropic mesh generator" ${DEFAULT})
opt(BFGS "Enable BFGS (used by some mesh optimizers)" ${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 lib)" OFF)
opt(BUILD_ANDROID "Enable Android NDK library target (experimental)" OFF)
opt(BUILD_IOS "Enable iOS (ARM) library target (experimental)" OFF)
opt(CGNS "Enable CGNS mesh export (experimental)" OFF)
opt(CAIRO "Enable Cairo to render fonts (experimental)" ${DEFAULT})
opt(CHACO "Enable Chaco mesh partitioner (alternative to Metis)" ${DEFAULT})

Christophe Geuzaine
committed
opt(COMPRESSED_IO "Enable compressed (gzip) input/output using zlib" OFF)
opt(DINTEGRATION "Enable discrete integration (needed for levelsets)" ${DEFAULT})
opt(FLTK "Enable FLTK graphical user interface (requires mesh/post)" ${DEFAULT})
opt(FOURIER_MODEL "Enable Fourier geometrical models (experimental)" OFF)
opt(GMM "Enable GMM linear solvers (simple alternative to PETSc)" ${DEFAULT})
opt(GRAPHICS "Enable building graphics lib even without GUI (advanced)" OFF)
opt(KBIPACK "Enable Kbipack (neeeded by homology solver)" ${DEFAULT})
opt(MATHEX "Enable math expression parser (used by plugins and options)" ${DEFAULT})
opt(MED "Enable MED mesh and post file formats" ${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 (mostly for parser and solver - mesh generation is sequential)" OFF)
opt(MSVC_STATIC_RUNTIME "Enable static Visual C++ runtime" OFF)
opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF)
opt(NATIVE_FILE_CHOOSER "Enable native file chooser in GUI" ${DEFAULT})
opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT})
Jonathan Lambrechts
committed
opt(NUMPY "Enable conversion between fullMatrix and numpy array (requires SWIG)" OFF)
opt(PETSC4PY "Enable petsc4py wrappers for petsc matrices" ON)
opt(OCC "Enable Open CASCADE geometrical models" ${DEFAULT})
opt(ONELAB2 "Enable experimental ONELAB-Cloud solver interface" OFF)
if(ENABLE_ONELAB2)
opt(UDT "Enable UDT library for ONELAB-Cloud" ON)
endif(ENABLE_ONELAB2)
opt(ONELAB_METAMODEL "Enable ONELAB metamodels (experimental)" ${DEFAULT})
opt(OPENMP "Enable OpenMP (experimental)" OFF)
opt(OPTHOM "Enable high-order mesh optimization tools" ${DEFAULT})
opt(OS_SPECIFIC_INSTALL "Enable OS-specific (e.g. app bundle) installation" ${DEFAULT})
opt(OSMESA "Enable OSMesa for offscreen rendering (experimental)" OFF)
opt(PARSER "Enable GEO file parser (required for .geo/.pos files)" ${DEFAULT})
opt(PETSC "Enable PETSc linear solvers (required for SLEPc)" ${DEFAULT})
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(QT "Enable dummy QT graphical interface proof-of-concept (experimental)" OFF)
opt(SALOME "Enable Salome routines for CAD healing" ${DEFAULT})
opt(SGEOM "Enable SGEOM interface to OCC (experimental)" OFF)
opt(SLEPC "Enable SLEPc eigensolvers (required for conformal compounds)" ${DEFAULT})
opt(SOLVER "Enable built-in finite element solvers (required for compounds)" ${DEFAULT})
opt(TAUCS "Enable Taucs linear solver (alternative to PETSc)" ${DEFAULT})
Jonathan Lambrechts
committed
opt(TCMALLOC "Enable libtcmalloc, a fast malloc implementation but that does not release memory" OFF)
opt(TETGEN "Enable Tetgen 3D initial mesh generator" ${DEFAULT})
opt(TETGEN_OLD "Enable older version of Tetgen" OFF)
opt(VORO3D "Enable Voro3D (for hex meshing, experimental)" ${DEFAULT})
opt(WRAP_JAVA "Enable generation of Java wrappers (experimental)" OFF)
set(GMSH_MAJOR_VERSION 2)
set(GMSH_EXTRA_VERSION "" CACHE STRING "Gmsh extra version string")
set(GMSH_VERSION "${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}")
set(GMSH_VERSION "${GMSH_VERSION}.${GMSH_PATCH_VERSION}${GMSH_EXTRA_VERSION}")
set(GMSH_SHORT_LICENSE "GNU General Public License")
${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h
Common/Gmsh.h Common/Context.h Common/GmshDefines.h Common/GmshMessage.h
Common/VertexArray.h Common/Octree.h Common/OctreeInternals.h
Common/OS.h Common/StringUtils.h Common/OpenFile.h
Common/onelab.h Common/GmshSocket.h Common/onelabUtils.h
Numeric/Numeric.h Numeric/GaussIntegration.h Numeric/polynomialBasis.h
Numeric/JacobianBasis.h Numeric/MetricBasis.h Numeric/bezierBasis.h Numeric/fullMatrix.h
Gauthier Becker
committed
Numeric/simpleFunction.h Numeric/cartesian.h Numeric/ElementType.h
Geo/GModel.h Geo/GEntity.h Geo/GPoint.h Geo/GVertex.h Geo/GEdge.h
Geo/GFace.h Geo/GRegion.h Geo/GEdgeLoop.h Geo/GEdgeCompound.h
Geo/GFaceCompound.h Geo/GRegionCompound.h Geo/GRbf.h Geo/MVertex.h
Geo/MVertexBoundaryLayerData.h Geo/MEdge.h

Christophe Geuzaine
committed
Geo/MFace.h Geo/MElement.h Geo/MElementOctree.h Geo/MPoint.h Geo/MLine.h
Geo/MTriangle.h Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h
Geo/MPrism.h Geo/MPyramid.h Geo/MElementCut.h Geo/MElementOctree.h
Geo/discreteVertex.h Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h
Geo/SPoint2.h Geo/SPoint3.h Geo/SVector3.h Geo/STensor3.h Geo/SBoundingBox3d.h
Geo/Pair.h Geo/Range.h Geo/SOrientedBoundingBox.h
Geo/CellComplex.h Geo/ChainComplex.h Geo/Cell.h Geo/Homology.h Geo/Chain.h
Paul-Emile Bernard
committed
Geo/GenericVertex.h Geo/GenericEdge.h Geo/GenericFace.h Geo/GenericRegion.h
Geo/partitionEdge.h Geo/CGNSOptions.h Geo/gmshLevelset.h Geo/boundaryLayersData.h

Christophe Geuzaine
committed
Mesh/meshGEdge.h Mesh/meshGFace.h Mesh/meshGFaceOptimize.h
Mesh/meshGFaceElliptic.h Mesh/meshPartition.h Mesh/meshGFaceDelaunayInsertion.h
Mesh/simple3D.h Mesh/meshPartitionOptions.h Mesh/directions3D.h Mesh/yamakawa.h
Mesh/Voronoi3D.h Mesh/Levy3D.h Mesh/periodical.h Mesh/meshMetric.h
Solver/dofManager.h Solver/femTerm.h Solver/laplaceTerm.h Solver/elasticityTerm.h
Solver/crossConfTerm.h Solver/orthogonalTerm.h
Solver/linearSystem.h Solver/linearSystemGMM.h Solver/linearSystemCSR.h
Solver/linearSystemFull.h Solver/elasticitySolver.h Solver/sparsityPattern.h
Solver/groupOfElements.h Solver/linearSystemPETSc.h Solver/linearSystemMUMPS.h
Post/PView.h Post/PViewData.h Plugin/PluginManager.h Post/OctreePost.h
Post/PViewDataList.h Post/PViewDataGModel.h Post/PViewOptions.h Post/ColorTable.h
Gauthier Becker
committed
Numeric/nodalBasis.h
Graphics/drawContext.h
contrib/kbipack/gmp_normal_form.h contrib/kbipack/gmp_matrix.h
contrib/kbipack/gmp_blas.h contrib/kbipack/mpz.h
contrib/HighOrderMeshOptimizer/OptHOM.h contrib/HighOrderMeshOptimizer/OptHomMesh.h
contrib/HighOrderMeshOptimizer/OptHomRun.h contrib/HighOrderMeshOptimizer/ParamCoord.h
contrib/HighOrderMeshOptimizer/OptHomFastCurving.h contrib/HighOrderMeshOptimizer/SuperEl.h
contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.h
contrib/HighOrderMeshOptimizer/CADDistances.h
contrib/HighOrderMeshOptimizer/OptHomObjContribScaledJac.h
contrib/HighOrderMeshOptimizer/OptHomObjContribMetricMin.h
contrib/HighOrderMeshOptimizer/OptHomObjContribCADDist.h
contrib/MeshOptimizer/MeshOptPatch.h contrib/MeshOptimizer/MeshOpt.h
contrib/MeshOptimizer/MeshOptCommon.h contrib/MeshOptimizer/MeshOptimizer.h
contrib/MeshOptimizer/MeshOptObjContribFunc.h contrib/MeshOptimizer/MeshOptObjContrib.h
Thomas Toulorge
committed
contrib/MeshOptimizer/MeshOptObjContribScaledNodeDispSq.h
contrib/MeshOptimizer/MeshOptObjectiveFunction.h contrib/MeshOptimizer/MeshOptVertexCoord.h
Thomas Toulorge
committed
contrib/MeshQualityOptimizer/MeshQualityObjContribIdealJac.h
contrib/MeshQualityOptimizer/MeshQualityObjContribInvCond.h
contrib/MeshQualityOptimizer/MeshQualityOptimizer.h
contrib/MathEx/mathex.h)
get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY)
if(IAMCHILD)
set(GMSH_API ${GMSH_API} PARENT_SCOPE)
endif(IAMCHILD)
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
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hostname OUTPUT_VARIABLE HOSTNAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND whoami OUTPUT_VARIABLE PACKAGER
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT DATE)
set(DATE "unknown")
endif(NOT DATE)
set(GMSH_DATE "${DATE}")
if(NOT HOSTNAME)
set(HOSTNAME "unknown")
endif(NOT HOSTNAME)
set(GMSH_HOST "${HOSTNAME}")
if(NOT PACKAGER)
set(PACKAGER "unknown")
endif(NOT PACKAGER)
set(GMSH_PACKAGER "${PACKAGER}")
if(APPLE)
set(GMSH_OS "MacOSX")
elseif(CYGWIN)
set(GMSH_OS "Windows")
else(APPLE)
set(GMSH_OS "${CMAKE_SYSTEM_NAME}")
endif(APPLE)
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800 4244 4267)")
if(ENABLE_MSVC_STATIC_RUNTIME)
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(${VAR} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
endif(${VAR} MATCHES "/MD")
endforeach(VAR)
endif(ENABLE_MSVC_STATIC_RUNTIME)
endif(MSVC)
if(ENABLE_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)
endif(ENABLE_OPENMP)
macro(append_gmsh_src DIRNAME FILES)
foreach(FILE ${FILES})
list(APPEND LIST ${DIRNAME}/${FILE})
endforeach(FILE)
set(GMSH_SRC ${GMSH_SRC};${LIST} PARENT_SCOPE)
set(GMSH_DIRS ${GMSH_DIRS};${DIRNAME} PARENT_SCOPE)
endmacro(append_gmsh_src)
macro(find_all_libraries VARNAME LISTNAME PATH SUFFIX)
list(LENGTH ${LISTNAME} NUM_LIST)
foreach(LIB ${${LISTNAME}})
find_library(FOUND_LIB ${LIB} PATHS ${PATH} PATH_SUFFIXES ${SUFFIX})
if(FOUND_LIB)
list(APPEND ${VARNAME} ${FOUND_LIB})
endif(FOUND_LIB)
unset(FOUND_LIB CACHE)
endforeach(LIB)
list(LENGTH ${VARNAME} NUM_FOUND_LIBRARIES)
endif(NUM_FOUND_LIBRARIES LESS NUM_LIST)
macro(set_config_option VARNAME STRING)
set(${VARNAME} TRUE)
list(APPEND CONFIG_OPTIONS ${STRING})
message(STATUS "Found " ${STRING})
endmacro(set_config_option)

Christophe Geuzaine
committed
# check if the machine is 64 bits (this is more reliable than using
# CMAKE_SIZEOF_VOID_P, which does not seem to work e.g. on some Suse
# machines)
check_type_size("void*" SIZEOF_VOID_P)
if(SIZEOF_VOID_P EQUAL 8)

Christophe Geuzaine
committed
endif(SIZEOF_VOID_P EQUAL 8)
if(ENABLE_BLAS_LAPACK)
# 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(BLAS_LAPACK_LIBRARIES)
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(HAVE_64BIT_SIZE_T)
set(MKL_PATH ia32/lib)
set(MKL_LIBS_REQUIRED libguide40 mkl_intel_c mkl_intel_thread mkl_core)
endif(HAVE_64BIT_SIZE_T)
find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
set_config_option(HAVE_BLAS "Blas(IntelMKL)")
set_config_option(HAVE_LAPACK "Lapack(IntelMKL)")
else(LAPACK_LIBRARIES)
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(Reference)")
set_config_option(HAVE_LAPACK "Lapack(Reference)")
endif(LAPACK_LIBRARIES)
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(HAVE_64BIT_SIZE_T)
set(MKL_PATH lib/32)
endif(HAVE_64BIT_SIZE_T)
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(NOT LAPACK_LIBRARIES)
set_config_option(HAVE_BLAS "Blas(IntelMKL)")
set_config_option(HAVE_LAPACK "Lapack(IntelMKL)")
# 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 "" "")
set_config_option(HAVE_BLAS "Blas(ATLAS)")
set_config_option(HAVE_LAPACK "Lapack(ATLAS)")
else(LAPACK_LIBRARIES)
# 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(GFORTRAN_LIB)
endif(LAPACK_LIBRARIES)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
# on SunOS we know blas and lapack are available in sunperf
set(LAPACK_FLAGS -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_config_option(HAVE_BLAS "Blas(VecLib)")
set_config_option(HAVE_LAPACK "Lapack(VecLib)")
endif(MSVC)
find_library(BLAS_LIB f2cblas PATH_SUFFIXES lib)
find_library(LAPACK_LIB f2clapack PATH_SUFFIXES lib)
if(BLAS_LIB)
list(APPEND EXTERNAL_LIBRARIES ${BLAS_LIB})
set_config_option(HAVE_BLAS "Blas")
endif(BLAS_LIB)
if(LAPACK_LIB)
list(APPEND EXTERNAL_LIBRARIES ${LAPACK_LIB})
set_config_option(HAVE_LAPACK "Lapack")
# for isnan/isinf
add_definitions(-D_GLIBCXX_USE_C99_MATH=1)
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(GFORTRAN_LIB)
endif(LAPACK_LIBRARIES)
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
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(LAPACK_FOUND)
set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif(LAPACK_FOUND)
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(CMAKE_Fortran_COMPILER MATCHES "gfortran")
endif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
endif(BLAS_FOUND)
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
message(STATUS "Warning: Could not find Blas or Lapack: most meshing algorithms "
"will not be functional")
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
endif(ENABLE_BLAS_LAPACK)
Jonathan Lambrechts
committed
if(ENABLE_TCMALLOC)
find_library(TCMALLOC tcmalloc)
if(TCMALLOC)
set_config_option(HAVE_TCMALLOC "TCMalloc")
list(APPEND EXTERNAL_LIBRARIES ${TCMALLOC})
endif(TCMALLOC)
endif(ENABLE_TCMALLOC)
add_subdirectory(Common)
add_subdirectory(Numeric)
add_subdirectory(Geo)
set_config_option(HAVE_MESH "Mesh")
if(ENABLE_SOLVER)
add_subdirectory(Solver)
set_config_option(HAVE_SOLVER "Solver")
if(ENABLE_POST)
add_subdirectory(Post)
set_config_option(HAVE_POST "Post")
if(ENABLE_PLUGINS)
add_subdirectory(Plugin)
set_config_option(HAVE_PLUGINS "Plugins")
endif(ENABLE_POST)
if(ENABLE_PARSER)
add_subdirectory(Parser)
set_config_option(HAVE_PARSER "Parser")
endif(ENABLE_PARSER)
if(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 GREATER 1.1)
add_subdirectory(Fltk)
set_config_option(HAVE_FLTK "Fltk")

Christophe Geuzaine
committed
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(EXISTS ${FLTK_INCLUDE_DIR}/FL/images)
if(EXISTS ${FLTK_INCLUDE_DIR}/jpeg)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/jpeg)
endif(EXISTS ${FLTK_INCLUDE_DIR}/jpeg)
if(EXISTS ${FLTK_INCLUDE_DIR}/zlib)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/zlib)
endif(EXISTS ${FLTK_INCLUDE_DIR}/zlib)
if(EXISTS ${FLTK_INCLUDE_DIR}/png)
list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/png)
endif(EXISTS ${FLTK_INCLUDE_DIR}/png)
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(FLTK_VERSION GREATER 1.1)
endif(FLTK_CONFIG_SCRIPT)
# 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
if(FLTK_JPEG)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_JPEG})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/jpeg)
endforeach(DIR)
endif(FLTK_JPEG)
# find fltk zlib
if(FLTK_Z)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_Z})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/zlib)
endforeach(DIR)
endif(FLTK_Z)
# find fltk png
if(FLTK_PNG)
list(APPEND EXTERNAL_LIBRARIES ${FLTK_PNG})
foreach(DIR ${FLTK_INCLUDE_DIR})
list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/png)
endforeach(DIR)
endif(FLTK_PNG)
endif(FLTK_FOUND)
elseif(ENABLE_QT)
find_package(Qt4)
set(QT_USE_QTOPENGL TRUE)
include(${QT_USE_FILE})
if(QT_FOUND)
set_config_option(HAVE_QT "Qt")
list(APPEND EXTERNAL_INCLUDES ${QT_INCLUDE_DIR})
endif(QT_FOUND)
endif(ENABLE_FLTK)

Christophe Geuzaine
committed
if(ENABLE_NATIVE_FILE_CHOOSER)
set_config_option(HAVE_NATIVE_FILE_CHOOSER "NativeFileChooser")
endif(ENABLE_NATIVE_FILE_CHOOSER)
if(ENABLE_ONELAB2)
if(ENABLE_UDT)
find_package(Threads REQUIRED)
find_path(UDT_INCLUDE_DIR "udt.h" PATH_SUFFIXES include udt)
find_library(UDT_LIBRARY udt)
if(UDT_INCLUDE_DIR AND UDT_LIBRARY AND Threads_FOUND)
set_config_option(HAVE_UDT "UDT")
list(APPEND EXTERNAL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
list(APPEND EXTERNAL_LIBRARIES ${UDT_LIBRARY})
list(APPEND EXTERNAL_INCLUDES ${UDT_INCLUDE_DIR})
message(FATAL_ERROR "Unable to find UDT library or threads")
endif(ENABLE_UDT)
set_config_option(HAVE_ONELAB2 "ONELAB2")
add_subdirectory(contrib/onelab2)
include_directories(contrib/onelab2)
endif(ENABLE_ONELAB2)

Christophe Geuzaine
committed
if(ENABLE_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(ENABLE_ONELAB_METAMODEL)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/contrib/onelab/python/onelab.py
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/onelab)

Christophe Geuzaine
committed
endif(ENABLE_ONELAB)
find_file(CMAKE_TOOLCHAIN_FILE "ios.cmake")
if(NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Cannot compile Gmsh for iOS without a toolchain")
endif(NOT CMAKE_TOOLCHAIN_FILE)
if(HAVE_FLTK OR HAVE_QT OR ENABLE_GRAPHICS)

Christophe Geuzaine
committed
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")

Christophe Geuzaine
committed
endif(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB)
if(FLTK_JPEG)
set_config_option(HAVE_LIBJPEG "Jpeg(Fltk)")
else(FLTK_JPEG)
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(JPEG_FOUND)
endif(FLTK_JPEG)
if(FLTK_Z)
set_config_option(HAVE_LIBZ "Zlib(Fltk)")
else(FLTK_Z)
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(ZLIB_FOUND)
endif(FLTK_Z)
if(HAVE_LIBZ)
if(FLTK_PNG)
set_config_option(HAVE_LIBPNG "Png(Fltk)")
else(FLTK_PNG)
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(PNG_FOUND)
endif(FLTK_PNG)
endif(HAVE_LIBZ)
if(ENABLE_MPEG_ENCODE)
add_subdirectory(contrib/mpeg_encode)
include_directories(contrib/mpeg_encode/headers)
set_config_option(HAVE_MPEG_ENCODE "Mpeg")
endif(ENABLE_MPEG_ENCODE)
if(ENABLE_3M AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
add_subdirectory(contrib/3M)
include_directories(contrib/3M)
set_config_option(HAVE_3M "3M")
endif(ENABLE_3M AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
if(ENABLE_OSMESA)
find_library(OSMESA_LIB OSMesa)
if(OSMESA_LIB)
set_config_option(HAVE_OSMESA "OSMesa")
list(APPEND EXTERNAL_LIBRARIES ${OSMESA_LIB})
endif(OSMESA_LIB)
endif(ENABLE_OSMESA)
find_package(OpenGL REQUIRED)
if(OPENGL_GLU_FOUND)
add_subdirectory(Graphics)
set_config_option(HAVE_OPENGL "OpenGL")
else(OPENGL_GLU_FOUND)
message(SEND_ERROR "Could not find GLU: disabling OpenGL support")
endif(OPENGL_GLU_FOUND)
endif(HAVE_FLTK OR HAVE_QT OR ENABLE_GRAPHICS)
if(HAVE_MESH OR HAVE_PLUGINS)
if(ENABLE_ANN)
find_library(ANN_LIB ann PATH_SUFFIXES lib)
find_path(ANN_INC "ANN.h" PATH_SUFFIXES src include ANN)
if(ANN_LIB AND ANN_INC)
list(APPEND EXTERNAL_LIBRARIES ${ANN_LIB})
list(APPEND EXTERNAL_INCLUDES ${ANN_INC})
else(ANN_LIB AND ANN_INC)
message(STATUS "System ANN not found: using contrib/ANN instead")
add_subdirectory(contrib/ANN)
include_directories(contrib/ANN/include)
endif(ANN_LIB AND ANN_INC)
set_config_option(HAVE_ANN "Ann")
endif(ENABLE_ANN)
endif(HAVE_MESH OR HAVE_PLUGINS)

Christophe Geuzaine
committed
if(ENABLE_BFGS)
add_subdirectory(contrib/lbfgs)
include_directories(contrib/lbfgs)
set_config_option(HAVE_BFGS "Bfgs")
endif(ENABLE_BFGS)
Jonathan Lambrechts
committed
find_library(CAIRO_LIB cairo)
find_path(CAIRO_INC "cairo/cairo.h" PATH_SUFFIXES include)
if(CAIRO_INC AND CAIRO_LIB)
Jonathan Lambrechts
committed
list(APPEND EXTERNAL_LIBRARIES ${CAIRO_LIB})
list(APPEND EXTERNAL_INCLUDES ${CAIRO_INC})
Jonathan Lambrechts
committed
if(ENABLE_DINTEGRATION)
add_subdirectory(contrib/DiscreteIntegration)
include_directories(contrib/DiscreteIntegration)
set_config_option(HAVE_DINTEGRATION "DIntegration")
endif(ENABLE_DINTEGRATION)
if(ENABLE_OPTHOM)
add_subdirectory(contrib/HighOrderMeshOptimizer)
include_directories(contrib/HighOrderMeshOptimizer)
add_subdirectory(contrib/MeshOptimizer)
include_directories(contrib/MeshOptimizer)
add_subdirectory(contrib/MeshQualityOptimizer)
include_directories(contrib/MeshQualityOptimizer)
set_config_option(HAVE_OPTHOM "OptHom")
endif(ENABLE_OPTHOM)
if(ENABLE_KBIPACK)
set_config_option(HAVE_KBIPACK "Kbipack")
add_subdirectory(contrib/kbipack)
include_directories(contrib/kbipack)
find_path(GMP_INC "gmp.h" PATH_SUFFIXES src include)
if(GMP_LIB AND GMP_INC)
set_config_option(HAVE_GMP "GMP")
list(APPEND EXTERNAL_LIBRARIES ${GMP_LIB})
list(APPEND EXTERNAL_INCLUDES ${GMP_INC})
Matti Pellika
committed
else(GMP_LIB AND GMP_INC)
endif(ENABLE_KBIPACK)
include_directories(contrib/MathEx)
set_config_option(HAVE_MATHEX "MathEx")
find_package(MPI)
if(MPI_FOUND)
set_config_option(HAVE_MPI "MPI")
list(APPEND EXTERNAL_INCLUDES ${MPI_INCLUDE_DIR})
list(APPEND EXTERNAL_LIBRARIES ${MPI_LIBRARIES})
include(CMakeForceCompiler)
# Warning: this actually requires cmake >= 2.8.5
cmake_force_c_compiler(${MPI_C_COMPILER} "MPI C Compiler")
cmake_force_cxx_compiler(${MPI_CXX_COMPILER} "MPI C++ Compiler")
endif(MPI_FOUND)
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(POPPLER_LIB AND POPPLER_INC)
if(HAVE_MESH OR HAVE_SOLVER)
if(ENABLE_METIS)
# Gmsh currently uses Metis 4 - we should switch to Metis 5 and use the
# system lib if available
add_subdirectory(contrib/Metis)
include_directories(contrib/Metis)
set_config_option(HAVE_METIS "Metis")
message(STATUS "Note: By including Metis you have to comply with Metis' "

Christophe Geuzaine
committed
"special licensing requirements stated in contrib/Metis/README.txt.")
endif(ENABLE_METIS)
if(ENABLE_CHACO)
add_subdirectory(contrib/Chaco)
include_directories(contrib/Chaco/main)
set_config_option(HAVE_CHACO "Chaco")
endif(ENABLE_CHACO)
endif(HAVE_MESH OR HAVE_SOLVER)
if(ENABLE_VORO3D)
add_subdirectory(contrib/voro++)
include_directories(contrib/voro++/src)
set_config_option(HAVE_VORO3D "Voro3D")
endif(ENABLE_VORO3D)
if(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(ENABLE_BLOSSOM)
if(ENABLE_NETGEN)
add_subdirectory(contrib/Netgen)
include_directories(contrib/Netgen contrib/Netgen/libsrc/include
add_definitions(-DNO_PARALLEL_THREADS -DNOTCL)
endif(ENABLE_NETGEN)
if(ENABLE_BAMG)
add_subdirectory(contrib/bamg)
include_directories(contrib/bamg contrib/bamg/bamglib)
set_config_option(HAVE_BAMG "Bamg")
endif(ENABLE_BAMG)

Jean-François Remacle
committed
if(ENABLE_MMG3D)

Christophe Geuzaine
committed
find_library(MMG3D_LIB mmg3dlib4.0 PATH_SUFFIXES lib)
find_path(MMG3D_INC "libmmg3d.h" PATH_SUFFIXES src include)
if(MMG3D_LIB AND MMG3D_INC)
list(APPEND EXTERNAL_LIBRARIES ${MMG3D_LIB})
list(APPEND EXTERNAL_INCLUDES ${MMG3D_INC})
else(MMG3D_LIB AND MMG3D_INC)
message(STATUS "System MMG3D not found: using contrib/mmg3d instead")

Christophe Geuzaine
committed
add_subdirectory(contrib/mmg3d)
include_directories(contrib/mmg3d/build/sources)
endif(MMG3D_LIB AND MMG3D_INC)

Jean-François Remacle
committed
set_config_option(HAVE_MMG3D "Mmg3d")
endif(ENABLE_MMG3D)
if(ENABLE_TETGEN AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Tetgen1.5/tetgen.h)
add_subdirectory(contrib/Tetgen1.5)
include_directories(contrib/Tetgen1.5)
set_config_option(HAVE_TETGEN "Tetgen(1.5)")
elseif(ENABLE_TETGEN_OLD AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Tetgen1.4/tetgen.h)
add_subdirectory(contrib/Tetgen1.4)
include_directories(contrib/Tetgen1.4)
set_config_option(HAVE_TETGEN "Tetgen(1.4)")

Christophe Geuzaine
committed
elseif(ENABLE_TETGEN)
find_library(TETGEN_LIB tet PATH_SUFFIXES lib)
find_path(TETGEN_INC "tetgen.h" PATH_SUFFIXES src include tetgen)
if(TETGEN_LIB AND TETGEN_INC)
list(APPEND EXTERNAL_LIBRARIES ${TETGEN_LIB})
list(APPEND EXTERNAL_INCLUDES ${TETGEN_INC})
set_config_option(HAVE_TETGEN "Tetgen")
endif(TETGEN_LIB AND TETGEN_INC)
endif(ENABLE_TETGEN AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Tetgen1.5/tetgen.h)

Christophe Geuzaine
committed
if(HAVE_TETGEN)
message(STATUS "Note: By including Tetgen you have to comply with Tetgen's "
"special licensing requirements stated in contrib/Tetgen*/LICENSE.")

Christophe Geuzaine
committed
endif(HAVE_TETGEN)
if(ENABLE_FOURIER_MODEL)
set(FM_REQUIRED FourierModel fftw3 gsl gslcblas)
find_all_libraries(FM_LIBS FM_REQUIRED "" lib)
if(FM_LIBS)
set_config_option(HAVE_FOURIER_MODEL "FourierModel")
list(APPEND EXTERNAL_LIBRARIES ${FM_LIBS})
endif(FM_LIBS)
endif(ENABLE_FOURIER_MODEL)
if(ENABLE_MED OR ENABLE_CGNS)
find_library(HDF5_LIB hdf5)
if(HDF5_LIB)
if(ENABLE_MED)
find_library(MED_LIB med)
if(MED_LIB)
set_config_option(HAVE_MED "Med")
list(APPEND EXTERNAL_LIBRARIES ${MED_LIB})
endif(MED_LIB)
endif(ENABLE_MED)
if(ENABLE_CGNS)
find_library(CGNS_LIB cgns PATHS ENV CGNS_ROOT PATH_SUFFIXES lib)
find_path(CGNS_INC "cgnslib.h" PATHS ENV CGNS_ROOT PATH_SUFFIXES include)
set_config_option(HAVE_LIBCGNS "Cgns")
list(APPEND EXTERNAL_LIBRARIES ${CGNS_LIB})
list(APPEND EXTERNAL_INCLUDES ${CGNS_INC})
endif(ENABLE_CGNS)
if(MED_LIB OR CGNS_LIB)
list(APPEND EXTERNAL_LIBRARIES ${HDF5_LIB})
if(SZ_LIB)
list(APPEND EXTERNAL_LIBRARIES ${SZ_LIB})
endif(SZ_LIB)
if(NOT HAVE_LIBZ) # necessary for non-GUI builds
find_package(ZLIB)
if(ZLIB_FOUND)
set_config_option(HAVE_LIBZ "Zlib")
list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
endif(ZLIB_FOUND)
endif(NOT HAVE_LIBZ)
endif(MED_LIB OR CGNS_LIB)
Bastien Gorissen
committed
else(HDF5_LIB)
message(STATUS "HDF5 not found")
endif(HDF5_LIB)
endif(ENABLE_MED OR ENABLE_CGNS)
if(HAVE_SOLVER)
if(ENABLE_GMM)
find_path(GMM_INC "gmm.h" PATH_SUFFIXES src include include/gmm)
if(GMM_INC)
list(APPEND EXTERNAL_INCLUDES ${GMM_INC})
else(GMM_INC)
message(STATUS "System GMM not found: using contrib/gmm instead")
include_directories(contrib/gmm)
endif(GMM_INC)
set_config_option(HAVE_GMM "Gmm")
endif(ENABLE_GMM)
if(ENABLE_TAUCS)
if(HAVE_METIS)
find_library(TAUCS_LIB taucs PATH_SUFFIXES lib)
find_path(TAUCS_INC "taucs.h" PATH_SUFFIXES src include taucs)
set_config_option(HAVE_TAUCS "Taucs")
add_definitions(-DTAUCS_CILK)
list(APPEND EXTERNAL_LIBRARIES ${TAUCS_LIB})
list(APPEND EXTERNAL_INCLUDES ${TAUCS_INC})
endif(TAUCS_LIB AND TAUCS_INC)
else(HAVE_METIS)
message(STATUS "Warning: Disabling Taucs (requires METIS)")
endif(HAVE_METIS)
endif(ENABLE_TAUCS)
set(MUMPS_LIBS_REQUIRED smumps dmumps cmumps zmumps mumps_common pord metis)
if(NOT ENABLE_MPI)
list(APPEND MUMPS_LIBS_REQUIRED mpiseq)
endif(NOT ENABLE_MPI)
find_all_libraries(MUMPS_LIBRARIES MUMPS_LIBS_REQUIRED "" "lib")
find_path(SMUMPS_INC "smumps_c.h" PATH_SUFFIXES src include)
find_path(DMUMPS_INC "dmumps_c.h" PATH_SUFFIXES src include)
find_path(CMUMPS_INC "cmumps_c.h" PATH_SUFFIXES src include)
find_path(ZMUMPS_INC "zmumps_c.h" PATH_SUFFIXES src include)
if(MUMPS_LIBRARIES AND SMUMPS_INC AND DMUMPS_INC AND CMUMPS_INC AND ZMUMPS_INC)
set_config_option(HAVE_MUMPS "MUMPS")
list(APPEND EXTERNAL_LIBRARIES ${MUMPS_LIBRARIES})
list(APPEND EXTERNAL_INCLUDES ${SMUMPS_INC})
list(APPEND EXTERNAL_INCLUDES ${DMUMPS_INC})
list(APPEND EXTERNAL_INCLUDES ${CMUMPS_INC})
list(APPEND EXTERNAL_INCLUDES ${ZMUMPS_INC})
find_library(GFORTRAN_LIB gfortran)
if(GFORTRAN_LIB)
list(APPEND EXTERNAL_LIBRARIES ${GFORTRAN_LIB})
endif(GFORTRAN_LIB)
if(ENABLE_GMM) # use GMM/MUMPS interface
add_definitions(-DGMM_USES_MUMPS)
endif(ENABLE_GMM)
endif(MUMPS_LIBRARIES AND SMUMPS_INC AND DMUMPS_INC AND CMUMPS_INC AND ZMUMPS_INC)
if(PETSC_DIR)
set(ENV_PETSC_DIR ${PETSC_DIR})
else(PETSC_DIR)
set(ENV_PETSC_DIR $ENV{PETSC_DIR})
endif(PETSC_DIR)
if(PETSC_ARCH)
set(ENV_PETSC_ARCH ${PETSC_ARCH})
else(PETSC_ARCH)
set(ENV_PETSC_ARCH $ENV{PETSC_ARCH})
endif(PETSC_ARCH)
if(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables)
# old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
# find includes by parsing the petscvariables file
file(STRINGS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables
PETSC_VARIABLES NEWLINE_CONSUME)
endif(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables)
if(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables)
# old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
# find includes by parsing the petscvariables file
file(STRINGS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables
PETSC_VARIABLES NEWLINE_CONSUME)
endif(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables)
if(PETSC_VARIABLES)
# try to find PETSC_CC_INCLUDES for PETSc >= 3.4
string(REGEX MATCH "PETSC_CC_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
string(REPLACE "PETSC_CC_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
${PETSC_PACKAGES_INCLUDES})
else(PETSC_PACKAGES_INCLUDES)
# try to find PETSC_PACKAGES_INCLUDES in older versions
list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/include)
list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/include)
string(REGEX MATCH "PACKAGES_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
${PETSC_VARIABLES})
string(REPLACE "PACKAGES_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
${PETSC_PACKAGES_INCLUDES})
endif(PETSC_PACKAGES_INCLUDES)
if(PETSC_PACKAGES_INCLUDES)
if(PETSC_PACKAGES_INCLUDES)
string(REPLACE "-I" "" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
string(REPLACE " " ";" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
foreach(VAR ${PETSC_PACKAGES_INCLUDES})
# seem to include unexisting directories (/usr/include/lib64)
# check to avoid warnings
if(EXISTS ${VAR})
list(APPEND EXTERNAL_INCLUDES ${VAR})
endif(EXISTS ${VAR})
endforeach(VAR)
endif(PETSC_PACKAGES_INCLUDES)
# find libraries (<= 3.0)
set(PETSC_LIBS_REQUIRED petscksp petscdm petscmat petscvec petsc)
find_all_libraries(PETSC_LIBS PETSC_LIBS_REQUIRED
${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib "")
# petsc 3.1 creates only one library (libpetsc)
if(NOT PETSC_LIBS)
find_library(PETSC_LIBS petsc PATHS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib)
endif(NOT PETSC_LIBS)
if(PETSC_LIBS)
set_config_option(HAVE_PETSC "PETSc")
if(NOT HAVE_BLAS)
set_config_option(HAVE_BLAS "Blas(PETSc)")
endif(NOT HAVE_BLAS)
if(NOT HAVE_LAPACK)
set_config_option(HAVE_LAPACK "Lapack(PETSc)")
endif(NOT HAVE_LAPACK)
# find slepc (needs to be linked in before petsc)

Christophe Geuzaine
committed
if(ENABLE_SLEPC)