CodeCommitsIssuesPull requestsActionsInsightsSecurity
v18.12.9-testing

Branches

Tags

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

Clone

HTTPS

Download ZIP

cmake/Modules/FindPoco.cmake

233lines · 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 /usr/local/include/Poco
55 C:/AppliedInformatics
56 ${Poco_DIR}
57 $ENV{Poco_DIR}
58)
59
60if(NOT Poco_ROOT_DIR)
61 # look for the root directory, first for the source-tree variant
62 find_path(Poco_ROOT_DIR
63 NAMES Foundation/include/Poco/Poco.h
64 HINTS ${Poco_HINTS}
65 )
66 if(NOT Poco_ROOT_DIR)
67 # this means poco may have a different directory structure, maybe it was installed, let's check for that
68 message(STATUS "Looking for Poco install directory structure.")
69 find_path(Poco_ROOT_DIR
70 NAMES include/Poco/Poco.h
71 HINTS ${Poco_HINTS}
72 )
73 if(NOT Poco_ROOT_DIR)
74 # poco was still not found -> Fail
75 if(Poco_FIND_REQUIRED)
76 message(FATAL_ERROR "Poco: Could not find Poco install directory")
77 endif()
78 if(NOT Poco_FIND_QUIETLY)
79 message(STATUS "Poco: Could not find Poco install directory")
80 endif()
81 return()
82 else()
83 # poco was found with the make install directory structure
84 message(STATUS "Assuming Poco install directory structure at ${Poco_ROOT_DIR}.")
85 set(Poco_INSTALLED true)
86 endif()
87 endif()
88endif()
89
90# add dynamic library directory
91if(WIN32)
92 find_path(Poco_RUNTIME_LIBRARY_DIRS
93 NAMES PocoFoundation.dll
94 HINTS ${Poco_ROOT_DIR}
95 PATH_SUFFIXES
96 bin
97 lib
98 )
99endif()
100
101# if installed directory structure, set full include dir
102if(Poco_INSTALLED)
103 set(Poco_INCLUDE_DIRS ${Poco_ROOT_DIR}/include/ CACHE PATH "The global include path for Poco")
104endif()
105
106# append the default minimum components to the list to find
107list(APPEND components
108 ${Poco_FIND_COMPONENTS}
109 # default components:
110 "Util"
111 "Foundation"
112)
113list(REMOVE_DUPLICATES components) # remove duplicate defaults
114
115foreach( component ${components} )
116 #if(NOT Poco_${component}_FOUND)
117
118 # include directory for the component
119 if(NOT Poco_${component}_INCLUDE_DIR)
120 if (${component} STREQUAL "DataODBC")
121 set (component_in_data "ODBC")
122 else ()
123 set (component_in_data "")
124 endif ()
125 if (${component} STREQUAL "NetSSL")
126 set (component_alt "Net")
127 else ()
128 set (component_alt ${component})
129 endif ()
130 find_path(Poco_${component}_INCLUDE_DIR
131 NAMES
132 Poco/${component}.h # e.g. Foundation.h
133 Poco/${component}/${component}.h # e.g. OSP/OSP.h Util/Util.h
134 Poco/${component_alt}/${component}.h # e.g. Net/NetSSL.h
135 Poco/Data/${component_in_data}/${component_in_data}.h # e.g. Data/ODBC/ODBC.h
136 HINTS
137 ${Poco_ROOT_DIR}
138 PATH_SUFFIXES
139 include
140 ${component}/include
141 )
142 endif()
143 if(NOT Poco_${component}_INCLUDE_DIR)
144 message(WARNING "Poco_${component}_INCLUDE_DIR NOT FOUND")
145 else()
146 list(APPEND Poco_INCLUDE_DIRS ${Poco_${component}_INCLUDE_DIR})
147 endif()
148
149 # release library
150 if(NOT Poco_${component}_LIBRARY)
151 find_library(
152 Poco_${component}_LIBRARY
153 NAMES Poco${component}
154 HINTS ${Poco_ROOT_DIR}
155 PATH_SUFFIXES
156 lib
157 bin
158 )
159 if(Poco_${component}_LIBRARY)
160 message(STATUS "Found Poco ${component}: ${Poco_${component}_LIBRARY}")
161 endif()
162 endif()
163 if(Poco_${component}_LIBRARY)
164 list(APPEND Poco_LIBRARIES "optimized" ${Poco_${component}_LIBRARY} )
165 mark_as_advanced(Poco_${component}_LIBRARY)
166 endif()
167
168 # debug library
169 if(NOT Poco_${component}_LIBRARY_DEBUG)
170 find_library(
171 Poco_${component}_LIBRARY_DEBUG
172 Names Poco${component}d
173 HINTS ${Poco_ROOT_DIR}
174 PATH_SUFFIXES
175 lib
176 bin
177 )
178 if(Poco_${component}_LIBRARY_DEBUG)
179 message(STATUS "Found Poco ${component} (debug): ${Poco_${component}_LIBRARY_DEBUG}")
180 endif()
181 endif(NOT Poco_${component}_LIBRARY_DEBUG)
182 if(Poco_${component}_LIBRARY_DEBUG)
183 list(APPEND Poco_LIBRARIES "debug" ${Poco_${component}_LIBRARY_DEBUG})
184 mark_as_advanced(Poco_${component}_LIBRARY_DEBUG)
185 endif()
186
187 # mark component as found or handle not finding it
188 if(Poco_${component}_LIBRARY_DEBUG OR Poco_${component}_LIBRARY)
189 set(Poco_${component}_FOUND TRUE)
190 elseif(NOT Poco_FIND_QUIETLY)
191 message(WARNING "Could not find Poco component ${component}!")
192 endif()
193endforeach()
194
195if(Poco_DataODBC_LIBRARY)
196 list(APPEND Poco_DataODBC_LIBRARY ${ODBC_LIBRARIES} ${LTDL_LIBRARY})
197 list(APPEND Poco_INCLUDE_DIRS ${ODBC_INCLUDE_DIRECTORIES})
198endif()
199
200if(Poco_NetSSL_LIBRARY)
201 list(APPEND Poco_NetSSL_LIBRARY ${OPENSSL_LIBRARIES})
202 list(APPEND Poco_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
203endif()
204
205if(DEFINED Poco_LIBRARIES)
206 set(Poco_FOUND true)
207endif()
208
209if(${Poco_OSP_FOUND})
210 # find the osp bundle program
211 find_program(
212 Poco_OSP_Bundle_EXECUTABLE
213 NAMES bundle
214 HINTS
215 ${Poco_RUNTIME_LIBRARY_DIRS}
216 ${Poco_ROOT_DIR}
217 PATH_SUFFIXES
218 bin
219 OSP/BundleCreator/bin/Darwin/x86_64
220 OSP/BundleCreator/bin/Darwin/i386
221 DOC "The executable that bundles OSP packages according to a .bndlspec specification."
222 )
223 if(Poco_OSP_Bundle_EXECUTABLE)
224 set(Poco_OSP_Bundle_EXECUTABLE_FOUND true)
225 endif()
226 # include bundle script file
227 find_file(Poco_OSP_Bundles_file NAMES PocoBundles.cmake HINTS ${CMAKE_MODULE_PATH})
228 if(${Poco_OSP_Bundles_file})
229 include(${Poco_OSP_Bundles_file})
230 endif()
231endif()
232
233message(STATUS "Found Poco: ${Poco_LIBRARIES}")