CodeCommitsIssuesPull requestsActionsInsightsSecurity
CLICKHOUSE-3023

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/Modules/FindPoco.cmake

224lines · modecode

1# https://github.com/astahl/poco-cmake/blob/master/cmake/FindPoco.cmake
2
3# - finds the Poco C++ libraries
4# This module finds the Applied Informatics Poco libraries.
5# It supports the following components:
6#
7# Util (loaded by default)
8# Foundation (loaded by default)
9# XML
10# Zip
11# Crypto
12# Data
13# Net
14# NetSSL
15# OSP
16#
17# Usage:
18# set(ENV{Poco_DIR} path/to/poco/sdk)
19# find_package(Poco REQUIRED OSP Data Crypto)
20#
21# On completion, the script defines the following variables:
22#
23# - Compound variables:
24# Poco_FOUND
25# - true if all requested components were found.
26# Poco_LIBRARIES
27# - contains release (and debug if available) libraries for all requested components.
28# It has the form "optimized LIB1 debug LIBd1 optimized LIB2 ...", ready for use with the target_link_libraries command.
29# Poco_INCLUDE_DIRS
30# - Contains include directories for all requested components.
31#
32# - Component variables:
33# Poco_Xxx_FOUND
34# - Where Xxx is the properly cased component name (eg. 'Util', 'OSP').
35# True if a component's library or debug library was found successfully.
36# Poco_Xxx_LIBRARY
37# - Library for component Xxx.
38# Poco_Xxx_LIBRARY_DEBUG
39# - debug library for component Xxx
40# Poco_Xxx_INCLUDE_DIR
41# - include directory for component Xxx
42#
43# - OSP BundleCreator variables: (i.e. bundle.exe on windows, bundle on unix-likes)
44# (is only discovered if OSP is a requested component)
45# Poco_OSP_Bundle_EXECUTABLE_FOUND
46# - true if the bundle-creator executable was found.
47# Poco_OSP_Bundle_EXECUTABLE
48# - the path to the bundle-creator executable.
49#
50# Author: Andreas Stahl andreas.stahl@tu-dresden.de
51
52set(Poco_HINTS
53 /usr/local
54 C:/AppliedInformatics
55 ${Poco_DIR}
56 $ENV{Poco_DIR}
57)
58
59if(NOT Poco_ROOT_DIR)
60 # look for the root directory, first for the source-tree variant
61 find_path(Poco_ROOT_DIR
62 NAMES Foundation/include/Poco/Poco.h
63 HINTS ${Poco_HINTS}
64 )
65 if(NOT Poco_ROOT_DIR)
66 # this means poco may have a different directory structure, maybe it was installed, let's check for that
67 message(STATUS "Looking for Poco install directory structure.")
68 find_path(Poco_ROOT_DIR
69 NAMES include/Poco/Poco.h
70 HINTS ${Poco_HINTS}
71 )
72 if(NOT Poco_ROOT_DIR)
73 # poco was still not found -> Fail
74 if(Poco_FIND_REQUIRED)
75 message(FATAL_ERROR "Poco: Could not find Poco install directory")
76 endif()
77 if(NOT Poco_FIND_QUIETLY)
78 message(STATUS "Poco: Could not find Poco install directory")
79 endif()
80 return()
81 else()
82 # poco was found with the make install directory structure
83 message(STATUS "Assuming Poco install directory structure at ${Poco_ROOT_DIR}.")
84 set(Poco_INSTALLED true)
85 endif()
86 endif()
87endif()
88
89# add dynamic library directory
90if(WIN32)
91 find_path(Poco_RUNTIME_LIBRARY_DIRS
92 NAMES PocoFoundation.dll
93 HINTS ${Poco_ROOT_DIR}
94 PATH_SUFFIXES
95 bin
96 lib
97 )
98endif()
99
100# if installed directory structure, set full include dir
101if(Poco_INSTALLED)
102 set(Poco_INCLUDE_DIRS ${Poco_ROOT_DIR}/include/ CACHE PATH "The global include path for Poco")
103endif()
104
105# append the default minimum components to the list to find
106list(APPEND components
107 ${Poco_FIND_COMPONENTS}
108 # default components:
109 "Util"
110 "Foundation"
111)
112list(REMOVE_DUPLICATES components) # remove duplicate defaults
113
114foreach( component ${components} )
115 #if(NOT Poco_${component}_FOUND)
116
117 # include directory for the component
118 if(NOT Poco_${component}_INCLUDE_DIR)
119 if (${component} STREQUAL "DataODBC")
120 set (component_in_data "ODBC")
121 else ()
122 set (component_in_data "")
123 endif ()
124 if (${component} STREQUAL "NetSSL")
125 set (component_alt "Net")
126 else ()
127 set (component_alt ${component})
128 endif ()
129 find_path(Poco_${component}_INCLUDE_DIR
130 NAMES
131 Poco/${component}.h # e.g. Foundation.h
132 Poco/${component}/${component}.h # e.g. OSP/OSP.h Util/Util.h
133 Poco/${component_alt}/${component}.h # e.g. Net/NetSSL.h
134 Poco/Data/${component_in_data}/${component_in_data}.h # e.g. Data/ODBC/ODBC.h
135 HINTS
136 ${Poco_ROOT_DIR}
137 PATH_SUFFIXES
138 include
139 ${component}/include
140 )
141 endif()
142 if(NOT Poco_${component}_INCLUDE_DIR)
143 message(WARNING "Poco_${component}_INCLUDE_DIR NOT FOUND")
144 else()
145 list(APPEND Poco_INCLUDE_DIRS ${Poco_${component}_INCLUDE_DIR})
146 endif()
147
148 # release library
149 if(NOT Poco_${component}_LIBRARY)
150 find_library(
151 Poco_${component}_LIBRARY
152 NAMES Poco${component}
153 HINTS ${Poco_ROOT_DIR}
154 PATH_SUFFIXES
155 lib
156 bin
157 )
158 if(Poco_${component}_LIBRARY)
159 message(STATUS "Found Poco ${component}: ${Poco_${component}_LIBRARY}")
160 endif()
161 endif()
162 if(Poco_${component}_LIBRARY)
163 list(APPEND Poco_LIBRARIES "optimized" ${Poco_${component}_LIBRARY} )
164 mark_as_advanced(Poco_${component}_LIBRARY)
165 endif()
166
167 # debug library
168 if(NOT Poco_${component}_LIBRARY_DEBUG)
169 find_library(
170 Poco_${component}_LIBRARY_DEBUG
171 Names Poco${component}d
172 HINTS ${Poco_ROOT_DIR}
173 PATH_SUFFIXES
174 lib
175 bin
176 )
177 if(Poco_${component}_LIBRARY_DEBUG)
178 message(STATUS "Found Poco ${component} (debug): ${Poco_${component}_LIBRARY_DEBUG}")
179 endif()
180 endif(NOT Poco_${component}_LIBRARY_DEBUG)
181 if(Poco_${component}_LIBRARY_DEBUG)
182 list(APPEND Poco_LIBRARIES "debug" ${Poco_${component}_LIBRARY_DEBUG})
183 mark_as_advanced(Poco_${component}_LIBRARY_DEBUG)
184 endif()
185
186 # mark component as found or handle not finding it
187 if(Poco_${component}_LIBRARY_DEBUG OR Poco_${component}_LIBRARY)
188 set(Poco_${component}_FOUND TRUE)
189 elseif(NOT Poco_FIND_QUIETLY)
190 message(WARNING "Could not find Poco component ${component}!")
191 endif()
192endforeach()
193
194if(DEFINED Poco_LIBRARIES)
195 set(Poco_FOUND true)
196endif()
197
198if(${Poco_OSP_FOUND})
199 # find the osp bundle program
200 find_program(
201 Poco_OSP_Bundle_EXECUTABLE
202 NAMES bundle
203 HINTS
204 ${Poco_RUNTIME_LIBRARY_DIRS}
205 ${Poco_ROOT_DIR}
206 PATH_SUFFIXES
207 bin
208 OSP/BundleCreator/bin/Darwin/x86_64
209 OSP/BundleCreator/bin/Darwin/i386
210 DOC "The executable that bundles OSP packages according to a .bndlspec specification."
211 )
212 if(Poco_OSP_Bundle_EXECUTABLE)
213 set(Poco_OSP_Bundle_EXECUTABLE_FOUND true)
214 endif()
215 # include bundle script file
216 find_file(Poco_OSP_Bundles_file NAMES PocoBundles.cmake HINTS ${CMAKE_MODULE_PATH})
217 if(${Poco_OSP_Bundles_file})
218 include(${Poco_OSP_Bundles_file})
219 endif()
220endif()
221
222message(STATUS "Found Poco: ${Poco_LIBRARIES}")