mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 13:45:10 +00:00
Merge branch 'pybind:master' into master
This commit is contained in:
commit
128ff3ce1e
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -37,9 +37,9 @@ jobs:
|
|||||||
- '3.10'
|
- '3.10'
|
||||||
- '3.11'
|
- '3.11'
|
||||||
- '3.12'
|
- '3.12'
|
||||||
- 'pypy-3.7'
|
|
||||||
- 'pypy-3.8'
|
- 'pypy-3.8'
|
||||||
- 'pypy-3.9'
|
- 'pypy-3.9'
|
||||||
|
- 'pypy-3.10'
|
||||||
|
|
||||||
# Items in here will either be added to the build matrix (if not
|
# Items in here will either be added to the build matrix (if not
|
||||||
# present), or add new keys to an existing matrix element if all the
|
# present), or add new keys to an existing matrix element if all the
|
||||||
|
12
.github/workflows/configure.yml
vendored
12
.github/workflows/configure.yml
vendored
@ -26,20 +26,24 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
runs-on: [ubuntu-20.04, macos-latest, windows-latest]
|
runs-on: [ubuntu-20.04, macos-latest, windows-latest]
|
||||||
arch: [x64]
|
arch: [x64]
|
||||||
cmake: ["3.23"]
|
cmake: ["3.26"]
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- runs-on: ubuntu-20.04
|
- runs-on: ubuntu-20.04
|
||||||
arch: x64
|
arch: x64
|
||||||
cmake: 3.4
|
cmake: "3.5"
|
||||||
|
|
||||||
|
- runs-on: ubuntu-20.04
|
||||||
|
arch: x64
|
||||||
|
cmake: "3.27"
|
||||||
|
|
||||||
- runs-on: macos-latest
|
- runs-on: macos-latest
|
||||||
arch: x64
|
arch: x64
|
||||||
cmake: 3.7
|
cmake: "3.7"
|
||||||
|
|
||||||
- runs-on: windows-2019
|
- runs-on: windows-2019
|
||||||
arch: x64 # x86 compilers seem to be missing on 2019 image
|
arch: x64 # x86 compilers seem to be missing on 2019 image
|
||||||
cmake: 3.18
|
cmake: "3.18"
|
||||||
|
|
||||||
name: 🐍 3.7 • CMake ${{ matrix.cmake }} • ${{ matrix.runs-on }}
|
name: 🐍 3.7 • CMake ${{ matrix.cmake }} • ${{ matrix.runs-on }}
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
4
.github/workflows/pip.yml
vendored
4
.github/workflows/pip.yml
vendored
@ -102,13 +102,13 @@ jobs:
|
|||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
|
|
||||||
- name: Publish standard package
|
- name: Publish standard package
|
||||||
uses: pypa/gh-action-pypi-publish@v1.8.6
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.pypi_password }}
|
password: ${{ secrets.pypi_password }}
|
||||||
packages-dir: standard/
|
packages-dir: standard/
|
||||||
|
|
||||||
- name: Publish global package
|
- name: Publish global package
|
||||||
uses: pypa/gh-action-pypi-publish@v1.8.6
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.pypi_password_global }}
|
password: ${{ secrets.pypi_password_global }}
|
||||||
packages-dir: global/
|
packages-dir: global/
|
||||||
|
@ -25,7 +25,7 @@ repos:
|
|||||||
|
|
||||||
# Clang format the codebase automatically
|
# Clang format the codebase automatically
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: "v16.0.4"
|
rev: "v16.0.6"
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
types_or: [c++, c, cuda]
|
types_or: [c++, c, cuda]
|
||||||
@ -38,14 +38,14 @@ repos:
|
|||||||
|
|
||||||
# Ruff, the Python auto-correcting linter written in Rust
|
# Ruff, the Python auto-correcting linter written in Rust
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.0.270
|
rev: v0.0.276
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: ["--fix", "--show-fixes"]
|
args: ["--fix", "--show-fixes"]
|
||||||
|
|
||||||
# Check static types with mypy
|
# Check static types with mypy
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: "v1.3.0"
|
rev: "v1.4.1"
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
args: []
|
args: []
|
||||||
@ -84,7 +84,7 @@ repos:
|
|||||||
|
|
||||||
# Also code format the docs
|
# Also code format the docs
|
||||||
- repo: https://github.com/asottile/blacken-docs
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
rev: "1.13.0"
|
rev: "1.14.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
@ -124,7 +124,7 @@ repos:
|
|||||||
# Use tools/codespell_ignore_lines_from_errors.py
|
# Use tools/codespell_ignore_lines_from_errors.py
|
||||||
# to rebuild .codespell-ignore-lines
|
# to rebuild .codespell-ignore-lines
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
rev: "v2.2.4"
|
rev: "v2.2.5"
|
||||||
hooks:
|
hooks:
|
||||||
- id: codespell
|
- id: codespell
|
||||||
exclude: ".supp$"
|
exclude: ".supp$"
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
# All rights reserved. Use of this source code is governed by a
|
# All rights reserved. Use of this source code is governed by a
|
||||||
# BSD-style license that can be found in the LICENSE file.
|
# BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.22)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.22)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.22)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Avoid infinite recursion if tests include this as a subdirectory
|
# Avoid infinite recursion if tests include this as a subdirectory
|
||||||
|
@ -18,7 +18,7 @@ information, see :doc:`/compiling`.
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5...3.26)
|
||||||
project(example)
|
project(example)
|
||||||
|
|
||||||
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`
|
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`
|
||||||
|
@ -549,3 +549,7 @@ The ``name`` property returns the name of the enum value as a unicode string.
|
|||||||
...
|
...
|
||||||
|
|
||||||
By default, these are omitted to conserve space.
|
By default, these are omitted to conserve space.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Contrary to Python customs, enum values from the wrappers should not be compared using ``is``, but with ``==`` (see `#1177 <https://github.com/pybind/pybind11/issues/1177>`_ for background).
|
||||||
|
@ -241,7 +241,7 @@ extension module can be created with just a few lines of code:
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4...3.18)
|
cmake_minimum_required(VERSION 3.5...3.26)
|
||||||
project(example LANGUAGES CXX)
|
project(example LANGUAGES CXX)
|
||||||
|
|
||||||
add_subdirectory(pybind11)
|
add_subdirectory(pybind11)
|
||||||
@ -261,6 +261,9 @@ PyPI integration, can be found in the [cmake_example]_ repository.
|
|||||||
.. versionchanged:: 2.6
|
.. versionchanged:: 2.6
|
||||||
CMake 3.4+ is required.
|
CMake 3.4+ is required.
|
||||||
|
|
||||||
|
.. versionchanged:: 2.11
|
||||||
|
CMake 3.5+ is required.
|
||||||
|
|
||||||
Further information can be found at :doc:`cmake/index`.
|
Further information can be found at :doc:`cmake/index`.
|
||||||
|
|
||||||
pybind11_add_module
|
pybind11_add_module
|
||||||
@ -495,7 +498,7 @@ You can use these targets to build complex applications. For example, the
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5...3.26)
|
||||||
project(example LANGUAGES CXX)
|
project(example LANGUAGES CXX)
|
||||||
|
|
||||||
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
||||||
@ -553,7 +556,7 @@ information about usage in C++, see :doc:`/advanced/embedding`.
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4...3.18)
|
cmake_minimum_required(VERSION 3.5...3.26)
|
||||||
project(example LANGUAGES CXX)
|
project(example LANGUAGES CXX)
|
||||||
|
|
||||||
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
||||||
|
@ -284,7 +284,8 @@ There are three possible solutions:
|
|||||||
COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better,
|
COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better,
|
||||||
3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead
|
3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead
|
||||||
of the old, deprecated search tools, and these modules are much better at
|
of the old, deprecated search tools, and these modules are much better at
|
||||||
finding the correct Python.
|
finding the correct Python. If FindPythonLibs/Interp are not available
|
||||||
|
(CMake 3.27+), then this will be ignored and FindPython will be used.
|
||||||
3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python.
|
3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python.
|
||||||
However, you will have to use the target-based system, and do more setup
|
However, you will have to use the target-based system, and do more setup
|
||||||
yourself, because it does not know about or include things that depend on
|
yourself, because it does not know about or include things that depend on
|
||||||
|
@ -8,6 +8,20 @@ to a new version. But it goes into more detail. This includes things like
|
|||||||
deprecated APIs and their replacements, build system changes, general code
|
deprecated APIs and their replacements, build system changes, general code
|
||||||
modernization and other useful information.
|
modernization and other useful information.
|
||||||
|
|
||||||
|
.. _upgrade-guide-2.11:
|
||||||
|
|
||||||
|
v2.11
|
||||||
|
=====
|
||||||
|
|
||||||
|
* The minimum version of CMake is now 3.5. A future version will likely move to
|
||||||
|
requiring something like CMake 3.15. Note that CMake 3.27 is removing the
|
||||||
|
long-deprecated support for ``FindPythonInterp`` if you set 3.27 as the
|
||||||
|
minimum or maximum supported version. To prepare for that future, CMake 3.15+
|
||||||
|
using ``FindPython`` or setting ``PYBIND11_FINDPYTHON`` is highly recommended,
|
||||||
|
otherwise pybind11 will automatically switch to using ``FindPython`` if
|
||||||
|
``FindPythonInterp`` is not available.
|
||||||
|
|
||||||
|
|
||||||
.. _upgrade-guide-2.9:
|
.. _upgrade-guide-2.9:
|
||||||
|
|
||||||
v2.9
|
v2.9
|
||||||
|
@ -5,20 +5,17 @@
|
|||||||
# All rights reserved. Use of this source code is governed by a
|
# All rights reserved. Use of this source code is governed by a
|
||||||
# BSD-style license that can be found in the LICENSE file.
|
# BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.21)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.21)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Only needed for CMake < 3.5 support
|
|
||||||
include(CMakeParseArguments)
|
|
||||||
|
|
||||||
# Filter out items; print an optional message if any items filtered. This ignores extensions.
|
# Filter out items; print an optional message if any items filtered. This ignores extensions.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
|
@ -6,4 +6,4 @@ numpy==1.22.2; platform_python_implementation!="PyPy" and python_version>="3.10"
|
|||||||
pytest==7.0.0
|
pytest==7.0.0
|
||||||
pytest-timeout
|
pytest-timeout
|
||||||
scipy==1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
scipy==1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
||||||
scipy==1.8.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
scipy==1.10.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
|
@ -85,7 +85,7 @@ TEST_SUBMODULE(class_, m) {
|
|||||||
.def_static("new_instance", &NoConstructor::new_instance, "Return an instance");
|
.def_static("new_instance", &NoConstructor::new_instance, "Return an instance");
|
||||||
|
|
||||||
py::class_<NoConstructorNew>(m, "NoConstructorNew")
|
py::class_<NoConstructorNew>(m, "NoConstructorNew")
|
||||||
.def(py::init([](const NoConstructorNew &self) { return self; })) // Need a NOOP __init__
|
.def(py::init([]() { return nullptr; })) // Need a NOOP __init__
|
||||||
.def_static("__new__",
|
.def_static("__new__",
|
||||||
[](const py::object &) { return NoConstructorNew::new_instance(); });
|
[](const py::object &) { return NoConstructorNew::new_instance(); });
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# Built-in in CMake 3.5+
|
|
||||||
include(CMakeParseArguments)
|
|
||||||
|
|
||||||
add_custom_target(test_cmake_build)
|
add_custom_target(test_cmake_build)
|
||||||
|
|
||||||
function(pybind11_add_build_test name)
|
function(pybind11_add_build_test name)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_installed_embed CXX)
|
project(test_installed_embed CXX)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(test_installed_module CXX)
|
project(test_installed_module CXX)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_installed_function CXX)
|
project(test_installed_function CXX)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_installed_target CXX)
|
project(test_installed_target CXX)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_embed CXX)
|
project(test_subdirectory_embed CXX)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_function CXX)
|
project(test_subdirectory_function CXX)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
|
||||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
# the behavior using the following workaround:
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.26)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.26)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_target CXX)
|
project(test_subdirectory_target CXX)
|
||||||
|
@ -163,11 +163,19 @@ endif()
|
|||||||
|
|
||||||
# --------------------- Python specifics -------------------------
|
# --------------------- Python specifics -------------------------
|
||||||
|
|
||||||
|
# CMake 3.27 removes the classic FindPythonInterp if CMP0148 is NEW
|
||||||
|
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||||
|
set(_pybind11_missing_old_python "OLD")
|
||||||
|
else()
|
||||||
|
cmake_policy(GET CMP0148 _pybind11_missing_old_python)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check to see which Python mode we are in, new, old, or no python
|
# Check to see which Python mode we are in, new, old, or no python
|
||||||
if(PYBIND11_NOPYTHON)
|
if(PYBIND11_NOPYTHON)
|
||||||
set(_pybind11_nopython ON)
|
set(_pybind11_nopython ON)
|
||||||
elseif(
|
elseif(
|
||||||
PYBIND11_FINDPYTHON
|
_pybind11_missing_old_python STREQUAL "NEW"
|
||||||
|
OR PYBIND11_FINDPYTHON
|
||||||
OR Python_FOUND
|
OR Python_FOUND
|
||||||
OR Python2_FOUND
|
OR Python2_FOUND
|
||||||
OR Python3_FOUND)
|
OR Python3_FOUND)
|
||||||
|
@ -63,7 +63,9 @@ Modes
|
|||||||
|
|
||||||
There are two modes provided; classic, which is built on the old Python
|
There are two modes provided; classic, which is built on the old Python
|
||||||
discovery packages in CMake, or the new FindPython mode, which uses FindPython
|
discovery packages in CMake, or the new FindPython mode, which uses FindPython
|
||||||
from 3.12+ forward (3.15+ _highly_ recommended).
|
from 3.12+ forward (3.15+ _highly_ recommended). If you set the minimum or
|
||||||
|
maximum version of CMake to 3.27+, then FindPython is the default (since
|
||||||
|
FindPythonInterp/FindPythonLibs has been removed via policy `CMP0148`).
|
||||||
|
|
||||||
New FindPython mode
|
New FindPython mode
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
Loading…
Reference in New Issue
Block a user