forked from Kitware/ParaView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindGmsh.cmake
61 lines (56 loc) · 1.87 KB
/
FindGmsh.cmake
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
# - Find Gmsh library
# Find the Gmsh includes and library
# This module defines
# Gmsh_INCLUDE_DIRS: where to find GmshGlobal.h
# Gmsh_LIBRARIES: the Gmsh library
# Gmsh_FOUND: if false, do not try to use Gmsh
# Gmsh_VERSION: The found version of Gmsh
# Gmsh::Gmsh: Imported target for the Gmsh library
find_path(Gmsh_INCLUDE_DIR
NAMES
gmsh.h
PATHS
/usr/local/include
/usr/include
DOC "Gmsh include directory")
mark_as_advanced(Gmsh_INCLUDE_DIR)
find_library(Gmsh_LIBRARY
NAMES
gmsh libgmsh
DOC "Gmsh library path")
mark_as_advanced(Gmsh_LIBRARY)
if (Gmsh_INCLUDE_DIR)
if (EXISTS "${Gmsh_INCLUDE_DIR}/gmsh.h")
file(STRINGS "${Gmsh_INCLUDE_DIR}/gmsh.h" _gmsh_version
REGEX "GMSH_")
string(REGEX REPLACE ".*GMSH_API_VERSION_MAJOR *\([0-9]*\).*" "\\1" _gmsh_major "${_gmsh_version}")
string(REGEX REPLACE ".*GMSH_API_VERSION_MINOR *\([0-9]*\).*" "\\1" _gmsh_minor "${_gmsh_version}")
string(REGEX REPLACE ".*GMSH_API_VERSION_PATCH *\([0-9]*\).*" "\\1" _gmsh_patch "${_gmsh_version}")
unset(_gmsh_version)
if (NOT _gmsh_major STREQUAL "" AND
NOT _gmsh_minor STREQUAL "" AND
NOT _gmsh_patch STREQUAL "")
set(Gmsh_VERSION "${_gmsh_major}.${_gmsh_minor}.${_gmsh_patch}")
endif ()
unset(_gmsh_major)
unset(_gmsh_minor)
unset(_gmsh_patch)
else ()
set(Gmsh_VERSION Gmsh_VERSION-NOTFOUND)
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Gmsh
REQUIRED_VARS Gmsh_LIBRARY Gmsh_INCLUDE_DIR
VERSION_VAR Gmsh_VERSION)
if (Gmsh_FOUND)
set(Gmsh_LIBRARIES "${Gmsh_LIBRARY}")
set(Gmsh_INCLUDE_DIRS "${Gmsh_INCLUDE_DIR}")
if (NOT TARGET Gmsh::Gmsh)
add_library(Gmsh::Gmsh UNKNOWN IMPORTED)
set_target_properties(Gmsh::Gmsh
PROPERTIES
IMPORTED_LOCATION "${Gmsh_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Gmsh_INCLUDE_DIR}")
endif ()
endif ()