diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd8b7e8..2f89534 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,9 @@ jobs: - python-version: "3.9" runs-on: ubuntu-latest cmake: "3.20.x" + - python-version: "3.10" + runs-on: ubuntu-latest + cmake: "3.15.x" steps: - uses: actions/checkout@v4 diff --git a/src/cython_cmake/cmake/FindCython.cmake b/src/cython_cmake/cmake/FindCython.cmake index fde483c..f0828b8 100644 --- a/src/cython_cmake/cmake/FindCython.cmake +++ b/src/cython_cmake/cmake/FindCython.cmake @@ -18,6 +18,8 @@ # ``Cython::Cython`` # The Cython executable # +# A range of versions is supported on CMake 3.19+. +# # For more information on the Cython project, see https://cython.org/. # # *Cython is a language that makes writing C extensions for the Python language @@ -39,10 +41,6 @@ # limitations under the License. #============================================================================= -if(CMAKE_VERSION VERSION_LESS "3.20") - message(SEND_ERROR "CMake 3.20 required") -endif() - # Use the Cython executable that lives next to the Python executable # if it is a local installation. if(Python_EXECUTABLE) @@ -88,11 +86,19 @@ if(CYTHON_EXECUTABLE) endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Cython - REQUIRED_VARS CYTHON_EXECUTABLE - VERSION_VAR ${CYTHON_VERSION} - HANDLE_VERSION_RANGE -) + +if(CMAKE_VERSION VERSION_LESS 3.19) + find_package_handle_standard_args(Cython + REQUIRED_VARS CYTHON_EXECUTABLE + VERSION_VAR ${CYTHON_VERSION} + ) +else() + find_package_handle_standard_args(Cython + REQUIRED_VARS CYTHON_EXECUTABLE + VERSION_VAR ${CYTHON_VERSION} + HANDLE_VERSION_RANGE + ) +endif() if(CYTHON_FOUND) if(NOT DEFINED Cython::Cython) diff --git a/src/cython_cmake/cmake/UseCython.cmake b/src/cython_cmake/cmake/UseCython.cmake index 4100e6d..22b40b5 100644 --- a/src/cython_cmake/cmake/UseCython.cmake +++ b/src/cython_cmake/cmake/UseCython.cmake @@ -72,8 +72,8 @@ # limitations under the License. #============================================================================= -if(CMAKE_VERSION VERSION_LESS "3.20") - message(FATAL_ERROR "CMake 3.20 required") +if(CMAKE_VERSION VERSION_LESS "3.7") + message(SEND_ERROR "CMake 3.7 required for DEPFILE") endif() @@ -124,14 +124,21 @@ function(Cython_compile_pyx) endif() # Place the cython files in the current binary dir if no path given + # Can use cmake_path for CMake 3.20+ if(NOT CYTHON_OUTPUT) - cmake_path(GET INPUT STEM basename) - cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "${basename}${langauge_ext}" OUTPUT_VARIABLE CYTHON_OUTPUT) + # cmake_path(GET INPUT STEM basename) + get_filename_component(basename "${INPUT}" NAME_WE) + + # cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "${basename}${langauge_ext}" OUTPUT_VARIABLE CYTHON_OUTPUT) + set(CYTHON_OUPUT "${CMAKE_CURRENT_BINARY_DIR}/{basename}${langauge_ext}") endif() - cmake_path(ABSOLUTE_PATH CYTHON_OUTPUT) + + # cmake_path(ABSOLUTE_PATH CYTHON_OUTPUT) + get_filename_component(CYTHON_OUTPUT "${CYTHON_OUPUT}" ABSOLUTE) # Normalize the input path - cmake_path(ABSOLUTE_PATH INPUT) + # cmake_path(ABSOLUTE_PATH INPUT) + get_filename_component(INPUT "${INPUT}" ABSOLUTE) set_source_files_properties("${INPUT}" PROPERTIES GENERATED TRUE) # Support diff --git a/tests/packages/simple/CMakeLists.txt b/tests/packages/simple/CMakeLists.txt index ccfbc7c..4d7f134 100644 --- a/tests/packages/simple/CMakeLists.txt +++ b/tests/packages/simple/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20...3.29) +cmake_minimum_required(VERSION 3.15...3.29) project(${SKBUILD_PROJECT_NAME} LANGUAGES C) find_package(