summaryrefslogtreecommitdiffstats
path: root/Modules/FindBoost.cmake
diff options
context:
space:
mode:
authorDouglas Gregor <doug.gregor@gmail.com>2008-07-03 19:49:41 (GMT)
committerDouglas Gregor <doug.gregor@gmail.com>2008-07-03 19:49:41 (GMT)
commit566647d34f705eeee10815cbdb6b00a170a8aef3 (patch)
tree9e8ba927e3c8d7e68e553854abd0ec4e64a1f0a1 /Modules/FindBoost.cmake
parente245d4ea114b61fb3243adc16e82e269ac15ed86 (diff)
downloadCMake-566647d34f705eeee10815cbdb6b00a170a8aef3.zip
CMake-566647d34f705eeee10815cbdb6b00a170a8aef3.tar.gz
CMake-566647d34f705eeee10815cbdb6b00a170a8aef3.tar.bz2
ENH: Cleanup FindBoost module, fixing several small bugs and providing better diagnostic information when things go wrong
Diffstat (limited to 'Modules/FindBoost.cmake')
-rw-r--r--Modules/FindBoost.cmake358
1 files changed, 203 insertions, 155 deletions
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 8526875..c2224a0 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -41,7 +41,7 @@
# version set this variable to a list of
# strings, where each string contains a number, i.e.
# SET(Boost_ADDITIONAL_VERSIONS "0.99.0" "1.35.0")
-# BOOST_ROOT Preferred installation prefix for searching for Boost,
+# BOOST_ROOT or BOOSTROOT Preferred installation prefix for searching for Boost,
# set this if the module has problems finding the proper Boost installation
# BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
# module has problems finding the proper Boost installation
@@ -91,20 +91,28 @@
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
-
-# this module required CMake 2.5 for the Boost_FIND_VERSION stuff
-
-# this must not be done in find modules, it changes the policy settings, which may have been
-# set in the projects cmake files.
-# beside that this module comes with cmake, so the cmake version is always correct, Alex
-# CMAKE_MINIMUM_REQUIRED(VERSION "2.6" FATAL_ERROR)
-
-# MESSAGE(STATUS "Finding Boost libraries.... ")
-
-OPTION(Boost_USE_MULTITHREADED "Use the multithreaded versions of the boost libraries" ON)
-
-SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.36.1" "1.36.0" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33" )
-
+OPTION(Boost_USE_MULTITHREADED
+ "Use the multithreaded versions of the Boost libraries" ON)
+
+if (Boost_FIND_VERSION_EXACT)
+ if (Boost_FIND_VERSION_PATCH)
+ set( _boost_TEST_VERSIONS
+ "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}")
+ else (Boost_FIND_VERSION_PATCH)
+ set( _boost_TEST_VERSIONS
+ "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.0"
+ "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
+ endif (Boost_FIND_VERSION_PATCH)
+else (Boost_FIND_VERSION_EXACT)
+ set( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
+ "1.36.1" "1.36.0" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1"
+ "1.33.0" "1.33" )
+endif (Boost_FIND_VERSION_EXACT)
+
+# The reason that we failed to find Boost. This will be set to a
+# user-friendly message when we fail to find some necessary piece of
+# Boost.
+set(Boost_ERROR_REASON)
############################################
#
@@ -119,8 +127,6 @@ SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.36.1" "1.36.0" "1.35.1
MACRO (_Boost_ADJUST_LIB_VARS basename)
IF (Boost_INCLUDE_DIR )
- #MESSAGE(STATUS "Adjusting ${basename} ")
-
IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
@@ -152,7 +158,7 @@ MACRO (_Boost_ADJUST_LIB_VARS basename)
SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH)
SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
- SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Was the boost boost ${basename} library found")
+ SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
ENDIF (Boost_${basename}_LIBRARY)
ENDIF (Boost_INCLUDE_DIR )
@@ -197,120 +203,113 @@ ELSE (_boost_IN_CACHE)
# Need to search for boost
IF(WIN32)
- # In windows, automatic linking is performed, so you do not have to specify the libraries.
- # If you are linking to a dynamic runtime, then you can choose to link to either a static or a
- # dynamic Boost library, the default is to do a static link. You can alter this for a specific
- # library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to
- # be linked dynamically. Alternatively you can force all Boost libraries to dynamic link by
- # defining BOOST_ALL_DYN_LINK.
+ # In windows, automatic linking is performed, so you do not have
+ # to specify the libraries. If you are linking to a dynamic
+ # runtime, then you can choose to link to either a static or a
+ # dynamic Boost library, the default is to do a static link. You
+ # can alter this for a specific library "whatever" by defining
+ # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
+ # linked dynamically. Alternatively you can force all Boost
+ # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
- # This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB,
- # or for all of Boost by defining BOOST_ALL_NO_LIB.
+ # This feature can be disabled for Boost library "whatever" by
+ # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
+ # BOOST_ALL_NO_LIB.
- # If you want to observe which libraries are being linked against then defining
- # BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time
- # a library is selected for linking.
- SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
+ # If you want to observe which libraries are being linked against
+ # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
+ # code to emit a #pragma message each time a library is selected
+ # for linking.
+ SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
+ "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
ENDIF(WIN32)
-
SET(_boost_INCLUDE_SEARCH_DIRS
C:/boost/include
- "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}"
- # D: is very often the cdrom drive, IF you don't have a
- # cdrom inserted it will popup a very annoying dialog
- #D:/boost/include
+ "${ENV}{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}"
/sw/local/include
)
SET(_boost_LIBRARIES_SEARCH_DIRS
C:/boost/lib
- "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib"
+ "${ENV}{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib"
/sw/local/lib
)
- IF( NOT $ENV{BOOST_ROOT} STREQUAL "" )
- SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS})
- SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_ROOT}/lib ${_boost_INCLUDE_SEARCH_DIRS})
- ENDIF( NOT $ENV{BOOST_ROOT} STREQUAL "" )
+ # If BOOST_ROOT was defined in the environment, use it.
+ if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
+ set(BOOST_ROOT $ENV{BOOST_ROOT})
+ endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
+
+ # If BOOSTROOT was defined in the environment, use it.
+ if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
+ set(BOOST_ROOT $ENV{BOOSTROOT})
+ endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
+ # If BOOST_INCLUDEDIR was defined in the environment, use it.
IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
- SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
+ set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
+ # If BOOST_LIBRARYDIR was defined in the environment, use it.
IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
- SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_LIBRARYDIR} ${_boost_INCLUDE_SEARCH_DIRS})
+ set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
IF( BOOST_ROOT )
- IF( WIN32 )
- SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS})
- ELSE( WIN32 )
- SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS})
- ENDIF( WIN32 )
- SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_ROOT}/lib ${_boost_LIBRARIES_SEARCH_DIRS})
+ file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
+ SET(_boost_INCLUDE_SEARCH_DIRS
+ ${BOOST_ROOT}/include
+ ${BOOST_ROOT}
+ ${_boost_INCLUDE_SEARCH_DIRS})
+ SET(_boost_LIBRARIES_SEARCH_DIRS
+ ${BOOST_ROOT}/lib
+ ${BOOST_ROOT}/stage/lib
+ ${_boost_LIBRARIES_SEARCH_DIRS})
ENDIF( BOOST_ROOT )
IF( BOOST_INCLUDEDIR )
- SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
+ file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
+ SET(_boost_INCLUDE_SEARCH_DIRS
+ ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
ENDIF( BOOST_INCLUDEDIR )
IF( BOOST_LIBRARYDIR )
- SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
+ file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
+ SET(_boost_LIBRARIES_SEARCH_DIRS
+ ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
ENDIF( BOOST_LIBRARYDIR )
- #Try first in our own include search paths (e.g. BOOST_ROOT)
+ # Try to find Boost by stepping backwards through the Boost versions
+ # we know about.
FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
IF( NOT Boost_INCLUDE_DIR )
-
- # Add in a path suffix, based on the required version, ideally we could
- # read this from version.hpp, but for that to work we'd need to know the include
- # dir already
- SET(_boost_PATH_SUFFIX
- boost-${_boost_VER}
- )
+ # Add in a path suffix, based on the required version, ideally
+ # we could read this from version.hpp, but for that to work we'd
+ # need to know the include dir already
+ if (WIN32 AND NOT CYGWIN)
+ set(_boost_PATH_SUFFIX boost_${_boost_VER})
+ else (WIN32 AND NOT CYGWIN)
+ set(_boost_PATH_SUFFIX boost-${_boost_VER})
+ endif (WIN32 AND NOT CYGWIN)
IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
- STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
+ STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
+ _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
- STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
+ STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
+ _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
-
FIND_PATH(Boost_INCLUDE_DIR
NAMES boost/config.hpp
- PATHS ${_boost_INCLUDE_SEARCH_DIRS}
+ HINTS ${_boost_INCLUDE_SEARCH_DIRS}
PATH_SUFFIXES ${_boost_PATH_SUFFIX}
- NO_DEFAULT_PATH
)
ENDIF( NOT Boost_INCLUDE_DIR )
ENDFOREACH(_boost_VER)
- # If nothing is found search again using system default paths
- FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
- IF( NOT Boost_INCLUDE_DIR )
-
- # Add in a path suffix, based on the required version, ideally we could
- # read this from version.hpp, but for that to work we'd need to know the include
- # dir already
- SET(_boost_PATH_SUFFIX
- boost-${_boost_VER}
- )
-
- IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
- STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
- ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
- STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
- ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
-
- FIND_PATH(Boost_INCLUDE_DIR
- NAMES boost/config.hpp
- PATH_SUFFIXES ${_boost_PATH_SUFFIX}
- )
-
- ENDIF( NOT Boost_INCLUDE_DIR )
- ENDFOREACH(_boost_VER)
IF(Boost_INCLUDE_DIR)
# Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
# Read the whole file:
@@ -329,52 +328,53 @@ ELSE (_boost_IN_CACHE)
MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
-
+
+ set(Boost_ERROR_REASON
+ "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
+ ELSE(Boost_INCLUDE_DIR)
+ set(Boost_ERROR_REASON
+ "${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.")
ENDIF(Boost_INCLUDE_DIR)
-
- #Setting some more suffixes for the library
+ # Setting some more suffixes for the library
SET (Boost_LIB_PREFIX "")
IF ( WIN32 AND Boost_USE_STATIC_LIBS )
SET (Boost_LIB_PREFIX "lib")
ENDIF ( WIN32 AND Boost_USE_STATIC_LIBS )
SET (_boost_COMPILER "-gcc")
- IF (MSVC71)
- SET (_boost_COMPILER "-vc71")
- ENDIF(MSVC71)
- IF (MSVC80)
- SET (_boost_COMPILER "-vc80")
- ENDIF(MSVC80)
IF (MSVC90)
SET (_boost_COMPILER "-vc90")
- ENDIF (MSVC90)
+ ELSEIF (MSVC80)
+ SET (_boost_COMPILER "-vc80")
+ ELSEIF (MSVC71)
+ SET (_boost_COMPILER "-vc71")
+ ENDIF(MSVC90)
IF (MINGW)
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
- ARGS --version
+ ARGS -dumpversion
OUTPUT_VARIABLE _boost_COMPILER_VERSION
)
- STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2"
+ STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
_boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
ENDIF(MINGW)
- IF (CYGWIN)
- SET (_boost_COMPILER "-gcc")
- ENDIF (CYGWIN)
IF (UNIX)
IF (APPLE)
- SET (_boost_COMPILER "")
+ # Due to a quirk in Boost.Build, there is no compiler name
+ # mangled into library names on Mac OS X/Darwin.
+ SET (_boost_COMPILER "")
ELSE (APPLE)
IF (NOT CMAKE_COMPILER_IS_GNUCC)
- # This is for the intel compiler
+ # We assume that we have the Intel compiler.
SET (_boost_COMPILER "-il")
ELSE (NOT CMAKE_COMPILER_IS_GNUCC)
- #find out the version of gcc being used.
+ # Determine which version of GCC we have.
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
- ARGS --version
+ ARGS -dumpversion
OUTPUT_VARIABLE _boost_COMPILER_VERSION
)
- STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2"
+ STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
_boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
@@ -423,39 +423,18 @@ ELSE (_boost_IN_CACHE)
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
${Boost_LIB_PREFIX}boost_${COMPONENT}
- PATHS ${_boost_LIBRARIES_SEARCH_DIRS}
- NO_DEFAULT_PATH
+ HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
)
- IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} )
- FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
- NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}
- )
- ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} )
-
FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
- PATHS ${_boost_LIBRARIES_SEARCH_DIRS}
- NO_DEFAULT_PATH
+ HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
)
- IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} )
- FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
- NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
- ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
- )
- ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} )
_Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
IF( Boost_USE_STATIC_LIBS )
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
@@ -469,33 +448,103 @@ ELSE (_boost_IN_CACHE)
${Boost_INCLUDE_DIR}
)
- # MESSAGE(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
- # MESSAGE(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
-
SET(Boost_FOUND FALSE)
IF(Boost_INCLUDE_DIR)
SET( Boost_FOUND TRUE )
- IF( Boost_FIND_VERSION_MAJOR AND Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
- SET( Boost_FOUND FALSE )
- ELSE( Boost_FIND_VERSION_MAJOR AND Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
- IF( Boost_FIND_VERSION_MINOR AND Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
- SET( Boost_FOUND FALSE )
- ELSE( Boost_FIND_VERSION_MINOR AND Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
- IF( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
- SET( Boost_FOUND FALSE )
- ENDIF( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
- ENDIF( Boost_FIND_VERSION_MINOR AND Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
- ENDIF( Boost_FIND_VERSION_MAJOR AND Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
- set(_boost_CHECKED_COMPONENT FALSE)
- FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
- STRING(TOUPPER ${COMPONENT} COMPONENT)
- set(_boost_CHECKED_COMPONENT TRUE)
- IF(NOT Boost_${COMPONENT}_FOUND)
- SET( Boost_FOUND FALSE)
- ENDIF(NOT Boost_${COMPONENT}_FOUND)
- ENDFOREACH(COMPONENT)
+
+ # Check the version of Boost against the requested version.
+ if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
+ 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")
+ endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
+ if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
+ set( Boost_FOUND FALSE )
+ set(_Boost_VERSION_AGE "old")
+ elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
+ if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
+ set( Boost_FOUND FALSE )
+ set(_Boost_VERSION_AGE "old")
+ elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
+ if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
+ set( Boost_FOUND FALSE )
+ set(_Boost_VERSION_AGE "old")
+ endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
+ endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
+ endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
+
+ if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
+ # If the user requested an exact version of Boost, check
+ # that. We already know that the Boost version we have is >= the
+ # requested version.
+ set(_Boost_VERSION_AGE "new")
+
+ # If the user didn't specify a patchlevel, it's 0.
+ if (NOT Boost_FIND_VERSION_PATCH)
+ set(Boost_FIND_VERSION_PATCH 0)
+ endif (NOT Boost_FIND_VERSION_PATCH)
+
+ # We'll set Boost_FOUND true again if we have an exact version match.
+ set(Boost_FOUND FALSE)
+ if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
+ if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
+ if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
+ set( Boost_FOUND TRUE )
+ endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
+ endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
+ endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
+ endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
+
+ if(NOT Boost_FOUND)
+ # State that we found a version of Boost that is too new or too old.
+ set(Boost_ERROR_REASON
+ "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
+ if (Boost_FIND_VERSION_PATCH)
+ set(Boost_ERROR_REASON
+ "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
+ endif (Boost_FIND_VERSION_PATCH)
+ if (NOT Boost_FIND_VERSION_EXACT)
+ set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
+ endif (NOT Boost_FIND_VERSION_EXACT)
+ set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
+ endif (NOT Boost_FOUND)
+
+ if (Boost_FOUND)
+ set(_boost_CHECKED_COMPONENT FALSE)
+ set(_Boost_MISSING_COMPONENTS)
+ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ string(TOUPPER ${COMPONENT} COMPONENT)
+ set(_boost_CHECKED_COMPONENT TRUE)
+ if(NOT Boost_${COMPONENT}_FOUND)
+ string(TOLOWER ${COMPONENT} COMPONENT)
+ list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
+ set( Boost_FOUND FALSE)
+ endif(NOT Boost_${COMPONENT}_FOUND)
+ endforeach(COMPONENT)
+ endif (Boost_FOUND)
+
+ if (_Boost_MISSING_COMPONENTS)
+ # We were unable to find some libraries, so generate a sensible
+ # error message that lists the libraries we were unable to find.
+ set(Boost_ERROR_REASON
+ "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
+ foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
+ set(Boost_ERROR_REASON
+ "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
+ endforeach(COMPONENT)
+
+ list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
+ list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
+ if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
+ set(Boost_ERROR_REASON
+ "${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.")
+ else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
+ set(Boost_ERROR_REASON
+ "${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.")
+ endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
+ endif (_Boost_MISSING_COMPONENTS)
+
IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
- # Compatibility Code for backwards compatibility with CMake 2.4
+ # Compatibility Code for backwards compatibility with CMake
+ # 2.4's FindBoost module.
# Look for the boost library path.
# Note that the user may not have installed any libraries
@@ -549,8 +598,7 @@ ELSE (_boost_IN_CACHE)
ENDFOREACH(COMPONENT)
ELSE (Boost_FOUND)
IF (Boost_FIND_REQUIRED)
- MESSAGE(STATUS "Boost version required: ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}, found: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
- MESSAGE(FATAL_ERROR "Couldn't find the Boost libraries and/or include directory, or the version found is too old. Please install the Boost libraries AND development packages. You can set BOOST_ROOT, BOOST_INCLUDEDIR and BOOST_LIBRARYDIR to help find Boost.")
+ message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
ENDIF(Boost_FIND_REQUIRED)
ENDIF(Boost_FOUND)