source: calamares/trunk/fuentes/CMakeModules/BoostPython3.cmake @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 2.8 KB
Line 
1# On Ubuntu 14.04, the libboost-python1.54-dev package comes with one library
2# for each Python version:
3# libboost_python-py27.so
4# libboost_python-py33.so
5# libboost_python-py34.so
6#
7# Boost upstream however installs Boost.Python3 libboost_python3.so, which is
8# what FindBoost.cmake is looking for. It looks for a library named
9# "libboost_${component}.so".
10#
11# On Gentoo instead, the >=dev-libs/boost-1.54 package provides boost library
12# with a name like:
13# libboost_python-2.7.so
14# libboost_python-3.3.so
15# libboost_python-3.4.so
16# depending on what python's targets you selected during install
17#
18# find_boost_python3() tries to find the package with different component
19# names. By default it tries "python3", "python-py$suffix" and
20# "python-$dotsuffix", where suffix is based on the `python_version` argument.
21# One can supply a custom component name by setting the
22# `CALAMARES_BOOST_PYTHON3_COMPONENT` variable at CMake time.
23set( CALAMARES_BOOST_PYTHON3_COMPONENT python3 CACHE STRING
24    "Name of the Boost.Python component. If Boost.Python is installed as
25    libboost_python-foo.so then this variable should be set to 'python-foo'."
26)
27
28include(FindPackageHandleStandardArgs)
29
30macro( _find_boost_python3_int boost_version componentname found_var )
31    foreach( _fbp_name ${CALAMARES_BOOST_PYTHON3_COMPONENT} ${componentname} )
32        find_package( Boost ${boost_version} QUIET COMPONENTS ${_fbp_name} )
33        string( TOUPPER ${_fbp_name} _fbp_uc_name )
34        if( Boost_${_fbp_uc_name}_FOUND )
35            set( ${found_var} ${_fbp_uc_name} )
36            break()
37        endif()
38    endforeach()
39endmacro()
40
41macro( find_boost_python3 boost_version python_version found_var )
42    set( ${found_var} OFF )
43    set( _fbp_found OFF )
44
45    # turns "3.4.123abc" into "34"
46    string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1\\2" _fbp_python_short_version ${python_version} )
47    _find_boost_python3_int( ${boost_version} python-py${_fbp_python_short_version} _fbp_found )
48
49    if (NOT _fbp_found)
50        # The following loop changes the searched name for Gentoo based distributions
51        # turns "3.4.123abc" into "3.4"
52        string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1.\\2" _fbp_python_short_version ${python_version} )
53        _find_boost_python3_int( ${boost_version} python-${_fbp_python_short_version} _fbp_found )
54    endif()
55
56    set( ${found_var} ${_fbp_found} )
57
58    # This is superfluous, but allows proper reporting in the features list
59    if ( _fbp_found )
60        find_package( Boost ${boost_version} COMPONENTS ${_fbp_found} )
61    else()
62        find_package( Boost ${boost_version} COMPONENTS Python )
63    endif()
64    set_package_properties(
65        Boost PROPERTIES
66        DESCRIPTION "A C++ library which enables seamless interoperability between C++ and Python 3."
67        URL "http://www.boost.org"
68    )
69endmacro()
Note: See TracBrowser for help on using the repository browser.