[go: up one dir, main page]

File: soci-config.cmake.in

package info (click to toggle)
soci 4.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,944 kB
  • sloc: ansic: 169,887; cpp: 54,198; javascript: 12,258; ada: 1,973; sh: 36; makefile: 12; xml: 2
file content (162 lines) | stat: -rw-r--r-- 4,789 bytes parent folder | download
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
162
@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_soci_boost "@SOCI_DEPENDENCY_BOOST@")
set(__dep_soci_boost_components "@SOCI_DEPENDENCY_BOOST_COMPONENTS@")

set(__prev_module_path "${CMAKE_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/find_package_files/")

if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  set(__quiet "QUIET")
else()
  set(__quiet "")
endif()


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)

# Check (optional) Core dependency on Boost.
if (${__dep_soci_boost})
  if (NOT "${__dep_soci_boost_components}" STREQUAL "")
    set(SOCI_BOOST_COMPONENTS COMPONENTS ${__dep_soci_boost_components})
  endif()

  # Don't use REQUIRED to be able to give a better error message below.
  find_package(Boost ${SOCI_BOOST_COMPONENTS} ${__quiet})

  if (NOT Boost_FOUND)
    set(SOCI_FOUND FALSE)
    set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency 'Boost' for SOCI component 'Core'")
  else()
    # Check for all the components too
    foreach (__soci_boost_component IN LISTS __dep_soci_boost_components)
      if (NOT TARGET Boost::${__soci_boost_component})
        set(SOCI_FOUND FALSE)
        set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency 'Boost::${__soci_boost_component}' for SOCI component 'Core'")
      endif()
    endforeach()
  endif()
endif()

list(LENGTH __dep_soci_comps __list_size)
foreach (__item IN ITEMS __dep_names __dep_dep_targets)
    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)

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(__skip_dependency FALSE)
  foreach (__i RANGE ${__list_size})
    # We want to iterate up to and excluding __list_size, but CMake RANGE
    # doesn't allow this, so do it manually here.
    if (${__i} EQUAL ${__list_size})
      break()
    endif()

    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)

      # Split list-valued entries to become actual lists
      string(REPLACE "|" ";" __targets "${__targets}")

      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()

      find_package(
        ${__dep}
        ${__quiet}
      )

      if (NOT ${__dep}_FOUND)
        set(SOCI_FOUND FALSE)
        set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency '${__dep}' for SOCI component '${__comp}'")
        set(__skip_dependency TRUE)
      endif()

      list(APPEND __link_targets  ${__targets})
    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}"
  )
  set(${CMAKE_FIND_PACKAGE_NAME}_${__comp}_FOUND ON)
endforeach()
unset(__comp)


unset(__dep_soci_comps)
unset(__dep_names)
unset(__dep_dep_targets)


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()

unset(__quiet)

set(CMAKE_MODULE_PATH "${__prev_module_path}")
unset(__prev_module_path)