-
Notifications
You must be signed in to change notification settings - Fork 7
/
BoostConfig.cmake.in
154 lines (137 loc) · 6.19 KB
/
BoostConfig.cmake.in
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# - Boost CMake Configuration File to replace FindBoost
# Use of find_package's config mode plus use if imported targets
# provides a most robust location mechanism.
#
# This config file aims for compatibility with FindBoost's interface
# and results. The following variables are set by this config file,
# with differences from FindBoost noted:
#
# Boost_FOUND True if headers and requested libraries were found
# Boost_INCLUDE_DIRS Boost include directories
# Boost_LIBRARY_DIRS Link directories for Boost libraries
# Boost_LIBRARIES Boost component libraries to be linked
# Boost_<C>_FOUND True if component <C> was found (<C> is upper-case)
# Boost_<C>_LIBRARY Libraries to link for component <C> (will be
# an imported target)
# Boost_VERSION Boost's X.Y.Z version number
# NB: FindBoost sets this as the value of
# BOOST_VERSION in boost/version.hpp
# Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
# Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
# Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
#
# As with FindBoost, several variables can be set prior to the call to
# find_package(Boost) to influence which threading and link model
# libraries will be searched for:
#
# Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
# Boost libraries. If not specified, default to
# ON.
#
# Boost_USE_STATIC_LIBS Can be set to ON to force the use of the
# static Boost libraries. Defaults to OFF.
#
# Fatal errors will be emitted (i.e. configuration failed) if the
# requested thread/link model libs are not provided by this install of
# Boost.
#
# The main departure from FindBoost is in the separation of Release
# and Debug (and in the future, Profile) libraries. Whilst FindBoost
# stores paths to Release and Debug libs in separate variables,
# BoostConfig uses imported targets which store both paths and link
# the one appropriate for the client's build mode. For example:
#
# find_package(Boost 1.58.0 REQUIRED regex)
# add_executable(foo foo.cpp)
# target_link_libraries(foo ${Boost_REGEX_LIBRARY})
#
# would link `foo` to `libboost_regex-mt.so` when foo is built in
# Release mode, and to `libboost_regex-mt-d.so` when foo is built in
# Debug mode.
#
#-----------------------------------------------------------------------
# Locate ourselves, since we can locate all other files relative to
# where we are.
#
get_filename_component(__cfl_boost_config_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
#-----------------------------------------------------------------------
# Versioning variables for compatibility with FindBoost
#
set(Boost_MAJOR_VERSION "@Boost_MAJOR_VERSION@")
set(Boost_MINOR_VERSION "@Boost_MINOR_VERSION@")
set(Boost_SUBMINOR_VERSION "@Boost_SUBMINOR_VERSION@")
#-----------------------------------------------------------------------
# Configure variables for compatibility with FindBoost's link/thread
# model selection.
#
# - Boost_USE_STATIC_LIBS
set(Boost_LINKMODEL_TAG "-shared")
set(Boost_STATIC_LIBS_FOUND @boost.staticlibs@)
if(Boost_USE_STATIC_LIBS)
if(Boost_STATIC_LIBS_FOUND)
set(Boost_LINKMODEL_TAG "-static")
else()
message(FATAL_ERROR "The found Boost installation, loaded from\n${__cfl_boost_config_dir}\n does not provide the static variants of the Boost libraries.")
endif()
endif()
# - Boost_USE_MULTITHREADED
set(Boost_THREADMODEL_TAG "-multithread")
set(Boost_MULTITHREADED_FOUND ON)
set(Boost_SINGLETHREADED_FOUND @boost.singlethread@)
if(DEFINED Boost_USE_MULTITHREADED AND NOT Boost_USE_MULTITHREADED)
if(Boost_SINGLETHREADED_FOUND)
set(Boost_THREADMODEL_TAG "-singlethread")
else()
message(FATAL_ERROR "The found Boost installation, loaded from\n${__cfl_boost_config_dir}\n does not provide the single threaded variants of the Boost libraries.")
endif()
endif()
#-----------------------------------------------------------------------
# Set the header path
#
get_filename_component(Boost_INCLUDE_DIR "${__cfl_boost_config_dir}/../../../include" ABSOLUTE CACHE)
set(Boost_INCLUDE_DIR "${Boost_INCLUDE_DIR}" CACHE PATH "Path to the Boost headers")
mark_as_advanced(Boost_INCLUDE_DIR)
set(Boost_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
#-----------------------------------------------------------------------
# Load library depends file for link/thread model requested
#
if(NOT Boost_LIBDEPS_LOADED)
include("${__cfl_boost_config_dir}/BoostLibraryDepends${Boost_LINKMODEL_TAG}${Boost_THREADMODEL_TAG}.cmake")
set(Boost_LIBDEPS_LOADED 1)
endif()
#-----------------------------------------------------------------------
# Handle components as loaded by the LibraryDepends file
#
foreach(_boost_component ${Boost_INSTALLED_COMPONENTS})
# Map FindBoost's 'Boost_<C>_LIBRARY' variables to the imported target
# names
string(TOUPPER "${_boost_component}" _boost_component_upper)
set(Boost_${_boost_component_upper}_FOUND 1)
set(Boost_${_boost_component_upper}_LIBRARY "boost_${_boost_component}" CACHE FILEPATH "Path (imported) to the Boost ${_boost_component} library")
mark_as_advanced(Boost_${_boost_component_upper}_LIBRARY)
if(Boost_FIND_REQUIRED_${_boost_component})
list(APPEND Boost_LIBRARIES ${Boost_${_boost_component_upper}_LIBRARY})
endif()
if(Boost_FIND_COMPONENTS)
list(REMOVE_ITEM Boost_FIND_COMPONENTS ${_boost_component})
endif()
endforeach()
if(Boost_LIBRARIES)
list(REMOVE_DUPLICATES Boost_LIBRARIES)
endif()
#-----------------------------------------------------------------------
# Finally, handle any remaining components.
# We should have dealt with all available components above, and removed
# them from the list of FIND_COMPONENTS so any left we either didn't
# find or don't know about. Emit a warning if REQUIRED isn't set, or
# FATAL_ERROR otherwise
#
list(REMOVE_DUPLICATES Boost_FIND_COMPONENTS)
foreach(_remaining ${Boost_FIND_COMPONENTS})
if(Boost_FIND_REQUIRED)
message(FATAL_ERROR "Boost component ${_remaining} not found")
elseif(NOT Boost_FIND_QUIETLY)
message(WARNING " Boost component ${_remaining} not found")
endif()
unset(Boost_FIND_REQUIRED_${_remaining})
endforeach()