-
Notifications
You must be signed in to change notification settings - Fork 2
/
FindBackwardCpp.cmake
65 lines (57 loc) · 2.4 KB
/
FindBackwardCpp.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
################################################################################
#
# \file FindBackwardCpp.cmake
# \copyright 2012-2015 J. Bakosi,
# 2016-2018 Los Alamos National Security, LLC.,
# 2019-2021 Triad National Security, LLC.
# All rights reserved. See the LICENSE file for details.
# \brief Find the Backward-cpp header-only library
# \note BackwardCPP requires other libraries, and for a static build,
# those libraries also require other libraries, e.g., elf, ebl, bz2, and lzma.
#
################################################################################
# Find Backward-cpp library headers
#
# BACKWARDCPP_FOUND - True if Backward-cpp is found
# BACKWARD_INCLUDE_DIRS - Backward-cpp include paths
# BACKWARD_LIBRARIES - Backward-cpp libraries to link
#
# Set BACKWARDCPP_ROOT before calling find_package to a path to add an
# additional search path, e.g.,
#
# Usage:
#
# set(BACKWARDCPP_ROOT "/path/to/custom/backward-cpp") # prefer over system
# find_package(Backward)
# if(BackwardCpp_FOUND)
# include_directories( ${BACKWARD_INCLUDE_DIRS} )
# target_link_libraries( <executable> ${BACKWARD_LIBRARIES} )
# endif()
# If already in cache, be silent
if (BACKWARD_INCLUDE_DIRS AND BACKWARD_LIBRARIES)
set (BACKWARDCPP_FIND_QUIETLY TRUE)
endif()
# Look for the header file
FIND_PATH(BACKWARDCPP_INCLUDE_DIR
NAMES backward.hpp
PATH_SUFFIXES include
HINTS ${BACKWARDCPP_ROOT} $ENV{BACKWARDCPP_ROOT})
# Look for the cmake configuration file
FIND_PATH(BACKWARD_CMAKE_CONFIG_DIR
NAMES BackwardConfig.cmake
PATH_SUFFIXES lib/backward
HINTS ${BACKWARDCPP_ROOT} $ENV{BACKWARDCPP_ROOT})
if(BACKWARDCPP_INCLUDE_DIR AND BACKWARD_CMAKE_CONFIG_DIR)
list(APPEND CMAKE_MODULE_PATH "${BACKWARD_CMAKE_CONFIG_DIR}")
include(BackwardConfig)
message(STATUS "Backward-cpp config: ${BACKWARD_DEFINITIONS}")
if (BACKWARD_LIBRARIES)
message(STATUS "Backward-cpp libraries: ${BACKWARD_LIBRARIES}")
endif()
endif()
set(BACKWARD_INCLUDE_DIRS ${BACKWARDCPP_INCLUDE_DIR})
# Handle the QUIETLY and REQUIRED arguments and set BACKWARDCPP_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(BackwardCpp DEFAULT_MSG BACKWARD_INCLUDE_DIRS BACKWARD_LIBRARIES)
MARK_AS_ADVANCED(BACKWARD_INCLUDE_DIRS BACKWARD_LIBRARIES)