From 9c05ecef4d7e27cc2c286d212032c0f5df76a06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Thu, 17 Jul 2014 14:54:13 +0200 Subject: [PATCH] Fix finding of Boost.Python on Ubuntu --- CMakeLists.txt | 22 +++++++++++---------- CMakeModules/BoostPython3.cmake | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 CMakeModules/BoostPython3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fcc1bfdb..763c5843c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,25 +29,27 @@ macro_optional_find_package( PythonLibs 3.3 REQUIRED ) macro_log_feature( PYTHONLIBS_FOUND "Python" - "C interface libraries for the Python interpreter." + "C interface libraries for the Python 3 interpreter." "http://python.org" - TRUE "" - "Python is used for some Calamares job modules." + FALSE "3.3" + "Python 3 is used for some Calamares job modules." ) -macro_optional_find_package( Boost 1.55.0 COMPONENTS python3 REQUIRED ) + +include( BoostPython3 ) +find_boost_python3( 1.54.0 ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND ) macro_log_feature( - Boost_PYTHON3_FOUND + CALAMARES_BOOST_PYTHON3_FOUND "Boost.Python" - "A C++ library which enables seamless interoperability between C++ and Python." + "A C++ library which enables seamless interoperability between C++ and Python 3." "http://www.boost.org" - TRUE "" - "Boost.Python is used for interfacing with Calamares job modules written in Python." + FALSE "1.54.0" + "Boost.Python is used for interfacing with Calamares job modules written in Python 3." ) -if( Boost_PYTHON3_NOTFOUND OR PYTHONLIBS_NOTFOUND ) + +if ( PYTHONLIBS_NOTFOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND ) set( WITH_PYTHON OFF ) endif() - ### ### Calamares application info ### diff --git a/CMakeModules/BoostPython3.cmake b/CMakeModules/BoostPython3.cmake new file mode 100644 index 000000000..e0c298728 --- /dev/null +++ b/CMakeModules/BoostPython3.cmake @@ -0,0 +1,35 @@ +# On Ubuntu 14.04, the libboost-python1.54-dev package comes with one library +# for each Python version: +# libboost_python-py27.so +# libboost_python-py33.so +# libboost_python-py34.so +# +# Boost upstream however installs Boost.Python3 libboost_python3.so, which is +# what FindBoost.cmake is looking for. It looks for a library named +# "libboost_${component}.so". +# +# find_boost_python3() tries to find the package with different component names. +# By default it tries "python3" and "python-py$suffix", where suffix is based on +# the `python_version` argument. One can supply a custom component name by +# setting the `CALAMARES_BOOST_PYTHON3_COMPONENT` variable at CMake time. + +set( CALAMARES_BOOST_PYTHON3_COMPONENT python3 CACHE STRING + "Name of the Boost.Python component. If Boost.Python is installed as + libboost_python-foo.so then this variable should be set to 'python-foo'." +) + +macro( find_boost_python3 boost_version python_version found_var ) + set( ${found_var} OFF ) + + # turns "3.4.123abc" into "34" + string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1\\2" _fbp_python_short_version ${python_version} ) + + foreach( _fbp_name ${CALAMARES_BOOST_PYTHON3_COMPONENT} python-py${_fbp_python_short_version} ) + find_package( Boost ${boost_version} QUIET COMPONENTS ${_fbp_name} ) + string( TOUPPER ${_fbp_name} _fbp_uc_name ) + if( Boost_${_fbp_uc_name}_FOUND ) + set( ${found_var} ON ) + break() + endif() + endforeach() +endmacro()