@@ -10,26 +10,15 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.27")
10
10
cmake_policy (GET CMP0148 _pybind11_cmp0148)
11
11
endif ()
12
12
13
- cmake_minimum_required (VERSION 3.5)
14
-
15
- # The `cmake_minimum_required(VERSION 3.5...3.29)` syntax does not work with
16
- # some versions of VS that have a patched CMake 3.11. This forces us to emulate
17
- # the behavior using the following workaround:
18
- if (${CMAKE_VERSION} VERSION_LESS 3.29)
19
- cmake_policy (VERSION ${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} )
20
- else ()
21
- cmake_policy (VERSION 3.29)
22
- endif ()
13
+ cmake_minimum_required (VERSION 3.15...3.30)
23
14
24
15
if (_pybind11_cmp0148)
25
16
cmake_policy (SET CMP0148 ${_pybind11_cmp0148} )
26
17
unset (_pybind11_cmp0148)
27
18
endif ()
28
19
29
20
# Avoid infinite recursion if tests include this as a subdirectory
30
- if (DEFINED PYBIND11_MASTER_PROJECT)
31
- return ()
32
- endif ()
21
+ include_guard (GLOBAL )
33
22
34
23
# Extract project version from source
35
24
file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR} /include/pybind11/detail/common.h"
@@ -74,14 +63,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
74
63
75
64
set (PYBIND11_MASTER_PROJECT ON )
76
65
77
- if (OSX AND CMAKE_VERSION VERSION_LESS 3.7)
78
- # Bug in macOS CMake < 3.7 is unable to download catch
79
- message (WARNING "CMAKE 3.7+ needed on macOS to download catch, and newer HIGHLY recommended" )
80
- elseif (WINDOWS AND CMAKE_VERSION VERSION_LESS 3.8)
81
- # Only tested with 3.8+ in CI.
82
- message (WARNING "CMAKE 3.8+ tested on Windows, previous versions untested" )
83
- endif ()
84
-
85
66
message (STATUS "CMake ${CMAKE_VERSION} " )
86
67
87
68
if (CMAKE_CXX_STANDARD)
@@ -133,8 +114,7 @@ cmake_dependent_option(
133
114
"Install pybind11 headers in Python include directory instead of default installation prefix"
134
115
OFF "PYBIND11_INSTALL" OFF )
135
116
136
- cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default}
137
- "NOT CMAKE_VERSION VERSION_LESS 3.12" OFF )
117
+ option (PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default} )
138
118
139
119
# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests
140
120
# (makes transition easier while we support both modes).
@@ -184,7 +164,7 @@ set(PYBIND11_HEADERS
184
164
include /pybind11/warnings.h)
185
165
186
166
# Compare with grep and warn if mismatched
187
- if (PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12 )
167
+ if (PYBIND11_MASTER_PROJECT)
188
168
file (
189
169
GLOB_RECURSE _pybind11_header_check
190
170
LIST_DIRECTORIES false
@@ -202,10 +182,7 @@ if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
202
182
endif ()
203
183
endif ()
204
184
205
- # CMake 3.12 added list(TRANSFORM <list> PREPEND
206
- # But we can't use it yet
207
- string (REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR} /include/" PYBIND11_HEADERS
208
- "${PYBIND11_HEADERS} " )
185
+ list (TRANSFORM PYBIND11_HEADERS PREPEND "${CMAKE_CURRENT_SOURCE_DIR} /" )
209
186
210
187
# Cache variable so this can be used in parent projects
211
188
set (pybind11_INCLUDE_DIR
@@ -275,25 +252,11 @@ if(PYBIND11_INSTALL)
275
252
tools/${PROJECT_NAME} Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} Config.cmake"
276
253
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR} )
277
254
278
- if (CMAKE_VERSION VERSION_LESS 3.14)
279
- # Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does
280
- # not depend on architecture specific settings or libraries.
281
- set (_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P} )
282
- unset (CMAKE_SIZEOF_VOID_P )
283
-
284
- write_basic_package_version_file(
285
- ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
286
- VERSION ${PROJECT_VERSION}
287
- COMPATIBILITY AnyNewerVersion)
288
-
289
- set (CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P} )
290
- else ()
291
- # CMake 3.14+ natively supports header-only libraries
292
- write_basic_package_version_file(
293
- ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
294
- VERSION ${PROJECT_VERSION}
295
- COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
296
- endif ()
255
+ # CMake natively supports header-only libraries
256
+ write_basic_package_version_file(
257
+ ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
258
+ VERSION ${PROJECT_VERSION}
259
+ COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
297
260
298
261
install (
299
262
FILES ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} Config.cmake
0 commit comments