Skip to content

Commit 4c12c10

Browse files
committed
fix: try supporting older CMake
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 90e41de commit 4c12c10

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
- python-version: "3.9"
5252
runs-on: ubuntu-latest
5353
cmake: "3.20.x"
54+
- python-version: "3.10"
55+
runs-on: ubuntu-latest
56+
cmake: "3.15.x"
5457

5558
steps:
5659
- uses: actions/checkout@v4
@@ -67,6 +70,9 @@ jobs:
6770
with:
6871
cmake-version: ${{ matrix.cmake }}
6972

73+
- run: pipx install ninja
74+
if: matrix.cmake == '3.15.x'
75+
7076
- uses: yezz123/setup-uv@v4
7177

7278
- name: Install package

src/cython_cmake/cmake/FindCython.cmake

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# ``Cython::Cython``
1919
# The Cython executable
2020
#
21+
# A range of versions is supported on CMake 3.19+.
22+
#
2123
# For more information on the Cython project, see https://cython.org/.
2224
#
2325
# *Cython is a language that makes writing C extensions for the Python language
@@ -39,10 +41,6 @@
3941
# limitations under the License.
4042
#=============================================================================
4143

42-
if(CMAKE_VERSION VERSION_LESS "3.20")
43-
message(SEND_ERROR "CMake 3.20 required")
44-
endif()
45-
4644
# Use the Cython executable that lives next to the Python executable
4745
# if it is a local installation.
4846
if(Python_EXECUTABLE)
@@ -88,11 +86,19 @@ if(CYTHON_EXECUTABLE)
8886
endif()
8987

9088
include(FindPackageHandleStandardArgs)
91-
find_package_handle_standard_args(Cython
92-
REQUIRED_VARS CYTHON_EXECUTABLE
93-
VERSION_VAR ${CYTHON_VERSION}
94-
HANDLE_VERSION_RANGE
95-
)
89+
90+
if(CMAKE_VERSION VERSION_LESS 3.19)
91+
find_package_handle_standard_args(Cython
92+
REQUIRED_VARS CYTHON_EXECUTABLE
93+
VERSION_VAR ${CYTHON_VERSION}
94+
)
95+
else()
96+
find_package_handle_standard_args(Cython
97+
REQUIRED_VARS CYTHON_EXECUTABLE
98+
VERSION_VAR ${CYTHON_VERSION}
99+
HANDLE_VERSION_RANGE
100+
)
101+
endif()
96102

97103
if(CYTHON_FOUND)
98104
if(NOT DEFINED Cython::Cython)

src/cython_cmake/cmake/UseCython.cmake

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
# limitations under the License.
7373
#=============================================================================
7474

75-
if(CMAKE_VERSION VERSION_LESS "3.20")
76-
message(FATAL_ERROR "CMake 3.20 required")
75+
if(CMAKE_VERSION VERSION_LESS "3.7")
76+
message(SEND_ERROR "CMake 3.7 required for DEPFILE")
7777
endif()
7878

7979

@@ -124,14 +124,21 @@ function(Cython_compile_pyx)
124124
endif()
125125

126126
# Place the cython files in the current binary dir if no path given
127+
# Can use cmake_path for CMake 3.20+
127128
if(NOT CYTHON_OUTPUT)
128-
cmake_path(GET INPUT STEM basename)
129-
cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "${basename}${langauge_ext}" OUTPUT_VARIABLE CYTHON_OUTPUT)
129+
# cmake_path(GET INPUT STEM basename)
130+
get_filename_component(basename "${INPUT}" NAME_WE)
131+
132+
# cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "${basename}${langauge_ext}" OUTPUT_VARIABLE CYTHON_OUTPUT)
133+
set(CYTHON_OUPUT "${CMAKE_CURRENT_BINARY_DIR}/${basename}${langauge_ext}")
130134
endif()
131-
cmake_path(ABSOLUTE_PATH CYTHON_OUTPUT)
135+
136+
# cmake_path(ABSOLUTE_PATH CYTHON_OUTPUT)
137+
get_filename_component(CYTHON_OUTPUT "${CYTHON_OUPUT}" ABSOLUTE)
132138

133139
# Normalize the input path
134-
cmake_path(ABSOLUTE_PATH INPUT)
140+
# cmake_path(ABSOLUTE_PATH INPUT)
141+
get_filename_component(INPUT "${INPUT}" ABSOLUTE)
135142
set_source_files_properties("${INPUT}" PROPERTIES GENERATED TRUE)
136143

137144
# Support

tests/packages/simple/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.20...3.29)
1+
cmake_minimum_required(VERSION 3.15...3.29)
22
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)
33

44
find_package(

0 commit comments

Comments
 (0)