Skip to content

Commit 55afedb

Browse files
authored
fix: support paths with spaces (#52)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent ea72824 commit 55afedb

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/cython_cmake/cmake/UseCython.cmake

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# )
5050
#
5151
# Python_add_library(_hello
52-
# MODULE ${_hello_source_files}
52+
# MODULE "${_hello_source_files}"
5353
# WITH_SOABI
5454
# )
5555
#
@@ -134,9 +134,9 @@ function(Cython_transpile)
134134

135135
# Pretty-printed output names
136136
file(RELATIVE_PATH generated_file_relative
137-
${CMAKE_BINARY_DIR} ${generated_file})
137+
"${CMAKE_BINARY_DIR}" "${generated_file}")
138138
file(RELATIVE_PATH source_file_relative
139-
${CMAKE_SOURCE_DIR} ${_source_file})
139+
"${CMAKE_SOURCE_DIR}" "${_source_file}")
140140
set(comment "Generating ${_language} source '${generated_file_relative}' from '${source_file_relative}'")
141141

142142
# Get output directory to ensure its exists
@@ -146,23 +146,23 @@ function(Cython_transpile)
146146

147147
# Add the command to run the compiler.
148148
add_custom_command(
149-
OUTPUT ${generated_file}
149+
OUTPUT "${generated_file}"
150150
COMMAND
151-
${CMAKE_COMMAND} -E make_directory ${output_directory}
151+
"${CMAKE_COMMAND}" -E make_directory "${output_directory}"
152152
COMMAND
153153
${_cython_command}
154154
${_language_arg}
155155
"${_args_CYTHON_ARGS}"
156156
${_depfile_arg}
157-
${pyx_location}
158-
--output-file ${generated_file}
157+
"${pyx_location}"
158+
--output-file "${generated_file}"
159159
COMMAND_EXPAND_LISTS
160160
MAIN_DEPENDENCY
161-
${_source_file}
161+
"${_source_file}"
162162
DEPFILE
163-
${_depfile}
163+
"${_depfile}"
164164
VERBATIM
165-
COMMENT ${comment}
165+
COMMENT "${comment}"
166166
)
167167
endfunction()
168168

@@ -179,10 +179,10 @@ function(Cython_transpile)
179179
# cmake_path(GET _input_file STEM basename)
180180
get_filename_component(_basename "${_input_file}" NAME_WE)
181181

182-
if(IS_ABSOLUTE ${_input_file})
183-
file(RELATIVE_PATH _input_relative ${CMAKE_CURRENT_SOURCE_DIR} ${_input_file})
182+
if(IS_ABSOLUTE "${_input_file}")
183+
file(RELATIVE_PATH _input_relative "${CMAKE_CURRENT_SOURCE_DIR}" "${_input_file}")
184184
else()
185-
set(_input_relative ${_input_file})
185+
set(_input_relative "${_input_file}")
186186
endif()
187187

188188
get_filename_component(_output_relative_dir "${_input_relative}" DIRECTORY)
@@ -222,19 +222,19 @@ function(Cython_transpile)
222222

223223
# Place the cython files in the current binary dir if no path given
224224
if(NOT _args_OUTPUT)
225-
_set_output(${_source_file} ${_language} _args_OUTPUT)
226-
elseif(NOT IS_ABSOLUTE ${_args_OUTPUT})
225+
_set_output("${_source_file}" ${_language} _args_OUTPUT)
226+
elseif(NOT IS_ABSOLUTE "${_args_OUTPUT}")
227227
set(_args_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_args_OUTPUT}")
228228
endif()
229229

230-
set(generated_file ${_args_OUTPUT})
231-
_transpile(${_source_file} ${generated_file} ${_language})
232-
list(APPEND generated_files ${generated_file})
230+
set(generated_file "${_args_OUTPUT}")
231+
_transpile("${_source_file}" "${generated_file}" ${_language})
232+
list(APPEND generated_files "${generated_file}")
233233

234234
# Output variable only if set
235235
if(_args_OUTPUT_VARIABLE)
236236
set(_output_variable ${_args_OUTPUT_VARIABLE})
237-
set(${_output_variable} ${generated_files} PARENT_SCOPE)
237+
set(${_output_variable} "${generated_files}" PARENT_SCOPE)
238238
endif()
239239

240240
endfunction()

0 commit comments

Comments
 (0)