Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindBoost.cmake
1 # - Try to find Boost include dirs and libraries
2 # Usage of this module as follows:
3 #
4 # NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable below.
5 # Due to Boost naming conventions and limitations in CMake this find
6 # module is NOT future safe with respect to Boost version numbers,
7 # and may break.
8 #
9 # == Using Header-Only libraries from within Boost: ==
10 #
11 #   find_package( Boost 1.36.0 )
12 #   if(Boost_FOUND)
13 #      include_directories(${Boost_INCLUDE_DIRS})
14 #      add_executable(foo foo.cc)
15 #   endif()
16 #
17 #
18 # == Using actual libraries from within Boost: ==
19 #
20 #   set(Boost_USE_STATIC_LIBS        ON)
21 #   set(Boost_USE_MULTITHREADED      ON)
22 #   set(Boost_USE_STATIC_RUNTIME    OFF)
23 #   find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
24 #
25 #   if(Boost_FOUND)
26 #      include_directories(${Boost_INCLUDE_DIRS})
27 #      add_executable(foo foo.cc)
28 #      target_link_libraries(foo ${Boost_LIBRARIES})
29 #   endif()
30 #
31 #
32 # The components list needs to contain actual names of boost libraries only,
33 # such as "date_time" for "libboost_date_time".  If you're using parts of
34 # Boost that contain header files only (e.g. foreach) you do not need to
35 # specify COMPONENTS.
36 #
37 # You should provide a minimum version number that should be used. If you provide this
38 # version number and specify the REQUIRED attribute, this module will fail if it
39 # can't find the specified or a later version. If you specify a version number this is
40 # automatically put into the considered list of version numbers and thus doesn't need
41 # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
42 #
43 # NOTE for Visual Studio Users:
44 #     Automatic linking is used on MSVC & Borland compilers by default when
45 #     #including things in Boost.  It's important to note that setting
46 #     Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
47 #     should you need this feature.  Automatic linking typically uses static
48 #     libraries with a few exceptions (Boost.Python is one).
49 #
50 #     Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
51 #     more details.  Adding a target_link_libraries() as shown in the example
52 #     above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
53 #     gets set to OFF.  It is suggested you avoid automatic linking since it
54 #     will make your application less portable.
55 #
56 # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
57 #
58 # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
59 # boost version numbers that should be taken into account when searching
60 # for Boost. Unfortunately boost puts the version number into the
61 # actual filename for the libraries, so this variable will certainly be needed
62 # in the future when new Boost versions are released.
63 #
64 # Currently this module searches for the following version numbers:
65 # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
66 # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
67 # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0,
68 # 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0,
69 # 1.49, 1.49.0, 1.50, 1.50.0, 1.51, 1.51.0, 1.52, 1.52.0,
70 # 1.53, 1.53.0, 1.54, 1.54.0, 1.55, 1.55.0, 1.56, 1.56.0
71 #
72 # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
73 # add both 1.x and 1.x.0 as shown above.  Official Boost include directories
74 # omit the 3rd version number from include paths if it is 0 although not all
75 # binary Boost releases do so.
76 #
77 # set(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0")
78 #
79 # ===================================== ============= ========================
80 #
81 # Variables used by this module, they can change the default behaviour and
82 # need to be set before calling find_package:
83 #
84 #   Boost_USE_MULTITHREADED      Can be set to OFF to use the non-multithreaded
85 #                                boost libraries.  If not specified, defaults
86 #                                to ON.
87 #
88 #   Boost_USE_STATIC_LIBS        Can be set to ON to force the use of the static
89 #                                boost libraries. Defaults to OFF.
90 #
91 #   Boost_NO_SYSTEM_PATHS        Set to TRUE to suppress searching in system
92 #                                paths (or other locations outside of BOOST_ROOT
93 #                                or BOOST_INCLUDEDIR).  Useful when specifying
94 #                                BOOST_ROOT. Defaults to OFF.
95 #                                  [Since CMake 2.8.3]
96 #
97 #   Boost_NO_BOOST_CMAKE         Do not do a find_package call in config mode
98 #                                before searching for a regular boost install.
99 #                                This will avoid finding boost-cmake installs.
100 #                                Defaults to OFF.
101 #                                  [Since CMake 2.8.6]
102 #
103 #   Boost_USE_STATIC_RUNTIME     If enabled, searches for boost libraries
104 #                                linked against a static C++ standard library
105 #                                ('s' ABI tag). This option should be set to
106 #                                ON or OFF because the default behavior
107 #                                if not specified is platform dependent
108 #                                for backwards compatibility.
109 #                                  [Since CMake 2.8.3]
110 #
111 #   Boost_USE_DEBUG_PYTHON       If enabled, searches for boost libraries
112 #                                compiled against a special debug build of
113 #                                Python ('y' ABI tag). Defaults to OFF.
114 #                                  [Since CMake 2.8.3]
115 #
116 #   Boost_USE_STLPORT            If enabled, searches for boost libraries
117 #                                compiled against the STLPort standard
118 #                                library ('p' ABI tag). Defaults to OFF.
119 #                                  [Since CMake 2.8.3]
120 #
121 #   Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
122 #                                If enabled, searches for boost libraries
123 #                                compiled against the deprecated STLPort
124 #                                "native iostreams" feature ('n' ABI tag).
125 #                                Defaults to OFF.
126 #                                  [Since CMake 2.8.3]
127 #
128 # Other Variables used by this module which you may want to set.
129 #
130 #   Boost_ADDITIONAL_VERSIONS    A list of version numbers to use for searching
131 #                                the boost include directory.  Please see
132 #                                the documentation above regarding this
133 #                                annoying, but necessary variable :(
134 #
135 #   Boost_DEBUG                  Set this to TRUE to enable debugging output
136 #                                of FindBoost.cmake if you are having problems.
137 #                                Please enable this before filing any bug
138 #                                reports.
139 #
140 #   Boost_DETAILED_FAILURE_MSG   FindBoost doesn't output detailed information
141 #                                about why it failed or how to fix the problem
142 #                                unless this is set to TRUE or the REQUIRED
143 #                                keyword is specified in find_package().
144 #                                  [Since CMake 2.8.0]
145 #
146 #   Boost_COMPILER               Set this to the compiler suffix used by Boost
147 #                                (e.g. "-gcc43") if FindBoost has problems finding
148 #                                the proper Boost installation
149 #
150 #   Boost_THREADAPI                When building boost.thread, sometimes the name of the
151 #                                library contains an additional "pthread" or "win32"
152 #                                string known as the threadapi.  This can happen when
153 #                                compiling against pthreads on Windows or win32 threads
154 #                                on Cygwin.  You may specify this variable and if set
155 #                                when FindBoost searches for the Boost threading library
156 #                                it will first try to match the threadapi you specify.
157 #                                  For Example: libboost_thread_win32-mgw45-mt-1_43.a
158 #                                might be found if you specified "win32" here before
159 #                                falling back on libboost_thread-mgw45-mt-1_43.a.
160 #                                  [Since CMake 2.8.3]
161 #
162 #   Boost_REALPATH               Resolves symbolic links for discovered boost libraries
163 #                                to assist with packaging.  For example, instead of
164 #                                Boost_SYSTEM_LIBRARY_RELEASE being resolved to
165 #                                "/usr/lib/libboost_system.so" it would be
166 #                                "/usr/lib/libboost_system.so.1.42.0" instead.
167 #                                This does not affect linking and should not be
168 #                                enabled unless the user needs this information.
169 #                                  [Since CMake 2.8.3]
170 #
171
172
173 #
174 # These last three variables are available also as environment variables:
175 # Also, note they are completely UPPERCASE, except Boost_DIR.
176 #
177 #   Boost_DIR or                 The preferred installation prefix for searching for
178 #   BOOST_ROOT or BOOSTROOT      Boost.  Set this if the module has problems finding
179 #                                the proper Boost installation.
180 #
181 #                                Note that Boost_DIR behaves exactly as <package>_DIR
182 #                                variables are documented to behave in find_package's
183 #                                Config mode.  That is, if it is set as a -D argument
184 #                                to CMake, it must point to the location of the
185 #                                BoostConfig.cmake or Boost-config.cmake file.  If it
186 #                                is set as an environment variable, it must point to
187 #                                the root of the boost installation.  BOOST_ROOT and
188 #                                BOOSTROOT, on the other hand, will point to the root
189 #                                in either case.
190 #
191 #                                To prevent falling back on the system paths, set
192 #                                Boost_NO_SYSTEM_PATHS to true.
193 #
194 #                                To avoid finding boost-cmake installations, set
195 #                                Boost_NO_BOOST_CMAKE to true.
196 #
197 #   BOOST_INCLUDEDIR             Set this to the include directory of Boost, if the
198 #                                module has problems finding the proper Boost installation
199 #
200 #   BOOST_LIBRARYDIR             Set this to the lib directory of Boost, if the
201 #                                module has problems finding the proper Boost installation
202 #
203 # Variables defined by this module:
204 #
205 #   Boost_FOUND                         System has Boost, this means the include dir was
206 #                                       found, as well as all the libraries specified in
207 #                                       the COMPONENTS list.
208 #
209 #   Boost_INCLUDE_DIRS                  Boost include directories: not cached
210 #
211 #   Boost_INCLUDE_DIR                   This is almost the same as above, but this one is
212 #                                       cached and may be modified by advanced users
213 #
214 #   Boost_LIBRARIES                     Link to these to use the Boost libraries that you
215 #                                       specified: not cached
216 #
217 #   Boost_LIBRARY_DIRS                  The path to where the Boost library files are.
218 #
219 #   Boost_VERSION                       The version number of the boost libraries that
220 #                                       have been found, same as in version.hpp from Boost
221 #
222 #   Boost_LIB_VERSION                   The version number in filename form as
223 #                                       it's appended to the library filenames
224 #
225 #   Boost_MAJOR_VERSION                 major version number of boost
226 #   Boost_MINOR_VERSION                 minor version number of boost
227 #   Boost_SUBMINOR_VERSION              subminor version number of boost
228 #
229 #   Boost_LIB_DIAGNOSTIC_DEFINITIONS    [WIN32 Only] You can call
230 #                                       add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
231 #                                       to have diagnostic information about Boost's
232 #                                       automatic linking outputted during compilation time.
233 #
234 # For each component you specify in find_package(), the following (UPPER-CASE)
235 # variables are set.  You can use these variables if you would like to pick and
236 # choose components for your targets instead of just using Boost_LIBRARIES.
237 #
238 #   Boost_${COMPONENT}_FOUND            True IF the Boost library "component" was found.
239 #
240 #   Boost_${COMPONENT}_LIBRARY          Contains the libraries for the specified Boost
241 #                                       "component" (includes debug and optimized keywords
242 #                                       when needed).
243
244 #=============================================================================
245 # Copyright 2006-2009 Kitware, Inc.
246 # Copyright 2006-2008 Andreas Schneider <mail@cynapses.org>
247 # Copyright 2007      Wengo
248 # Copyright 2007      Mike Jackson
249 # Copyright 2008      Andreas Pakulat <apaku@gmx.de>
250 # Copyright 2008-2012 Philip Lowman <philip@yhbt.com>
251 #
252 # Distributed under the OSI-approved BSD License (the "License");
253 # see accompanying file Copyright.txt for details.
254 #
255 # This software is distributed WITHOUT ANY WARRANTY; without even the
256 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
257 # See the License for more information.
258 #=============================================================================
259 # (To distribute this file outside of CMake, substitute the full
260 #  License text for the above reference.)
261
262
263 #-------------------------------------------------------------------------------
264 # Before we go searching, check whether boost-cmake is avaialble, unless the
265 # user specifically asked NOT to search for boost-cmake.
266 #
267 # If Boost_DIR is set, this behaves as any find_package call would. If not,
268 # it looks at BOOST_ROOT and BOOSTROOT to find Boost.
269 #
270 if (NOT Boost_NO_BOOST_CMAKE)
271   # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives,
272   # since these are more conventional for Boost.
273   if ("$ENV{Boost_DIR}" STREQUAL "")
274     if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
275       set(ENV{Boost_DIR} $ENV{BOOST_ROOT})
276     elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "")
277       set(ENV{Boost_DIR} $ENV{BOOSTROOT})
278     endif()
279   endif()
280
281   # Do the same find_package call but look specifically for the CMake version.
282   # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
283   # need to delegate them to this find_package call.
284   find_package(Boost QUIET NO_MODULE)
285
286   # If we found boost-cmake, then we're done.  Print out what we found.
287   # Otherwise let the rest of the module try to find it.
288   if (Boost_FOUND)
289     message("Boost ${Boost_FIND_VERSION} found.")
290     if (Boost_FIND_COMPONENTS)
291       message("Found Boost components:")
292       message("   ${Boost_FIND_COMPONENTS}")
293     endif()
294     return()
295   endif()
296 endif()
297
298
299 #-------------------------------------------------------------------------------
300 #  FindBoost functions & macros
301 #
302
303 ############################################
304 #
305 # Check the existence of the libraries.
306 #
307 ############################################
308 # This macro was taken directly from the FindQt4.cmake file that is included
309 # with the CMake distribution. This is NOT my work. All work was done by the
310 # original authors of the FindQt4.cmake file. Only minor modifications were
311 # made to remove references to Qt and make this file more generally applicable
312 # And ELSE/ENDIF pairs were removed for readability.
313 #########################################################################
314
315 macro(_Boost_ADJUST_LIB_VARS basename)
316   if(Boost_INCLUDE_DIR )
317     if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
318       # if the generator supports configuration types then set
319       # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
320       if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
321         set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
322       else()
323         # if there are no configuration types and CMAKE_BUILD_TYPE has no value
324         # then just use the release libraries
325         set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
326       endif()
327       # FIXME: This probably should be set for both cases
328       set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
329     endif()
330
331     # if only the release version was found, set the debug variable also to the release version
332     if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
333       set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
334       set(Boost_${basename}_LIBRARY       ${Boost_${basename}_LIBRARY_RELEASE})
335       set(Boost_${basename}_LIBRARIES     ${Boost_${basename}_LIBRARY_RELEASE})
336     endif()
337
338     # if only the debug version was found, set the release variable also to the debug version
339     if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
340       set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
341       set(Boost_${basename}_LIBRARY         ${Boost_${basename}_LIBRARY_DEBUG})
342       set(Boost_${basename}_LIBRARIES       ${Boost_${basename}_LIBRARY_DEBUG})
343     endif()
344
345     # If the debug & release library ends up being the same, omit the keywords
346     if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG})
347       set(Boost_${basename}_LIBRARY   ${Boost_${basename}_LIBRARY_RELEASE} )
348       set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
349     endif()
350
351     if(Boost_${basename}_LIBRARY)
352       set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
353
354       # Remove superfluous "debug" / "optimized" keywords from
355       # Boost_LIBRARY_DIRS
356       foreach(_boost_my_lib ${Boost_${basename}_LIBRARY})
357         get_filename_component(_boost_my_lib_path "${_boost_my_lib}" PATH)
358         list(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
359       endforeach()
360       list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
361
362       set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
363       set(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
364     endif()
365
366   endif()
367   # Make variables changeble to the advanced user
368   mark_as_advanced(
369       Boost_${basename}_LIBRARY
370       Boost_${basename}_LIBRARY_RELEASE
371       Boost_${basename}_LIBRARY_DEBUG
372   )
373 endmacro()
374
375 #-------------------------------------------------------------------------------
376
377 #
378 # Runs compiler with "-dumpversion" and parses major/minor
379 # version with a regex.
380 #
381 function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
382
383   exec_program(${CMAKE_CXX_COMPILER}
384     ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
385     OUTPUT_VARIABLE _boost_COMPILER_VERSION
386   )
387   string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
388     _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
389
390   set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
391 endfunction()
392
393 #
394 # A convenience function for marking desired components
395 # as found or not
396 #
397 function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no)
398   foreach(COMPONENT ${Boost_FIND_COMPONENTS})
399     string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
400     set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE)
401   endforeach()
402 endfunction()
403
404 #
405 # Take a list of libraries with "thread" in it
406 # and prepend duplicates with "thread_${Boost_THREADAPI}"
407 # at the front of the list
408 #
409 function(_Boost_PREPEND_LIST_WITH_THREADAPI _output)
410   set(_orig_libnames ${ARGN})
411   string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames "${_orig_libnames}")
412   set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE)
413 endfunction()
414
415 #
416 # If a library is found, replace its cache entry with its REALPATH
417 #
418 function(_Boost_SWAP_WITH_REALPATH _library _docstring)
419   if(${_library})
420     get_filename_component(_boost_filepathreal ${${_library}} REALPATH)
421     unset(${_library} CACHE)
422     set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}")
423   endif()
424 endfunction()
425
426 function(_Boost_CHECK_SPELLING _var)
427   if(${_var})
428     string(TOUPPER ${_var} _var_UC)
429     message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling.  The proper spelling is ${_var_UC}.")
430   endif()
431 endfunction()
432
433 # Guesses Boost's compiler prefix used in built library names
434 # Returns the guess by setting the variable pointed to by _ret
435 function(_Boost_GUESS_COMPILER_PREFIX _ret)
436   if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
437       OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
438       OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
439     if(WIN32)
440       set (_boost_COMPILER "-iw")
441     else()
442       set (_boost_COMPILER "-il")
443     endif()
444   elseif (MSVC11)
445     set(_boost_COMPILER "-vc110")
446   elseif (MSVC10)
447     set(_boost_COMPILER "-vc100")
448   elseif (MSVC90)
449     set(_boost_COMPILER "-vc90")
450   elseif (MSVC80)
451     set(_boost_COMPILER "-vc80")
452   elseif (MSVC71)
453     set(_boost_COMPILER "-vc71")
454   elseif (MSVC70) # Good luck!
455     set(_boost_COMPILER "-vc7") # yes, this is correct
456   elseif (MSVC60) # Good luck!
457     set(_boost_COMPILER "-vc6") # yes, this is correct
458   elseif (BORLAND)
459     set(_boost_COMPILER "-bcb")
460   elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
461     set(_boost_COMPILER "-sw")
462   elseif (MINGW)
463     if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
464         set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
465     else()
466       _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
467       set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
468     endif()
469   elseif (UNIX)
470     if (CMAKE_COMPILER_IS_GNUCXX)
471       if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
472         set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
473       else()
474         _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
475         # Determine which version of GCC we have.
476         if(APPLE)
477           if(Boost_MINOR_VERSION)
478             if(${Boost_MINOR_VERSION} GREATER 35)
479               # In Boost 1.36.0 and newer, the mangled compiler name used
480               # on Mac OS X/Darwin is "xgcc".
481               set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
482             else()
483               # In Boost <= 1.35.0, there is no mangled compiler name for
484               # the Mac OS X/Darwin version of GCC.
485               set(_boost_COMPILER "")
486             endif()
487           else()
488             # We don't know the Boost version, so assume it's
489             # pre-1.36.0.
490             set(_boost_COMPILER "")
491           endif()
492         else()
493           set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
494         endif()
495       endif()
496     endif ()
497   else()
498     # TODO at least Boost_DEBUG here?
499     set(_boost_COMPILER "")
500   endif()
501   set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
502 endfunction()
503
504 #
505 # End functions/macros
506 #
507 #-------------------------------------------------------------------------------
508
509 #-------------------------------------------------------------------------------
510 # main.
511 #-------------------------------------------------------------------------------
512
513 if(NOT DEFINED Boost_USE_MULTITHREADED)
514     set(Boost_USE_MULTITHREADED TRUE)
515 endif()
516
517 # Check the version of Boost against the requested version.
518 if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
519   message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34")
520 endif()
521
522 if(Boost_FIND_VERSION_EXACT)
523   # The version may appear in a directory with or without the patch
524   # level, even when the patch level is non-zero.
525   set(_boost_TEST_VERSIONS
526     "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
527     "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
528 else()
529   # The user has not requested an exact version.  Among known
530   # versions, find those that are acceptable to the user request.
531   set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
532     "1.56.0" "1.56" "1.55.0" "1.55" "1.54.0" "1.54"
533     "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
534     "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
535     "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"
536     "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
537     "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
538     "1.34" "1.33.1" "1.33.0" "1.33")
539   set(_boost_TEST_VERSIONS)
540   if(Boost_FIND_VERSION)
541     set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
542     # Select acceptable versions.
543     foreach(version ${_Boost_KNOWN_VERSIONS})
544       if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
545         # This version is high enough.
546         list(APPEND _boost_TEST_VERSIONS "${version}")
547       elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
548         # This version is a short-form for the requested version with
549         # the patch level dropped.
550         list(APPEND _boost_TEST_VERSIONS "${version}")
551       endif()
552     endforeach()
553   else()
554     # Any version is acceptable.
555     set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
556   endif()
557 endif()
558
559 # The reason that we failed to find Boost. This will be set to a
560 # user-friendly message when we fail to find some necessary piece of
561 # Boost.
562 set(Boost_ERROR_REASON)
563
564   if(Boost_DEBUG)
565     # Output some of their choices
566     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
567                    "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
568     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
569                    "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
570     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
571                    "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
572     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
573                    "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
574     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
575                    "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
576     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
577                    "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
578   endif()
579
580   if(WIN32)
581     # In windows, automatic linking is performed, so you do not have
582     # to specify the libraries.  If you are linking to a dynamic
583     # runtime, then you can choose to link to either a static or a
584     # dynamic Boost library, the default is to do a static link.  You
585     # can alter this for a specific library "whatever" by defining
586     # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
587     # linked dynamically.  Alternatively you can force all Boost
588     # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
589
590     # This feature can be disabled for Boost library "whatever" by
591     # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
592     # BOOST_ALL_NO_LIB.
593
594     # If you want to observe which libraries are being linked against
595     # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
596     # code to emit a #pragma message each time a library is selected
597     # for linking.
598     set(Boost_LIB_DIAGNOSTIC_DEFINITIONS
599       "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
600   endif()
601
602   set(_boost_INCLUDE_SEARCH_DIRS_SYSTEM
603     C:/boost/include
604     C:/boost
605     "$ENV{ProgramFiles}/boost/include"
606     "$ENV{ProgramFiles}/boost"
607     /sw/local/include
608   )
609
610   _Boost_CHECK_SPELLING(Boost_ROOT)
611   _Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
612   _Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
613
614   # If BOOST_ROOT was defined in the environment, use it.
615   if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "")
616     set(BOOST_ROOT $ENV{Boost_DIR})
617   endif()
618
619   # If BOOST_ROOT was defined in the environment, use it.
620   if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
621     set(BOOST_ROOT $ENV{BOOST_ROOT})
622   endif()
623
624   # If BOOSTROOT was defined in the environment, use it.
625   if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
626     set(BOOST_ROOT $ENV{BOOSTROOT})
627   endif()
628
629   # If BOOST_INCLUDEDIR was defined in the environment, use it.
630   if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
631     set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
632   endif()
633
634   # If BOOST_LIBRARYDIR was defined in the environment, use it.
635   if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
636     set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
637   endif()
638
639   if( BOOST_ROOT )
640     file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
641   endif()
642
643   if(Boost_DEBUG)
644     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
645                    "Declared as CMake or Environmental Variables:")
646     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
647                    "  BOOST_ROOT = ${BOOST_ROOT}")
648     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
649                    "  BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
650     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
651                    "  BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
652     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
653                    "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
654   endif()
655
656   if( Boost_NO_SYSTEM_PATHS)
657     set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
658   else()
659     set(_boost_INCLUDE_SEARCH_DIRS ${_boost_INCLUDE_SEARCH_DIRS_SYSTEM})
660   endif()
661
662   if( BOOST_ROOT )
663     set(_boost_INCLUDE_SEARCH_DIRS
664       ${BOOST_ROOT}/include
665       ${BOOST_ROOT}
666       ${_boost_INCLUDE_SEARCH_DIRS})
667   endif()
668
669   # prepend BOOST_INCLUDEDIR to search path if specified
670   if( BOOST_INCLUDEDIR )
671     file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
672     set(_boost_INCLUDE_SEARCH_DIRS
673       ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
674   endif()
675
676   # ------------------------------------------------------------------------
677   #  Search for Boost include DIR
678   # ------------------------------------------------------------------------
679   # Try to find Boost by stepping backwards through the Boost versions
680   # we know about.
681   if( NOT Boost_INCLUDE_DIR )
682     # Build a list of path suffixes for each version.
683     set(_boost_PATH_SUFFIXES)
684     foreach(_boost_VER ${_boost_TEST_VERSIONS})
685       # Add in a path suffix, based on the required version, ideally
686       # we could read this from version.hpp, but for that to work we'd
687       # need to know the include dir already
688       set(_boost_BOOSTIFIED_VERSION)
689
690       # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
691       if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
692           string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
693             _boost_BOOSTIFIED_VERSION ${_boost_VER})
694       elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
695           string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
696             _boost_BOOSTIFIED_VERSION ${_boost_VER})
697       endif()
698
699       list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
700       list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
701
702     endforeach()
703
704     if(Boost_DEBUG)
705       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
706                      "Include debugging info:")
707       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
708                      "  _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
709       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
710                      "  _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
711     endif()
712
713     # Look for a standard boost header file.
714     find_path(Boost_INCLUDE_DIR
715       NAMES         boost/config.hpp
716       HINTS         ${_boost_INCLUDE_SEARCH_DIRS}
717       PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
718       ${_boost_FIND_OPTIONS}
719       )
720   endif()
721
722   # ------------------------------------------------------------------------
723   #  Extract version information from version.hpp
724   # ------------------------------------------------------------------------
725
726   if(Boost_INCLUDE_DIR)
727     # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
728     # Read the whole file:
729     #
730     set(BOOST_VERSION 0)
731     set(BOOST_LIB_VERSION "")
732     file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ")
733     if(Boost_DEBUG)
734       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
735                      "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
736     endif()
737
738     string(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
739     string(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
740     unset(_boost_VERSION_HPP_CONTENTS)
741
742     set(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
743     set(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
744
745     if(NOT "${Boost_VERSION}" STREQUAL "0")
746       math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
747       math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
748       math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
749
750       set(Boost_ERROR_REASON
751           "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
752     endif()
753     if(Boost_DEBUG)
754       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
755                      "version.hpp reveals boost "
756                      "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
757     endif()
758   else()
759     set(Boost_ERROR_REASON
760       "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.")
761   endif()
762
763   # ------------------------------------------------------------------------
764   #  Suffix initialization and compiler suffix detection.
765   # ------------------------------------------------------------------------
766
767   # Setting some more suffixes for the library
768   set(Boost_LIB_PREFIX "")
769   if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN)
770     set(Boost_LIB_PREFIX "lib")
771   endif()
772
773   if (Boost_COMPILER)
774     set(_boost_COMPILER ${Boost_COMPILER})
775     if(Boost_DEBUG)
776       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
777                      "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
778     endif()
779   else()
780     # Attempt to guess the compiler suffix
781     # NOTE: this is not perfect yet, if you experience any issues
782     # please report them and use the Boost_COMPILER variable
783     # to work around the problems.
784     _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER)
785     if(Boost_DEBUG)
786       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
787         "guessed _boost_COMPILER = ${_boost_COMPILER}")
788     endif()
789   endif()
790
791   set (_boost_MULTITHREADED "-mt")
792   if( NOT Boost_USE_MULTITHREADED )
793     set (_boost_MULTITHREADED "")
794   endif()
795   if(Boost_DEBUG)
796     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
797       "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
798   endif()
799
800   #======================
801   # Systematically build up the Boost ABI tag
802   # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
803   set( _boost_RELEASE_ABI_TAG "-")
804   set( _boost_DEBUG_ABI_TAG   "-")
805   # Key       Use this library when:
806   #  s        linking statically to the C++ standard library and
807   #           compiler runtime support libraries.
808   if(Boost_USE_STATIC_RUNTIME)
809     set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
810     set( _boost_DEBUG_ABI_TAG   "${_boost_DEBUG_ABI_TAG}s")
811   endif()
812   #  g        using debug versions of the standard and runtime
813   #           support libraries
814   if(WIN32)
815     if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
816             OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
817       set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
818     endif()
819   endif()
820   #  y        using special debug build of python
821   if(Boost_USE_DEBUG_PYTHON)
822     set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y")
823   endif()
824   #  d        using a debug version of your code
825   set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d")
826   #  p        using the STLport standard library rather than the
827   #           default one supplied with your compiler
828   if(Boost_USE_STLPORT)
829     set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p")
830     set( _boost_DEBUG_ABI_TAG   "${_boost_DEBUG_ABI_TAG}p")
831   endif()
832   #  n        using the STLport deprecated "native iostreams" feature
833   if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
834     set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n")
835     set( _boost_DEBUG_ABI_TAG   "${_boost_DEBUG_ABI_TAG}n")
836   endif()
837
838   if(Boost_DEBUG)
839     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
840       "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
841     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
842       "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
843   endif()
844
845   # ------------------------------------------------------------------------
846   #  Begin finding boost libraries
847   # ------------------------------------------------------------------------
848
849   if(BOOST_ROOT)
850     set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS
851       ${BOOST_ROOT}/lib
852       ${BOOST_ROOT}/stage/lib)
853   endif()
854   set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS
855     ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS}
856     ${Boost_INCLUDE_DIR}/lib
857     ${Boost_INCLUDE_DIR}/../lib
858     ${Boost_INCLUDE_DIR}/stage/lib
859   )
860   set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM
861     C:/boost/lib
862     C:/boost
863     "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
864     "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
865     "$ENV{ProgramFiles}/boost/lib"
866     "$ENV{ProgramFiles}/boost"
867     /sw/local/lib
868   )
869   set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS})
870   if( Boost_NO_SYSTEM_PATHS )
871     set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
872   else()
873     list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM})
874   endif()
875
876   # prepend BOOST_LIBRARYDIR to search path if specified
877   if( BOOST_LIBRARYDIR )
878     file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
879     set(_boost_LIBRARY_SEARCH_DIRS
880       ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS})
881   endif()
882
883   if(Boost_DEBUG)
884     message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
885       "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}")
886   endif()
887
888   # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
889   if( Boost_USE_STATIC_LIBS )
890     set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
891     if(WIN32)
892       set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
893     else()
894       set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
895     endif()
896   endif()
897
898   # We want to use the tag inline below without risking double dashes
899   if(_boost_RELEASE_ABI_TAG)
900     if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
901       set(_boost_RELEASE_ABI_TAG "")
902     endif()
903   endif()
904   if(_boost_DEBUG_ABI_TAG)
905     if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
906       set(_boost_DEBUG_ABI_TAG "")
907     endif()
908   endif()
909
910   # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
911   # on WIN32 was to:
912   #  1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
913   #  2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
914   # We maintain this behavior since changing it could break people's builds.
915   # To disable the ambiguous behavior, the user need only
916   # set Boost_USE_STATIC_RUNTIME either ON or OFF.
917   set(_boost_STATIC_RUNTIME_WORKAROUND false)
918   if(WIN32 AND Boost_USE_STATIC_LIBS)
919     if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
920       set(_boost_STATIC_RUNTIME_WORKAROUND true)
921     endif()
922   endif()
923
924   # On versions < 1.35, remove the System library from the considered list
925   # since it wasn't added until 1.35.
926   if(Boost_VERSION AND Boost_FIND_COMPONENTS)
927      if(Boost_VERSION LESS 103500)
928        list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
929      endif()
930   endif()
931
932   foreach(COMPONENT ${Boost_FIND_COMPONENTS})
933     string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
934     set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
935     set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
936     set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
937
938     set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
939     set( _boost_docstring_debug   "Boost ${COMPONENT} library (debug)")
940
941     #
942     # Find RELEASE libraries
943     #
944     set(_boost_RELEASE_NAMES
945       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
946       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
947       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
948       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
949       ${Boost_LIB_PREFIX}boost_${COMPONENT} )
950     if(_boost_STATIC_RUNTIME_WORKAROUND)
951       set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
952       list(APPEND _boost_RELEASE_NAMES
953         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
954         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
955         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
956         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
957     endif()
958     if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
959        _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
960     endif()
961     if(Boost_DEBUG)
962       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
963                      "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
964     endif()
965     find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
966         NAMES ${_boost_RELEASE_NAMES}
967         HINTS ${_boost_LIBRARY_SEARCH_DIRS}
968         ${_boost_FIND_OPTIONS}
969         DOC "${_boost_docstring_release}"
970     )
971
972     #
973     # Find DEBUG libraries
974     #
975     set(_boost_DEBUG_NAMES
976       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
977       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
978       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
979       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
980       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
981       ${Boost_LIB_PREFIX}boost_${COMPONENT} )
982     if(_boost_STATIC_RUNTIME_WORKAROUND)
983       set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
984       list(APPEND _boost_DEBUG_NAMES
985         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
986         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
987         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
988         ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
989     endif()
990     if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
991        _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
992     endif()
993     if(Boost_DEBUG)
994       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
995                      "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
996     endif()
997     find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
998         NAMES ${_boost_DEBUG_NAMES}
999         HINTS ${_boost_LIBRARY_SEARCH_DIRS}
1000         ${_boost_FIND_OPTIONS}
1001         DOC "${_boost_docstring_debug}"
1002     )
1003
1004     if(Boost_REALPATH)
1005       _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
1006       _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG   "${_boost_docstring_debug}"  )
1007     endif()
1008
1009     _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
1010
1011   endforeach()
1012
1013   # Restore the original find library ordering
1014   if( Boost_USE_STATIC_LIBS )
1015     set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
1016   endif()
1017
1018   # ------------------------------------------------------------------------
1019   #  End finding boost libraries
1020   # ------------------------------------------------------------------------
1021
1022   # ------------------------------------------------------------------------
1023   #  Begin long process of determining Boost_FOUND, starting with version
1024   #  number checks, followed by
1025   #  TODO: Ideally the version check logic should happen prior to searching
1026   #        for libraries...
1027   # ------------------------------------------------------------------------
1028
1029   set(Boost_INCLUDE_DIRS
1030     ${Boost_INCLUDE_DIR}
1031   )
1032
1033   set(Boost_FOUND FALSE)
1034   if(Boost_INCLUDE_DIR)
1035     set( Boost_FOUND TRUE )
1036
1037     if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
1038       set( Boost_FOUND FALSE )
1039       set(_Boost_VERSION_AGE "old")
1040     elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
1041       if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
1042         set( Boost_FOUND FALSE )
1043         set(_Boost_VERSION_AGE "old")
1044       elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
1045         if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
1046           set( Boost_FOUND FALSE )
1047           set(_Boost_VERSION_AGE "old")
1048         endif()
1049       endif()
1050     endif()
1051
1052     if (NOT Boost_FOUND)
1053       _Boost_MARK_COMPONENTS_FOUND(OFF)
1054     endif()
1055
1056     if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
1057       # If the user requested an exact version of Boost, check
1058       # that. We already know that the Boost version we have is >= the
1059       # requested version.
1060       set(_Boost_VERSION_AGE "new")
1061
1062       # If the user didn't specify a patchlevel, it's 0.
1063       if (NOT Boost_FIND_VERSION_PATCH)
1064         set(Boost_FIND_VERSION_PATCH 0)
1065       endif ()
1066
1067       # We'll set Boost_FOUND true again if we have an exact version match.
1068       set(Boost_FOUND FALSE)
1069       _Boost_MARK_COMPONENTS_FOUND(OFF)
1070       if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
1071         if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
1072           if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
1073             set( Boost_FOUND TRUE )
1074             _Boost_MARK_COMPONENTS_FOUND(ON)
1075           endif()
1076         endif()
1077       endif()
1078     endif ()
1079
1080     if(NOT Boost_FOUND)
1081       # State that we found a version of Boost that is too new or too old.
1082       set(Boost_ERROR_REASON
1083         "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
1084       if (Boost_FIND_VERSION_PATCH)
1085         set(Boost_ERROR_REASON
1086           "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
1087       endif ()
1088       if (NOT Boost_FIND_VERSION_EXACT)
1089         set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
1090       endif ()
1091       set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
1092     endif ()
1093
1094     # Always check for missing components
1095     set(_boost_CHECKED_COMPONENT FALSE)
1096     set(_Boost_MISSING_COMPONENTS "")
1097     foreach(COMPONENT ${Boost_FIND_COMPONENTS})
1098       string(TOUPPER ${COMPONENT} COMPONENT)
1099       set(_boost_CHECKED_COMPONENT TRUE)
1100       if(NOT Boost_${COMPONENT}_FOUND)
1101         string(TOLOWER ${COMPONENT} COMPONENT)
1102         list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
1103         set( Boost_FOUND FALSE)
1104       endif()
1105     endforeach()
1106
1107     if(Boost_DEBUG)
1108       message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
1109     endif()
1110
1111     if (_Boost_MISSING_COMPONENTS)
1112       # We were unable to find some libraries, so generate a sensible
1113       # error message that lists the libraries we were unable to find.
1114       set(Boost_ERROR_REASON
1115         "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
1116       foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
1117         set(Boost_ERROR_REASON
1118           "${Boost_ERROR_REASON}        boost_${COMPONENT}\n")
1119       endforeach()
1120
1121       list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
1122       list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
1123       if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
1124         set(Boost_ERROR_REASON
1125           "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
1126       else ()
1127         set(Boost_ERROR_REASON
1128           "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
1129       endif ()
1130     endif ()
1131
1132     if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
1133       # Compatibility Code for backwards compatibility with CMake
1134       # 2.4's FindBoost module.
1135
1136       # Look for the boost library path.
1137       # Note that the user may not have installed any libraries
1138       # so it is quite possible the Boost_LIBRARY_DIRS may not exist.
1139       set(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
1140
1141       if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
1142         get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
1143       endif()
1144
1145       if("${_boost_LIB_DIR}" MATCHES "/include$")
1146         # Strip off the trailing "/include" in the path.
1147         get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
1148       endif()
1149
1150       if(EXISTS "${_boost_LIB_DIR}/lib")
1151         set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
1152       else()
1153         if(EXISTS "${_boost_LIB_DIR}/stage/lib")
1154           set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
1155         else()
1156           set(_boost_LIB_DIR "")
1157         endif()
1158       endif()
1159
1160       if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
1161         set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
1162       endif()
1163
1164     endif()
1165
1166   else()
1167     set( Boost_FOUND FALSE)
1168   endif()
1169
1170   # ------------------------------------------------------------------------
1171   #  Notification to end user about what was found
1172   # ------------------------------------------------------------------------
1173
1174   if(Boost_FOUND)
1175       if(NOT Boost_FIND_QUIETLY)
1176         message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
1177         if(Boost_FIND_COMPONENTS)
1178           message(STATUS "Found the following Boost libraries:")
1179         endif()
1180       endif()
1181       foreach( COMPONENT  ${Boost_FIND_COMPONENTS} )
1182         string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
1183         if( Boost_${UPPERCOMPONENT}_FOUND )
1184           if(NOT Boost_FIND_QUIETLY)
1185             message (STATUS "  ${COMPONENT}")
1186           endif()
1187           set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
1188         endif()
1189       endforeach()
1190   else()
1191     if(Boost_FIND_REQUIRED)
1192       message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
1193     else()
1194       if(NOT Boost_FIND_QUIETLY)
1195         # we opt not to automatically output Boost_ERROR_REASON here as
1196         # it could be quite lengthy and somewhat imposing in its requests
1197         # Since Boost is not always a required dependency we'll leave this
1198         # up to the end-user.
1199         if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
1200           message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
1201         else()
1202           message(STATUS "Could NOT find Boost")
1203         endif()
1204       endif()
1205     endif()
1206   endif()
1207
1208   # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
1209   mark_as_advanced(Boost_INCLUDE_DIR
1210       Boost_INCLUDE_DIRS
1211       Boost_LIBRARY_DIRS
1212   )