-
Notifications
You must be signed in to change notification settings - Fork 63
/
FindDiscregrid.cmake
executable file
·89 lines (79 loc) · 2.66 KB
/
FindDiscregrid.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
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
# - Try to find Discregrid library
#
# The find script can be invoked by using the following command:
# find_package(Discregrid)
#
# Once done this will define
#
# DISCREGRID_FOUND - System has found the discregrid library
# DISCREGRID_INCLUDE_DIRS - Path to the discregrid include directory
# DISCREGRID_LIBRARIES - Path to the static discregrid library
# ============================================================================
# _DISCREGRID_FIND_INCLUDE_DIR
# Internal function to find the include directories
# _var = variable to set
# _hdr = header file to look for
# ============================================================================
function(_DISCREGRID_FIND_INCLUDE_DIR _var _hdr)
find_path(${_var} ${_hdr}
PATHS
$ENV{DISCREGRID_ROOT}
${DISCREGRID_ROOT}
PATH_SUFFIXES
/include
)
if (${_var})
set(DISCREGRID_INCLUDE_DIRS ${DISCREGRID_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE)
if (NOT DISCREGRID_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
endif()
endfunction(_DISCREGRID_FIND_INCLUDE_DIR)
# ============================================================================
# _DISCREGRID_FIND_LIBRARY
# Internal function to find libraries packaged with DISCREGRID
# _var = library variable to create
# ============================================================================
function(_DISCREGRID_FIND_LIBRARY _var _lib _mode)
find_library(${_var}
NAMES ${_lib}
PATHS
$ENV{DISCREGRID_ROOT}
${DISCREGRID_ROOT}
PATH_SUFFIXES
/lib
)
if(${_var})
set(DISCREGRID_LIBRARIES ${DISCREGRID_LIBRARIES} ${_mode} ${${_var}} PARENT_SCOPE)
if(NOT DISCREGRID_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
endif()
endfunction(_DISCREGRID_FIND_LIBRARY)
# ============================================================================
#
# main()
#
# ============================================================================
#
# Find all libraries and include directories.
#
_DISCREGRID_FIND_INCLUDE_DIR(DISCREGRID_DISCREGRIDH_INCLUDE_DIR Discregrid/All)
_DISCREGRID_FIND_LIBRARY(DISCREGRID_LIBRARY_RELEASE "discregrid" optimized)
_DISCREGRID_FIND_LIBRARY(DISCREGRID_LIBRARY_DEBUG "discregrid_d" debug)
#
# Try to enforce components.
#
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DISCREGRID DEFAULT_MSG
DISCREGRID_DISCREGRIDH_INCLUDE_DIR
DISCREGRID_LIBRARY_DEBUG
DISCREGRID_LIBRARY_RELEASE
)
if(NOT DISCREGRID_FOUND)
set(DISCREGRID_INCLUDE_DIRS)
set(DISCREGRID_LIBRARIES)
endif()
if(DISCREGRID_INCLUDE_DIRS)
list(REMOVE_DUPLICATES DISCREGRID_INCLUDE_DIRS)
endif()