Skip to content

Commit 143f0f3

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

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
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.4"
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/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

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)

tools/pybind11Common.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,14 @@ endif()
163163

164164
# --------------------- Python specifics -------------------------
165165

166+
cmake_policy(GET CMP0148 _pybind11_missing_old_python)
167+
166168
# Check to see which Python mode we are in, new, old, or no python
167169
if(PYBIND11_NOPYTHON)
168170
set(_pybind11_nopython ON)
169171
elseif(
170-
PYBIND11_FINDPYTHON
172+
_pybind11_missing_old_python STREQUAL "NEW"
173+
OR PYBIND11_FINDPYTHON
171174
OR Python_FOUND
172175
OR Python2_FOUND
173176
OR Python3_FOUND)

tools/pybind11Config.cmake.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ Modes
6363
6464
There are two modes provided; classic, which is built on the old Python
6565
discovery packages in CMake, or the new FindPython mode, which uses FindPython
66-
from 3.12+ forward (3.15+ _highly_ recommended).
66+
from 3.12+ forward (3.15+ _highly_ recommended). If you set the minimum or
67+
maximum version of CMake to 3.27+, then FindPython is the default (since
68+
FindPythonInterp/FindPythonLibs has been removed via policy `CMP0148`).
6769
6870
New FindPython mode
6971
^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)