-
Notifications
You must be signed in to change notification settings - Fork 213
/
FindCXXGSL.cmake
79 lines (73 loc) · 2.03 KB
/
FindCXXGSL.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
# Copyright 2019 Collabora, Ltd.
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0
#
# Original Author:
# 2019 Rylie Pavlik <[email protected]>
#.rst:
# FindCXXGSL
# ---------------
#
# Find the C++ "Guideline Support Library".
#
# See https://github.com/Microsoft/GSL
#
# The Debian package for this is called ``libmsgsl-dev``
#
# Targets
# ^^^^^^^
#
# If successful, the following imported interface target is created.
#
# ``cxxgsl::gsl``
#
# Cache variables
# ^^^^^^^^^^^^^^^
#
# The following cache variables may also be set to assist/control the operation of this module:
#
# ``CXXGSL_ROOT_DIR``
# The root to search for GSL.
#
# The following cache variables are set if a GSL target is not already found:
#
# ``CXXGSL_INCLUDE_DIR``
# The directory to add to your include path to be able to #include <gsl/gsl>
# Set up cache variables
set(CXXGSL_ROOT_DIR
"${CXXGSL_ROOT_DIR}"
CACHE PATH "The root to search for GSL")
if(TARGET GSL)
set(CXXGSL_TARGET GSL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CXXGSL REQUIRED_VARS CXXGSL_TARGET)
if(NOT TARGET cxxgsl::gsl)
add_library(cxxgsl::gsl ALIAS GSL)
endif()
else()
find_path(
CXXGSL_INCLUDE_DIR
NAMES gsl/gsl
PATHS ${CXXGSL_ROOT_DIR}
PATH_SUFFIXES include)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CXXGSL REQUIRED_VARS CXXGSL_INCLUDE_DIR)
###
# If found, set variables and create target
###
if(CXXGSL_FOUND)
set(CXXGSL_INCLUDE_DIRS ${CXXGSL_INCLUDE_DIR})
if(NOT TARGET cxxgsl::gsl)
add_library(cxxgsl::gsl INTERFACE IMPORTED)
endif()
set_target_properties(
cxxgsl::gsl
PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
"${CXXGSL_INCLUDE_DIR}" INTERFACE_COMPILE_FEATURES
cxx_std_14)
endif()
endif()