]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_API_CPP/api/cmake_files/FindPOCO.cmake
Salome HOME
API c++
[modules/gde.git] / projects / GDE_API_CPP / api / cmake_files / FindPOCO.cmake
1 # - Find the Poco includes and libraries.
2 # The following variables are set if Poco is found. If Poco is not
3 # found, Poco_FOUND is set to false.
4 # Poco_FOUND - True when the Poco include directory is found.
5 # Poco_INCLUDE_DIRS - the path to where the poco include files are.
6 # Poco_LIBRARY_DIRS - The path to where the poco library files are.
7 # Poco_BINARY_DIRS - The path to where the poco dlls are.
8
9 # ----------------------------------------------------------------------------
10 # If you have installed Poco in a non-standard location.
11 # Then you have three options.
12 # In the following comments, it is assumed that <Your Path>
13 # points to the root directory of the include directory of Poco. e.g
14 # If you have put poco in C:\development\Poco then <Your Path> is
15 # "C:/development/Poco" and in this directory there will be two
16 # directories called "include" and "lib".
17 # 1) After CMake runs, set Poco_INCLUDE_DIR to <Your Path>/poco<-version>
18 # 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/poco<-version>. This will allow find_path()
19 # to locate Poco_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g.
20 # set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
21 # 3) Set an environment variable called ${POCO_ROOT} that points to the root of where you have
22 # installed Poco, e.g. <Your Path>. It is assumed that there is at least a subdirectory called
23 # Foundation/include/Poco in this path.
24 #
25 # Note:
26 # 1) If you are just using the poco headers, then you do not need to use
27 # Poco_LIBRARY_DIR in your CMakeLists.txt file.
28 # 2) If Poco has not been installed, then when setting Poco_LIBRARY_DIR
29 # the script will look for /lib first and, if this fails, then for /stage/lib.
30 #
31 # Usage:
32 # In your CMakeLists.txt file do something like this:
33 # ...
34 # # Poco
35 # find_package(Poco)
36 # ...
37 # include_directories(${Poco_INCLUDE_DIRS})
38 # link_directories(${Poco_LIBRARY_DIR})
39 #
40 # In Windows, we make the assumption that, if the Poco files are installed, the default directory
41 # will be C:\poco or C:\Program Files\Poco or C:\Programme\Poco.
42
43 set(POCO_INCLUDE_PATH_DESCRIPTION "top-level directory containing the poco include directories.")
44 set(POCO_INCLUDE_DIR_MESSAGE "Set the Poco_INCLUDE_DIR cmake cache entry to the ${POCO_INCLUDE_PATH_DESCRIPTION}")
45 set(POCO_LIBRARY_PATH_DESCRIPTION "directory containing the poco libraries:")
46
47
48 set(POCO_DIR_SEARCH $ENV{POCO_ROOT})
49 if(POCO_DIR_SEARCH)
50  file(TO_CMAKE_PATH ${POCO_DIR_SEARCH} POCO_DIR_SEARCH)
51 endif(POCO_DIR_SEARCH)
52 list(APPEND POCO_DIR_SEARCH ${Poco_DIR})
53
54 if(WIN32)
55  set(POCO_DIR_SEARCH
56  ${POCO_DIR_SEARCH}
57  C:/poco
58  D:/poco
59  "C:/Program Files/poco"
60  "C:/Programme/poco"
61  "D:/Program Files/poco"
62  "D:/Programme/poco"
63  )
64 endif(WIN32)
65
66 # Add in some path suffixes. These will have to be updated whenever a new Poco version comes out.
67 set(SUFFIX_FOR_INCLUDE_PATH
68  include
69 )
70
71 set(SUFFIX_FOR_LIBRARY_PATH
72  lib
73  bin
74 )
75
76 #
77 # Look for an installation.
78 #
79 find_path(Poco_INCLUDE_DIR NAMES Poco/Poco.h PATH_SUFFIXES ${SUFFIX_FOR_INCLUDE_PATH} PATHS
80
81  # Look in other places.
82  ${POCO_DIR_SEARCH}
83
84  # Help the user find it if we cannot.
85  DOC "The ${POCO_INCLUDE_PATH_DESCRIPTION}"
86 )
87
88 if(NOT Poco_INCLUDE_DIR)
89
90  # Look for standard unix include paths
91  find_path(Poco_INCLUDE_DIR Poco/Poco.h DOC "The ${POCO_INCLUDE_PATH_DESCRIPTION}")
92
93 endif(NOT Poco_INCLUDE_DIR)
94
95 # Assume we didn't find it.
96 set(Poco_FOUND 0)
97
98 set(Poco_LIBRARIES )
99 set(Poco_LIBRARY_DIRS )
100
101 # Now try to get the include and library path.
102 # Find all libraries, store debug and release separately
103 foreach(lib
104  Crypto
105  Data
106  DataMySQL
107  DataSQLite
108  Foundation
109  JSON
110  MongoDB
111  Net
112  NetSSL
113  PDF
114  Util
115  XML
116  Zip
117  )
118
119  # Find Release libraries
120  find_library(Poco_${lib}_LIBRARY_RELEASE
121  NAMES Poco${lib}
122  PATH_SUFFIXES ${SUFFIX_FOR_LIBRARY_PATH}
123  PATHS ${POCO_DIR_SEARCH}
124  DOC "The ${POCO_LIBRARY_PATH_DESCRIPTION} Poco${lib}"
125  )
126
127  # Find Debug libraries
128  find_library(Poco_${lib}_LIBRARY_DEBUG
129  NAMES Poco${lib}d
130  PATH_SUFFIXES ${SUFFIX_FOR_LIBRARY_PATH}
131  PATHS ${POCO_DIR_SEARCH}
132  DOC "The ${POCO_LIBRARY_PATH_DESCRIPTION} Poco${lib}d"
133  )
134
135  mark_as_advanced(Poco_${lib}_LIBRARY_RELEASE)
136  mark_as_advanced(Poco_${lib}_LIBRARY_DEBUG)
137
138  # Add libraries to variable according to build type
139  set(Poco_${lib}_LIBRARY)
140  if(Poco_${lib}_LIBRARY_RELEASE)
141  list(APPEND Poco_LIBRARIES optimized ${Poco_${lib}_LIBRARY_RELEASE})
142  list(APPEND Poco_${lib}_LIBRARY optimized ${Poco_${lib}_LIBRARY_RELEASE})
143  get_filename_component(lib_dir ${Poco_${lib}_LIBRARY_RELEASE} PATH)
144  list(APPEND Poco_LIBRARY_DIRS ${lib_dir})
145  endif()
146
147  if(Poco_${lib}_LIBRARY_DEBUG)
148  list(APPEND Poco_LIBRARIES debug ${Poco_${lib}_LIBRARY_DEBUG})
149  list(APPEND Poco_${lib}_LIBRARY debug ${Poco_${lib}_LIBRARY_DEBUG})
150  get_filename_component(lib_dir ${Poco_${lib}_LIBRARY_RELEASE} PATH)
151  list(APPEND Poco_LIBRARY_DIRS ${lib_dir})
152  endif()
153
154 endforeach()
155
156 if(Poco_LIBRARY_DIRS)
157  list(REMOVE_DUPLICATES Poco_LIBRARY_DIRS)
158 endif()
159
160 set(Poco_INCLUDE_DIRS ${Poco_INCLUDE_DIR})
161
162 include(FindPackageHandleStandardArgs)
163 find_package_handle_standard_args(Poco DEFAULT_MSG
164  Poco_INCLUDE_DIRS
165  Poco_Foundation_LIBRARY
166  Poco_LIBRARIES
167  )