3 #################################
4 ## Boost is a required library
6 # setup the boost static linkage
8 set(Boost_USE_STATIC_LIBS "ON")
9 add_definitions(-DBOOST_PYTHON_STATIC_LIB)
11 set(Boost_USE_STATIC_LIBS "OFF")
14 # setup some additional boost versions so that the newest versions of boost will be found
15 set(Boost_ADDITIONAL_VERSIONS "1.53.0;1.52.0;1.51.0;1.50.0;1.49.0;1.48.0;1.47.0;1.46;1.46.0;1.45.1;1.45.0;1.45;1.44.1;1.44.0;1.44;1.43.1;1.43.0;1.43;1.42.1;1.42.0;1.42;1.41.0;1.41;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38")
17 # When BOOST_ROOT is specified, make sure that we find the one the user intends
18 if ((BOOST_ROOT OR NOT $ENV{BOOST_ROOT} STREQUAL "") OR NOT $ENV{BOOSTROOT} STREQUAL "" OR NOT $ENV{Boost_DIR} STREQUAL "")
19 set(Boost_NO_SYSTEM_PATHS ON)
22 # try python-X.Y lib naming (gentoo style) first
23 set(BOOST_PYTHON_COMPONENT "python-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
25 set(REQUIRED_BOOST_COMPONENTS thread filesystem ${BOOST_PYTHON_COMPONENT} signals program_options unit_test_framework iostreams serialization)
27 message(STATUS "First attempt to find boost, it's OK if it fails")
28 # first, see if we can get any supported version of Boost
29 find_package(Boost 1.32.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS})
31 # if python is not found, try looking for python or python3
32 string(TOUPPER ${BOOST_PYTHON_COMPONENT} UPPER_BOOST_PYTHON_COMPONENT )
33 if (NOT Boost_${UPPER_BOOST_PYTHON_COMPONENT}_FOUND)
34 message(STATUS "Python ${BOOST_PYTHON_COMPONENT} not found, trying python or python3")
35 list(REMOVE_ITEM REQUIRED_BOOST_COMPONENTS ${BOOST_PYTHON_COMPONENT})
37 if (PYTHON_VERSION VERSION_GREATER 3)
38 SET(BOOST_PYTHON_COMPONENT "python3")
40 SET(BOOST_PYTHON_COMPONENT "python")
43 list(APPEND REQUIRED_BOOST_COMPONENTS ${BOOST_PYTHON_COMPONENT})
46 # if we get boost 1.35 or greator, we need to get the system library too
47 if (Boost_MINOR_VERSION GREATER 34)
48 list(APPEND REQUIRED_BOOST_COMPONENTS "system")
51 find_package(Boost 1.32.0 COMPONENTS REQUIRED ${REQUIRED_BOOST_COMPONENTS})
53 # add include directories
54 include_directories(${Boost_INCLUDE_DIR})
56 # hide variables the user doesn't need to see
57 mark_as_advanced(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
58 mark_as_advanced(Boost_DIR)