Skip to content

Commit

Permalink
feat: Simplify API expecting only one input file
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
henryiii and jcfr committed Jul 17, 2024
1 parent 8b256d5 commit cd86550
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cython_cmake/cmake/UseCython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Create custom rules to generate the source code for a Python extension module
# using cython.
#
# Cython_compile_pyx(<pyx_file1> [<pyx_file2> ...]
# Cython_compile_pyx(<pyx_file>
# [LANGUAGE C | CXX]
# [CYTHON_ARGS <args> ...]
# [OUTPUT_VARIABLE <OutputVariable>])
Expand Down Expand Up @@ -77,8 +77,12 @@ function(Cython_compile_pyx)
${ARGN}
)

# 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)
Expand Down Expand Up @@ -126,13 +130,12 @@ function(Cython_compile_pyx)
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${CYTHON_EXECUTABLE}
ARGS
${_language_arg}
${_args_CYTHON_ARGS}
${_depfile_arg}
${pyx_location}
--output-file ${generated_file}
DEPENDS
MAIN_DEPENDENCY
${_source_file}
DEPFILE
${_cython_depfile}
Expand Down

0 comments on commit cd86550

Please sign in to comment.