Skip to content

Commit cd86550

Browse files
henryiiijcfr
andcommitted
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 <[email protected]>
1 parent 8b256d5 commit cd86550

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/cython_cmake/cmake/UseCython.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Create custom rules to generate the source code for a Python extension module
88
# using cython.
99
#
10-
# Cython_compile_pyx(<pyx_file1> [<pyx_file2> ...]
10+
# Cython_compile_pyx(<pyx_file>
1111
# [LANGUAGE C | CXX]
1212
# [CYTHON_ARGS <args> ...]
1313
# [OUTPUT_VARIABLE <OutputVariable>])
@@ -77,8 +77,12 @@ function(Cython_compile_pyx)
7777
${ARGN}
7878
)
7979

80-
# Get source file location
80+
# Get input
8181
set(_source_files ${_args_UNPARSED_ARGUMENTS})
82+
list(LENGTH _source_files input_length)
83+
if(NOT input_length EQUAL 1)
84+
message(FATAL_ERROR "One and only one input file must be specified, got '${_source_files}'")
85+
endif()
8286

8387
# Set target language
8488
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
@@ -126,13 +130,12 @@ function(Cython_compile_pyx)
126130
add_custom_command(
127131
OUTPUT ${generated_file}
128132
COMMAND ${CYTHON_EXECUTABLE}
129-
ARGS
130133
${_language_arg}
131134
${_args_CYTHON_ARGS}
132135
${_depfile_arg}
133136
${pyx_location}
134137
--output-file ${generated_file}
135-
DEPENDS
138+
MAIN_DEPENDENCY
136139
${_source_file}
137140
DEPFILE
138141
${_cython_depfile}

0 commit comments

Comments
 (0)