Debian Codegraph @

Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake

raw
1 # Copyright 2019 Peter Dimov
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
4
5 # This CMake configuration file, installed as part of the Boost build
6 # and installation procedure done by `b2 install`, provides support
7 # for find_package(Boost).
8 #
9 # It's roughly, but not perfectly, compatible with the behavior
10 # of find_package(Boost) as provided by FindBoost.cmake.
11 #
12 # A typical use might be
13 #
14 # find_package(Boost 1.70 REQUIRED COMPONENTS filesystem regex PATHS C:/Boost)
15 #
16 # On success, the above invocation would define the targets Boost::headers,
17 # Boost::filesystem and Boost::regex. Boost::headers represents all
18 # header-only libraries. An alias, Boost::boost, for Boost::headers is
19 # provided for compatibility.
20 #
21 # Since Boost libraries can coexist in many variants - 32/64 bit,
22 # static/dynamic runtime, debug/release, the following variables can be used
23 # to control which variant is chosen:
24 #
25 # Boost_USE_DEBUG_LIBS: When OFF, disables debug libraries.
26 # Boost_USE_RELEASE_LIBS: When OFF, disables release libraries.
27 # Boost_USE_STATIC_LIBS: When ON, uses static Boost libraries; when OFF,
28 # uses shared Boost libraries; when not set, the
29 # default is to use shared when BUILD_SHARED_LIBS is
30 # ON, static otherwise.
31 # Boost_USE_STATIC_RUNTIME: When ON, uses Boost libraries linked against the
32 # static runtime. The default is shared runtime.
33 # Boost_USE_DEBUG_RUNTIME: When ON, uses Boost libraries linked against the
34 # debug runtime. When OFF, against the release
35 # runtime. The default is to use either.
36 # Boost_COMPILER: The compiler that has been used to build Boost,
37 # such as vc141, gcc7, clang37. The default is
38 # determined from CMAKE_CXX_COMPILER_ID.
39
40 message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}")
41
42 # Output requested configuration (f.ex. "REQUIRED COMPONENTS filesystem")
43
44 if(Boost_FIND_QUIETLY)
45 set(_BOOST_CONFIG "${_BOOST_CONFIG} QUIET")
46 endif()
47
48 if(Boost_FIND_REQUIRED)
49 set(_BOOST_CONFIG "${_BOOST_CONFIG} REQUIRED")
50 endif()
51
52 foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS)
53 if(${Boost_FIND_REQUIRED_${__boost_comp}})
54 list(APPEND _BOOST_COMPONENTS ${__boost_comp})
55 else()
56 list(APPEND _BOOST_OPTIONAL_COMPONENTS ${__boost_comp})
57 endif()
58 endforeach()
59
60 if(_BOOST_COMPONENTS)
61 set(_BOOST_CONFIG "${_BOOST_CONFIG} COMPONENTS ${_BOOST_COMPONENTS}")
62 endif()
63
64 if(_BOOST_OPTIONAL_COMPONENTS)
65 set(_BOOST_CONFIG "${_BOOST_CONFIG} OPTIONAL_COMPONENTS ${_BOOST_OPTIONAL_COMPONENTS}")
66 endif()
67
68 if(_BOOST_CONFIG)
69 message(STATUS " Requested configuration:${_BOOST_CONFIG}")
70 endif()
71
72 unset(_BOOST_CONFIG)
73 unset(_BOOST_COMPONENTS)
74 unset(_BOOST_OPTIONAL_COMPONENTS)
75
76 # find_dependency doesn't forward arguments until 3.9, so we have to roll our own
77
78 macro(boost_find_dependency dep req)
79
80 set(_BOOST_QUIET)
81 if(Boost_FIND_QUIETLY)
82 set(_BOOST_QUIET QUIET)
83 endif()
84
85 set(_BOOST_REQUIRED)
86 if(${req} AND Boost_FIND_REQUIRED)
87 set(_BOOST_REQUIRED REQUIRED)
88 endif()
89
90 get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
91
92 if(Boost_DEBUG)
93 message(STATUS "BoostConfig: find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})")
94 endif()
95 find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})
96
97 string(TOUPPER ${dep} _BOOST_DEP)
98 set(Boost_${_BOOST_DEP}_FOUND ${boost_${dep}_FOUND})
99
100 unset(_BOOST_REQUIRED)
101 unset(_BOOST_QUIET)
102 unset(_BOOST_CMAKEDIR)
103 unset(_BOOST_DEP)
104
105 endmacro()
106
107 # Find boost_headers
108
109 boost_find_dependency(headers 1)
110
111 if(NOT boost_headers_FOUND)
112
113 set(Boost_FOUND 0)
114 set(Boost_NOT_FOUND_MESSAGE "A required dependency, boost_headers, has not been found.")
115
116 return()
117
118 endif()
119
120 # Find components
121
122 foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS)
123
124 boost_find_dependency(${__boost_comp} ${Boost_FIND_REQUIRED_${__boost_comp}})
125
126 endforeach()
127
128 # Compatibility targets
129
130 if(NOT TARGET Boost::boost)
131
132 add_library(Boost::boost INTERFACE IMPORTED)
133 set_property(TARGET Boost::boost APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::headers)
134
135 # All Boost:: targets already disable autolink
136 add_library(Boost::diagnostic_definitions INTERFACE IMPORTED)
137 add_library(Boost::disable_autolinking INTERFACE IMPORTED)
138 add_library(Boost::dynamic_linking INTERFACE IMPORTED)
139
140 endif()