Skip to content

Commit c704c1e

Browse files
committed
fix: support CMake 3.27, drop 3.4
Signed-off-by: Henry Schreiner <[email protected]>
1 parent e10da79 commit c704c1e

File tree

16 files changed

+68
-49
lines changed

16 files changed

+68
-49
lines changed

.github/workflows/configure.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,24 @@ jobs:
2626
matrix:
2727
runs-on: [ubuntu-20.04, macos-latest, windows-latest]
2828
arch: [x64]
29-
cmake: ["3.23"]
29+
cmake: ["3.26"]
3030

3131
include:
3232
- runs-on: ubuntu-20.04
3333
arch: x64
34-
cmake: 3.4
34+
cmake: "3.5"
35+
36+
- runs-on: ubuntu-20.04
37+
arch: x64
38+
cmake: "3.27"
3539

3640
- runs-on: macos-latest
3741
arch: x64
38-
cmake: 3.7
42+
cmake: "3.7"
3943

4044
- runs-on: windows-2019
4145
arch: x64 # x86 compilers seem to be missing on 2019 image
42-
cmake: 3.18
46+
cmake: "3.18"
4347

4448
name: 🐍 3.7 • CMake ${{ matrix.cmake }} • ${{ matrix.runs-on }}
4549
runs-on: ${{ matrix.runs-on }}

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# All rights reserved. Use of this source code is governed by a
66
# BSD-style license that can be found in the LICENSE file.
77

8-
cmake_minimum_required(VERSION 3.4)
8+
cmake_minimum_required(VERSION 3.5)
99

10-
# The `cmake_minimum_required(VERSION 3.4...3.22)` syntax does not work with
10+
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
1111
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
1212
# the behavior using the following workaround:
13-
if(${CMAKE_VERSION} VERSION_LESS 3.22)
13+
if(${CMAKE_VERSION} VERSION_LESS 3.26)
1414
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
1515
else()
16-
cmake_policy(VERSION 3.22)
16+
cmake_policy(VERSION 3.26)
1717
endif()
1818

1919
# Avoid infinite recursion if tests include this as a subdirectory

docs/advanced/embedding.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information, see :doc:`/compiling`.
1818

1919
.. code-block:: cmake
2020
21-
cmake_minimum_required(VERSION 3.4)
21+
cmake_minimum_required(VERSION 3.5...3.26)
2222
project(example)
2323
2424
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`

docs/compiling.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ extension module can be created with just a few lines of code:
241241

242242
.. code-block:: cmake
243243
244-
cmake_minimum_required(VERSION 3.4...3.18)
244+
cmake_minimum_required(VERSION 3.5...3.26)
245245
project(example LANGUAGES CXX)
246246
247247
add_subdirectory(pybind11)
@@ -261,6 +261,9 @@ PyPI integration, can be found in the [cmake_example]_ repository.
261261
.. versionchanged:: 2.6
262262
CMake 3.4+ is required.
263263

264+
.. versionchanged:: 2.11
265+
CMake 3.5+ is required.
266+
264267
Further information can be found at :doc:`cmake/index`.
265268

266269
pybind11_add_module
@@ -495,7 +498,7 @@ You can use these targets to build complex applications. For example, the
495498

496499
.. code-block:: cmake
497500
498-
cmake_minimum_required(VERSION 3.4)
501+
cmake_minimum_required(VERSION 3.5...3.26)
499502
project(example LANGUAGES CXX)
500503
501504
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
@@ -553,7 +556,7 @@ information about usage in C++, see :doc:`/advanced/embedding`.
553556

554557
.. code-block:: cmake
555558
556-
cmake_minimum_required(VERSION 3.4...3.18)
559+
cmake_minimum_required(VERSION 3.5...3.26)
557560
project(example LANGUAGES CXX)
558561
559562
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)

docs/faq.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ There are three possible solutions:
284284
COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better,
285285
3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead
286286
of the old, deprecated search tools, and these modules are much better at
287-
finding the correct Python.
287+
finding the correct Python. If FindPythonLibs/Interp are not available
288+
(CMake 3.27+), then this will be ignored and FindPython will be used.
288289
3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python.
289290
However, you will have to use the target-based system, and do more setup
290291
yourself, because it does not know about or include things that depend on

docs/upgrade.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ to a new version. But it goes into more detail. This includes things like
88
deprecated APIs and their replacements, build system changes, general code
99
modernization and other useful information.
1010

11+
.. _upgrade-guide-2.11:
12+
13+
v2.11
14+
=====
15+
16+
* The minimum version of CMake is now 3.5. A future version will likely move
17+
to requiring something like 3.15. Using 3.15+ and using FindPython or setting
18+
``PYBIND11_FINDPYTHON`` is highly recommended; CMake is removing the
19+
long-deprecated support for ``FindPythonInterp``. Pybind11 will switch to
20+
FindPython if ``FindPythonInterp`` is not available.
21+
22+
1123
.. _upgrade-guide-2.9:
1224

1325
v2.9

tests/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
# All rights reserved. Use of this source code is governed by a
66
# BSD-style license that can be found in the LICENSE file.
77

8-
cmake_minimum_required(VERSION 3.4)
8+
cmake_minimum_required(VERSION 3.5)
99

10-
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
10+
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
1111
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
1212
# the behavior using the following workaround:
13-
if(${CMAKE_VERSION} VERSION_LESS 3.21)
13+
if(${CMAKE_VERSION} VERSION_LESS 3.26)
1414
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
1515
else()
16-
cmake_policy(VERSION 3.21)
16+
cmake_policy(VERSION 3.26)
1717
endif()
1818

19-
# Only needed for CMake < 3.5 support
20-
include(CMakeParseArguments)
21-
2219
# Filter out items; print an optional message if any items filtered. This ignores extensions.
2320
#
2421
# Usage:

tests/test_cmake_build/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Built-in in CMake 3.5+
2-
include(CMakeParseArguments)
3-
41
add_custom_target(test_cmake_build)
52

63
function(pybind11_add_build_test name)

tests/test_cmake_build/installed_embed/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
cmake_minimum_required(VERSION 3.4)
1+
cmake_minimum_required(VERSION 3.5)
22

3-
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
3+
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
44
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
55
# the behavior using the following workaround:
6-
if(${CMAKE_VERSION} VERSION_LESS 3.18)
6+
if(${CMAKE_VERSION} VERSION_LESS 3.26)
77
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
88
else()
9-
cmake_policy(VERSION 3.18)
9+
cmake_policy(VERSION 3.26)
1010
endif()
1111

1212
project(test_installed_embed CXX)

tests/test_cmake_build/installed_function/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
cmake_minimum_required(VERSION 3.4)
1+
cmake_minimum_required(VERSION 3.5)
22
project(test_installed_module CXX)
33

4-
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
4+
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
55
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
66
# the behavior using the following workaround:
7-
if(${CMAKE_VERSION} VERSION_LESS 3.18)
7+
if(${CMAKE_VERSION} VERSION_LESS 3.26)
88
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
99
else()
10-
cmake_policy(VERSION 3.18)
10+
cmake_policy(VERSION 3.26)
1111
endif()
1212

1313
project(test_installed_function CXX)

0 commit comments

Comments
 (0)