From 275fc2b3689ae30a27d906274f72025f1ef547d6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 17 Jul 2024 02:39:54 -0400 Subject: [PATCH] feat: Simplify API expecting only one input file Remove obsolete ARGS argument that is being ignored and here only for backward compatibility. Switch from DEPENDS to MAIN_DEPENDENCY to suggest Visual Studio where to hang the custom command. Co-authored-by: Jean-Christophe Fillion-Robin --- src/cython_cmake/cmake/UseCython.cmake | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cython_cmake/cmake/UseCython.cmake b/src/cython_cmake/cmake/UseCython.cmake index 84aea57..363a0ba 100644 --- a/src/cython_cmake/cmake/UseCython.cmake +++ b/src/cython_cmake/cmake/UseCython.cmake @@ -7,7 +7,7 @@ # Create custom rules to generate the source code for a Python extension module # using cython. # -# Cython_compile_pyx( [ ...] +# Cython_compile_pyx( # [LANGUAGE C | CXX] # [CYTHON_ARGS ...] # [OUTPUT_VARIABLE ]) @@ -97,8 +97,12 @@ function(Cython_compile_pyx) set(_args_CYTHON_ARGS "${CYTHON_ARGS}") endif() - # Get source file location + # Get input set(_source_files ${_args_UNPARSED_ARGUMENTS}) + list(LENGTH _source_files input_length) + if(NOT input_length EQUAL 1) + message(FATAL_ERROR "One and only one input file must be specified, got '${_source_files}'") + endif() # Set target language get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) @@ -151,13 +155,12 @@ function(Cython_compile_pyx) OUTPUT ${generated_file} COMMAND ${_cython_command} - ARGS ${_language_arg} ${_args_CYTHON_ARGS} ${_depfile_arg} ${pyx_location} --output-file ${generated_file} - DEPENDS + MAIN_DEPENDENCY ${_source_file} DEPFILE ${_depfile}