|
| 1 | +# FROM 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 | +# JSON |
| 10 | +# XML |
| 11 | +# Zip |
| 12 | +# Crypto |
| 13 | +# Data |
| 14 | +# Net |
| 15 | +# NetSSL |
| 16 | +# OSP |
| 17 | +# |
| 18 | +# Usage: |
| 19 | +# set(ENV{Poco_DIR} path/to/poco/sdk) |
| 20 | +# find_package(Poco REQUIRED OSP Data Crypto) |
| 21 | +# |
| 22 | +# On completion, the script defines the following variables: |
| 23 | +# |
| 24 | +# - Compound variables: |
| 25 | +# Poco_FOUND |
| 26 | +# - true if all requested components were found. |
| 27 | +# Poco_LIBRARIES |
| 28 | +# - contains release (and debug if available) libraries for all requested components. |
| 29 | +# It has the form "optimized LIB1 debug LIBd1 optimized LIB2 ...", ready for use with the target_link_libraries command. |
| 30 | +# Poco_INCLUDE_DIRS |
| 31 | +# - Contains include directories for all requested components. |
| 32 | +# |
| 33 | +# - Component variables: |
| 34 | +# Poco_Xxx_FOUND |
| 35 | +# - Where Xxx is the properly cased component name (eg. 'Util', 'OSP'). |
| 36 | +# True if a component's library or debug library was found successfully. |
| 37 | +# Poco_Xxx_LIBRARY |
| 38 | +# - Library for component Xxx. |
| 39 | +# Poco_Xxx_LIBRARY_DEBUG |
| 40 | +# - debug library for component Xxx |
| 41 | +# Poco_Xxx_INCLUDE_DIR |
| 42 | +# - include directory for component Xxx |
| 43 | +# |
| 44 | +# - OSP BundleCreator variables: (i.e. bundle.exe on windows, bundle on unix-likes) |
| 45 | +# (is only discovered if OSP is a requested component) |
| 46 | +# Poco_OSP_Bundle_EXECUTABLE_FOUND |
| 47 | +# - true if the bundle-creator executable was found. |
| 48 | +# Poco_OSP_Bundle_EXECUTABLE |
| 49 | +# - the path to the bundle-creator executable. |
| 50 | +# |
| 51 | +# Author: Andreas Stahl [email protected] |
| 52 | + |
| 53 | +set(Poco_HINTS |
| 54 | + /usr/local |
| 55 | + C:/AppliedInformatics |
| 56 | + ${Poco_DIR} |
| 57 | + $ENV{Poco_DIR} |
| 58 | +) |
| 59 | + |
| 60 | +if(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 | + 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() |
| 87 | +endif() |
| 88 | + |
| 89 | +# add dynamic library directory |
| 90 | +if(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 | + ) |
| 98 | +endif() |
| 99 | + |
| 100 | +# if installed directory structure, set full include dir |
| 101 | +if(Poco_INSTALLED) |
| 102 | + set(Poco_INCLUDE_DIRS ${Poco_ROOT_DIR}/include/ CACHE PATH "The global include path for Poco") |
| 103 | +endif() |
| 104 | + |
| 105 | +# append the default minimum components to the list to find |
| 106 | +list(APPEND components |
| 107 | + ${Poco_FIND_COMPONENTS} |
| 108 | + # default components: |
| 109 | + "Util" |
| 110 | + "Foundation" |
| 111 | +) |
| 112 | +list(REMOVE_DUPLICATES components) # remove duplicate defaults |
| 113 | + |
| 114 | +foreach( 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 "NetSSL") |
| 120 | + set(component_INCLUDE_NAMES |
| 121 | + "Poco/Net/NetSSL.h" |
| 122 | + ) |
| 123 | + else() |
| 124 | + set(component_INCLUDE_NAMES |
| 125 | + "Poco/${component}.h" # e.g. Foundation.h |
| 126 | + "Poco/${component}/${component}.h" # e.g. OSP/OSP.h Util/Util.h |
| 127 | + ) |
| 128 | + endif() |
| 129 | + find_path(Poco_${component}_INCLUDE_DIR |
| 130 | + NAMES |
| 131 | + ${component_INCLUDE_NAMES} |
| 132 | + HINTS |
| 133 | + ${Poco_ROOT_DIR} |
| 134 | + PATH_SUFFIXES |
| 135 | + include |
| 136 | + ${component}/include |
| 137 | + ) |
| 138 | + endif() |
| 139 | + if(NOT Poco_${component}_INCLUDE_DIR) |
| 140 | + message(FATAL_ERROR "Poco_${component}_INCLUDE_DIR NOT FOUND") |
| 141 | + else() |
| 142 | + list(APPEND Poco_INCLUDE_DIRS ${Poco_${component}_INCLUDE_DIR}) |
| 143 | + endif() |
| 144 | + |
| 145 | + # release library |
| 146 | + if(NOT Poco_${component}_LIBRARY) |
| 147 | + find_library( |
| 148 | + Poco_${component}_LIBRARY |
| 149 | + NAMES Poco${component} |
| 150 | + HINTS ${Poco_ROOT_DIR} |
| 151 | + PATH_SUFFIXES |
| 152 | + lib |
| 153 | + bin |
| 154 | + ) |
| 155 | + if(Poco_${component}_LIBRARY) |
| 156 | + message(STATUS "Found Poco ${component}: ${Poco_${component}_LIBRARY}") |
| 157 | + endif() |
| 158 | + endif() |
| 159 | + if(Poco_${component}_LIBRARY) |
| 160 | + list(APPEND Poco_LIBRARIES "optimized" ${Poco_${component}_LIBRARY} ) |
| 161 | + mark_as_advanced(Poco_${component}_LIBRARY) |
| 162 | + endif() |
| 163 | + |
| 164 | + # debug library |
| 165 | + if(NOT Poco_${component}_LIBRARY_DEBUG) |
| 166 | + find_library( |
| 167 | + Poco_${component}_LIBRARY_DEBUG |
| 168 | + Names Poco${component}d |
| 169 | + HINTS ${Poco_ROOT_DIR} |
| 170 | + PATH_SUFFIXES |
| 171 | + lib |
| 172 | + bin |
| 173 | + ) |
| 174 | + if(Poco_${component}_LIBRARY_DEBUG) |
| 175 | + message(STATUS "Found Poco ${component} (debug): ${Poco_${component}_LIBRARY_DEBUG}") |
| 176 | + endif() |
| 177 | + endif(NOT Poco_${component}_LIBRARY_DEBUG) |
| 178 | + if(Poco_${component}_LIBRARY_DEBUG) |
| 179 | + list(APPEND Poco_LIBRARIES "debug" ${Poco_${component}_LIBRARY_DEBUG}) |
| 180 | + mark_as_advanced(Poco_${component}_LIBRARY_DEBUG) |
| 181 | + endif() |
| 182 | + |
| 183 | + # mark component as found or handle not finding it |
| 184 | + if(Poco_${component}_LIBRARY_DEBUG OR Poco_${component}_LIBRARY) |
| 185 | + set(Poco_${component}_FOUND TRUE) |
| 186 | + elseif(NOT Poco_FIND_QUIETLY) |
| 187 | + message(FATAL_ERROR "Could not find Poco component ${component}!") |
| 188 | + endif() |
| 189 | +endforeach() |
| 190 | + |
| 191 | +if(DEFINED Poco_LIBRARIES) |
| 192 | + set(Poco_FOUND true) |
| 193 | +endif() |
| 194 | + |
| 195 | +if(${Poco_OSP_FOUND}) |
| 196 | + # find the osp bundle program |
| 197 | + find_program( |
| 198 | + Poco_OSP_Bundle_EXECUTABLE |
| 199 | + NAMES bundle |
| 200 | + HINTS |
| 201 | + ${Poco_RUNTIME_LIBRARY_DIRS} |
| 202 | + ${Poco_ROOT_DIR} |
| 203 | + PATH_SUFFIXES |
| 204 | + bin |
| 205 | + OSP/BundleCreator/bin/Darwin/x86_64 |
| 206 | + OSP/BundleCreator/bin/Darwin/i386 |
| 207 | + DOC "The executable that bundles OSP packages according to a .bndlspec specification." |
| 208 | + ) |
| 209 | + if(Poco_OSP_Bundle_EXECUTABLE) |
| 210 | + set(Poco_OSP_Bundle_EXECUTABLE_FOUND true) |
| 211 | + endif() |
| 212 | + # include bundle script file |
| 213 | + find_file(Poco_OSP_Bundles_file NAMES PocoBundles.cmake HINTS ${CMAKE_MODULE_PATH}) |
| 214 | + if(${Poco_OSP_Bundles_file}) |
| 215 | + include(${Poco_OSP_Bundles_file}) |
| 216 | + endif() |
| 217 | +endif() |
| 218 | + |
| 219 | +message(STATUS "Found Poco: ${Poco_LIBRARIES}") |
| 220 | + |
| 221 | + |
0 commit comments