Skip to content

Commit bb683a3

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 d1912ca commit bb683a3

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>])
@@ -97,8 +97,12 @@ function(Cython_compile_pyx)
9797
set(_args_CYTHON_ARGS "${CYTHON_ARGS}")
9898
endif()
9999

100-
# Get source file location
100+
# Get input
101101
set(_source_files ${_args_UNPARSED_ARGUMENTS})
102+
list(LENGTH _source_files input_length)
103+
if(NOT input_length EQUAL 1)
104+
message(FATAL_ERROR "One and only one input file must be specified, got '${_source_files}'")
105+
endif()
102106

103107
# Set target language
104108
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
@@ -151,13 +155,12 @@ function(Cython_compile_pyx)
151155
OUTPUT ${generated_file}
152156
COMMAND
153157
${_cython_command}
154-
ARGS
155158
${_language_arg}
156159
${_args_CYTHON_ARGS}
157160
${_depfile_arg}
158161
${pyx_location}
159162
--output-file ${generated_file}
160-
DEPENDS
163+
MAIN_DEPENDENCY
161164
${_source_file}
162165
DEPFILE
163166
${_depfile}

0 commit comments

Comments
 (0)