Python: use the vendored pybind11
Add a target that resembles what you would get from "normal" use of pybind11 when following the examples. Link with it. Drop Boost:Python sources from libcalamares.
This commit is contained in:
parent
35ae45e3ec
commit
5cad467a49
16
3rdparty/pybind11/CMakeLists.txt
vendored
Normal file
16
3rdparty/pybind11/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2023 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# This is a very-stripped-down way of getting the bundled pybind11
|
||||
|
||||
add_library(pybind11_headers INTERFACE)
|
||||
add_library(pybind11::headers ALIAS pybind11_headers)
|
||||
|
||||
target_include_directories(pybind11_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(pybind11_headers INTERFACE Python::Python) # Was searched-for at top-level
|
||||
|
||||
|
@ -23,8 +23,9 @@
|
||||
# WITH_<foo> : try to enable <foo> (these usually default to ON). For
|
||||
# a list of WITH_<foo> grep CMakeCache.txt after running
|
||||
# CMake once. These affect the ABI offered by Calamares.
|
||||
# - PYTHON (enable Python Job modules)
|
||||
# - QML (enable QML UI View modules)
|
||||
# - PYBIND11 (use bundled pybind11, default ON, needs WITH_PYTHON)
|
||||
# - PYTHON (enable Python Job modules, default ON if Python is found)
|
||||
# - QML (enable QML UI View modules, default ON)
|
||||
# - QT6 (use Qt6 rather than Qt5, default to OFF)
|
||||
# The WITH_* options affect the ABI of Calamares: you must
|
||||
# build (C++) modules for Calamares with the same WITH_*
|
||||
@ -80,7 +81,8 @@ option(INSTALL_POLKIT "Install Polkit configuration" ON)
|
||||
option(INSTALL_COMPLETION "Install shell completions" OFF)
|
||||
# When adding WITH_* that affects the ABI offered by libcalamares,
|
||||
# also update libcalamares/CalamaresConfig.h.in
|
||||
option(WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON)
|
||||
option(WITH_PYBIND11 "Use bundled pybind11 instead o Boost::Python" ON)
|
||||
option(WITH_PYTHON "Enable Python modules API." ON)
|
||||
option(WITH_QML "Enable QML UI options." ON)
|
||||
option(WITH_QT6 "Use Qt6 instead of Qt5" OFF)
|
||||
#
|
||||
@ -446,25 +448,30 @@ else()
|
||||
endif()
|
||||
add_feature_info(yaml-schema BUILD_SCHEMA_TESTING "Validate YAML (config files) with schema.${_schema_explanation}")
|
||||
|
||||
if(Python_Development_FOUND)
|
||||
if(NOT Python_Development_FOUND)
|
||||
message(STATUS "Disabling Python modules")
|
||||
set(WITH_PYTHON OFF)
|
||||
set(WITH_PYBIND11 OFF)
|
||||
endif()
|
||||
|
||||
if(WITH_PYTHON AND NOT WITH_PYBIND11)
|
||||
find_package(boost_python)
|
||||
if(NOT TARGET Boost::python)
|
||||
find_package(Boost ${BOOSTPYTHON_VERSION} COMPONENTS python)
|
||||
set_package_properties(Boost PROPERTIES PURPOSE "Boost.Python is used for Python job modules.")
|
||||
set_package_properties(Boost PROPERTIES
|
||||
PURPOSE "Boost.Python is used for Python job modules (because WITH_PYBIND11 is OFF)."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
else()
|
||||
message(STATUS "Found boost_python with target Boost::python")
|
||||
set(Boost_FOUND ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT Python_Development_FOUND OR NOT Boost_FOUND)
|
||||
message(STATUS "Disabling Boost::Python modules")
|
||||
set(WITH_PYTHON OFF)
|
||||
endif()
|
||||
|
||||
# Now we know the state of the ABI-options, copy them into "Calamares_"
|
||||
# prefixed variables, to match how the variables would-be-named
|
||||
# when building out-of-tree.
|
||||
set(Calamares_WITH_PYBIND11 ${WITH_PYBIND11})
|
||||
set(Calamares_WITH_PYTHON ${WITH_PYTHON})
|
||||
set(Calamares_WITH_QML ${WITH_QML})
|
||||
set(Calamares_WITH_QT6 ${WITH_QT6})
|
||||
@ -595,9 +602,13 @@ include(GNUInstallDirs)
|
||||
set(Calamares_LIBRARIES calamares)
|
||||
|
||||
add_subdirectory(3rdparty/kdsingleapplication)
|
||||
if(WITH_PYBIND11)
|
||||
add_subdirectory(3rdparty/pybind11)
|
||||
endif()
|
||||
add_subdirectory(src)
|
||||
|
||||
add_feature_info(Python ${WITH_PYTHON} "Python job modules")
|
||||
add_feature_info(Pybind11 ${WITH_PYBIND11} "Python using bundled pybind11")
|
||||
add_feature_info(Qml ${WITH_QML} "QML UI support")
|
||||
add_feature_info(Polkit ${INSTALL_POLKIT} "Install Polkit files")
|
||||
add_feature_info(KCrash ${BUILD_CRASH_REPORTING} "Crash dumps via KCrash")
|
||||
|
@ -115,8 +115,13 @@ endif()
|
||||
#
|
||||
#
|
||||
if(WITH_PYTHON)
|
||||
target_sources(calamares PRIVATE PythonHelper.cpp PythonJob.cpp PythonJobApi.cpp)
|
||||
target_link_libraries(calamares PRIVATE Python::Python Boost::python)
|
||||
if(WITH_PYBIND11)
|
||||
target_sources(calamares PRIVATE python/Api.cpp python/PythonJob.cpp)
|
||||
target_link_libraries(calamares PRIVATE Python::Python pybind11::headers)
|
||||
else()
|
||||
target_sources(calamares PRIVATE PythonHelper.cpp PythonJob.cpp PythonJobApi.cpp)
|
||||
target_link_libraries(calamares PRIVATE Python::Python Boost::python)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
### OPTIONAL GeoIP XML support
|
||||
|
Loading…
Reference in New Issue
Block a user