CMake: use modern FindPython and FindBoost
This commit is contained in:
parent
ab0a33ceae
commit
62de4eb8bf
@ -155,7 +155,7 @@ set(QT_VERSION 5.15.0)
|
||||
set(YAMLCPP_VERSION 0.5.1)
|
||||
set(ECM_VERSION 5.18)
|
||||
set(PYTHONLIBS_VERSION 3.6)
|
||||
set(BOOSTPYTHON_VERSION 1.67.0)
|
||||
set(BOOSTPYTHON_VERSION 1.72.0)
|
||||
|
||||
### CMAKE SETUP
|
||||
#
|
||||
@ -343,18 +343,17 @@ if(NOT KF5Crash_FOUND)
|
||||
set(BUILD_KF5Crash OFF)
|
||||
endif()
|
||||
|
||||
# TODO:3.3: Use FindPython3 instead
|
||||
find_package(PythonInterp ${PYTHONLIBS_VERSION})
|
||||
find_package(Python ${PYTHONLIBS_VERSION} COMPONENTS Interpreter Development)
|
||||
set_package_properties(
|
||||
PythonInterp
|
||||
Python
|
||||
PROPERTIES
|
||||
DESCRIPTION "Python 3 interpreter."
|
||||
DESCRIPTION "Python3 interpreter."
|
||||
URL "https://python.org"
|
||||
PURPOSE "Python 3 interpreter for certain tests."
|
||||
PURPOSE "Python3 interpreter for certain tests."
|
||||
)
|
||||
|
||||
set(_schema_explanation "")
|
||||
if(PYTHONINTERP_FOUND)
|
||||
if(Python_Interpreter_FOUND)
|
||||
if(BUILD_SCHEMA_TESTING)
|
||||
# The configuration validator script has some dependencies,
|
||||
# and if they are not installed, don't run. If errors out
|
||||
@ -363,7 +362,7 @@ if(PYTHONINTERP_FOUND)
|
||||
set(_validator_deps ${CALAMARES_CONFIGVALIDATOR_RESULT})
|
||||
else()
|
||||
exec_program(
|
||||
${PYTHON_EXECUTABLE}
|
||||
Python::Interpreter
|
||||
ARGS
|
||||
"${CMAKE_SOURCE_DIR}/ci/configvalidator.py"
|
||||
-x
|
||||
@ -388,27 +387,12 @@ else()
|
||||
endif()
|
||||
add_feature_info(yaml-schema BUILD_SCHEMA_TESTING "Validate YAML (config files) with schema.${_schema_explanation}")
|
||||
|
||||
find_package(PythonLibs ${PYTHONLIBS_VERSION})
|
||||
set_package_properties(
|
||||
PythonLibs
|
||||
PROPERTIES
|
||||
DESCRIPTION "C interface libraries for the Python 3 interpreter."
|
||||
URL "https://python.org"
|
||||
PURPOSE "Python 3 is used for Python job modules."
|
||||
)
|
||||
|
||||
if(PYTHONLIBS_FOUND)
|
||||
# TODO:3.3: Require Boost + CMake; sort out Boost::Python
|
||||
# Since Boost provides CMake config files (starting with Boost 1.70.
|
||||
# or so) the mess that is the Calamares find code picks the wrong
|
||||
# bits. Suppress those CMake config files, as suggested by @jmrcpn
|
||||
set(Boost_NO_BOOST_CMAKE ON)
|
||||
include(BoostPython3)
|
||||
find_boost_python3( ${BOOSTPYTHON_VERSION} ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND )
|
||||
if(Python_Development_FOUND)
|
||||
find_package( Boost ${BOOSTPYTHON_VERSION} COMPONENTS python )
|
||||
set_package_properties(Boost PROPERTIES PURPOSE "Boost.Python is used for Python job modules.")
|
||||
endif()
|
||||
|
||||
if(NOT PYTHONLIBS_FOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND)
|
||||
if(NOT Python_Development_FOUND OR NOT Boost_FOUND)
|
||||
message(STATUS "Disabling Boost::Python modules")
|
||||
set(WITH_PYTHON OFF)
|
||||
endif()
|
||||
|
@ -1,97 +0,0 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-FileCopyrightText: 2019 Kevin Kofler <kevin.kofler@chello.at>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Handles the mess that Boost::Python is before CMake 3.16 and
|
||||
# Boost 1.70 or so.
|
||||
#
|
||||
###
|
||||
#
|
||||
# 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".
|
||||
#
|
||||
# On Gentoo instead, the >=dev-libs/boost-1.54 package provides boost library
|
||||
# with a name like:
|
||||
# libboost_python-2.7.so
|
||||
# libboost_python-3.3.so
|
||||
# libboost_python-3.4.so
|
||||
# depending on what python's targets you selected during install
|
||||
#
|
||||
# On Fedora >= 30 instead, the boost-python3-devel provides boost library with a
|
||||
# name like:
|
||||
# libboost_python37.so
|
||||
# depending on what python's targets you selected during install
|
||||
#
|
||||
# find_boost_python3() tries to find the package with different component
|
||||
# names. By default it tries "python3", "python-py$suffix" and
|
||||
# "python-$dotsuffix", 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'."
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
macro( _find_boost_python3_int boost_version componentname found_var )
|
||||
foreach( _fbp_name ${CALAMARES_BOOST_PYTHON3_COMPONENT} ${componentname} )
|
||||
find_package( Boost ${boost_version} QUIET COMPONENTS ${_fbp_name} )
|
||||
string( TOUPPER ${_fbp_name} _fbp_uc_name )
|
||||
if( Boost_${_fbp_uc_name}_FOUND )
|
||||
if( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
|
||||
# No upcasing
|
||||
set( ${found_var} ${_fbp_name} )
|
||||
else()
|
||||
set( ${found_var} ${_fbp_uc_name} )
|
||||
endif()
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro( find_boost_python3 boost_version python_version found_var )
|
||||
set( ${found_var} OFF )
|
||||
set( _fbp_found OFF )
|
||||
|
||||
# turns "3.4.123abc" into "34"
|
||||
string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1\\2" _fbp_python_short_version ${python_version} )
|
||||
_find_boost_python3_int( ${boost_version} python-py${_fbp_python_short_version} _fbp_found )
|
||||
|
||||
if (NOT _fbp_found)
|
||||
_find_boost_python3_int( ${boost_version} python${_fbp_python_short_version} _fbp_found )
|
||||
endif()
|
||||
|
||||
if (NOT _fbp_found)
|
||||
# The following loop changes the searched name for Gentoo based distributions
|
||||
# turns "3.4.123abc" into "3.4"
|
||||
string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1.\\2" _fbp_python_short_version ${python_version} )
|
||||
_find_boost_python3_int( ${boost_version} python-${_fbp_python_short_version} _fbp_found )
|
||||
endif()
|
||||
|
||||
set( ${found_var} ${_fbp_found} )
|
||||
|
||||
# This is superfluous, but allows proper reporting in the features list
|
||||
if ( _fbp_found )
|
||||
find_package( Boost ${boost_version} COMPONENTS ${_fbp_found} )
|
||||
else()
|
||||
find_package( Boost ${boost_version} COMPONENTS Python )
|
||||
endif()
|
||||
set_package_properties(
|
||||
Boost PROPERTIES
|
||||
DESCRIPTION "A C++ library which enables seamless interoperability between C++ and Python 3."
|
||||
URL "http://www.boost.org"
|
||||
)
|
||||
endmacro()
|
Loading…
Reference in New Issue
Block a user