-
Notifications
You must be signed in to change notification settings - Fork 487
/
Copy pathsoci-config.cmake.in
161 lines (128 loc) · 4.55 KB
/
soci-config.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
154
155
156
157
158
159
160
161
@PACKAGE_INIT@
# Auto-generated stub to handle component-wise dependencies
set(__dep_soci_comps "@SOCI_DEPENDENCY_SOCI_COMPONENTS@")
set(__dep_names "@SOCI_DEPENDENCY_NAMES@")
set(__dep_dep_targets "@SOCI_DEPENDENCY_TARGETS@")
set(__dep_required "@SOCI_DEPENDENCY_REQUIRED@")
set(__dep_macro_names "@SOCI_DEPENDENCY_MACRO_NAMES@")
set(__dep_components "@SOCI_DEPENDENCY_COMPONENTS@")
set(__prev_module_path "${CMAKE_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/find_package_files/")
if (NOT DEFINED SOCI_FIND_COMPONENTS OR SOCI_FIND_COMPONENTS STREQUAL "")
# Use all available SOCI components
set(SOCI_FIND_COMPONENTS "${__dep_soci_comps}")
list(REMOVE_DUPLICATES SOCI_FIND_COMPONENTS)
list(TRANSFORM SOCI_FIND_COMPONENTS REPLACE "SOCI::" "")
endif()
# Ensure that the Core target is always included (and as first component)
list(REMOVE_ITEM SOCI_FIND_COMPONENTS Core)
list(INSERT SOCI_FIND_COMPONENTS 0 Core)
list(LENGTH __dep_soci_comps __list_size)
foreach (__item IN ITEMS __dep_names __dep_dep_targets __dep_required __dep_macro_names __dep_components)
list(LENGTH ${__item} __current_size)
if (NOT (__list_size EQUAL __current_size))
message(FATAL_ERROR "SociConfig is invalid -> dependency lists have different sizes")
endif()
endforeach()
unset(__current_size)
math(EXPR __list_size "${__list_size} - 1")
foreach(__comp IN LISTS SOCI_FIND_COMPONENTS)
if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/SOCI${__comp}Targets.cmake")
set(SOCI_FOUND FALSE)
set(SOCI_NOT_FOUND_MESSAGE "'${__comp}' is not a known SOCI component")
continue()
endif()
# Handle component-specific dependencies
set(__link_targets)
set(__define_macros)
set(__skip_dependency FALSE)
foreach (__i RANGE ${__list_size})
list(GET __dep_soci_comps ${__i} __dep_comp)
if (__dep_comp MATCHES "::${__comp}$")
# This entry matches the current component
list(GET __dep_names ${__i} __dep)
list(GET __dep_dep_targets ${__i} __targets)
list(GET __dep_required ${__i} __required)
list(GET __dep_macro_names ${__i} __macros)
list(GET __dep_components ${__i} __components)
# Split list-valued entries to become actual lists
string(REPLACE "|" ";" __targets "${__targets}")
string(REPLACE "|" ";" __macros "${__macros}")
string(REPLACE "|" ";" __components "${__components}")
set(__already_found)
foreach (__tgt IN LISTS __targets)
if (TARGET ${__tgt})
set(__already_found ON)
else()
set(__already_found OFF)
break()
endif()
endforeach()
if (__already_found)
continue()
endif()
if (__components)
set(__components COMPONENTS ${__components})
endif()
if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(__quiet "QUIET")
else()
set(__quiet "")
endif()
find_package(
${__dep}
${__components}
${__quiet}
)
if (NOT ${__dep}_FOUND)
if (__required)
set(SOCI_FOUND FALSE)
set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency '${__dep}' for SOCI component '${__comp}'")
set(__skip_dependency TRUE)
endif()
continue()
endif()
list(APPEND __link_targets ${__targets})
list(APPEND __define_macros ${__macros})
endif()
endforeach()
unset(__i)
if (__skip_dependency)
continue()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/SOCI${__comp}Targets.cmake")
set_property(
TARGET SOCI::${__comp}
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES "${__link_targets}"
)
if (__define_macros)
set_property(
TARGET SOCI::${__comp}
APPEND
PROPERTY INTERFACE_COMPILE_DEFINITIONS "${__define_macros}"
)
endif()
set(${CMAKE_FIND_PACKAGE_NAME}_${__comp}_FOUND ON)
endforeach()
unset(__comp)
unset(__dep_soci_comps)
unset(__dep_names)
unset(__dep_dep_targets)
unset(__dep_required)
unset(__dep_macro_names)
unset(__dep_components)
check_required_components(SOCI)
if (NOT DEFINED SOCI_FOUND OR SOCI_FOUND)
add_library(soci_interface INTERFACE)
foreach (__comp IN LISTS SOCI_FIND_COMPONENTS)
target_link_libraries(soci_interface INTERFACE SOCI::${__comp})
endforeach()
add_library(SOCI::soci ALIAS soci_interface)
if (NOT SOCI_FIND_QUIETLY)
list(JOIN SOCI_FIND_COMPONENTS ", " __components)
message(STATUS "Found SOCI: ${CMAKE_CURRENT_LIST_FILE} (found version \"@PROJECT_VERSION@\") found components: ${__components}")
endif()
endif()
set(CMAKE_MODULE_PATH "${__prev_module_path}")
unset(__prev_module_path)