Skip to content

Commit f6a7a69

Browse files
committed
Simplify commands creation
1 parent 86f8d62 commit f6a7a69

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

cmake/cmake/modules/FindRE2C.cmake

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,29 @@ function(re2c_target)
351351
endif()
352352

353353
set(message "[RE2C][${ARGV0}] Generating lexer with re2c ${RE2C_VERSION}")
354-
set(command ${RE2C_EXECUTABLE} ${options} --output ${output} ${input})
354+
set(commands COMMAND ${RE2C_EXECUTABLE} ${options} --output ${output} ${input})
355355

356356
# RE2C cannot create output directories. Ensure any required directories
357357
# for the generated files are created if they don't already exist.
358-
set(makeDirectoryCommand "")
358+
set(directories "")
359359
foreach(output IN LISTS outputs)
360360
cmake_path(GET output PARENT_PATH dir)
361361
if(dir)
362-
list(APPEND makeDirectoryCommand ${dir})
362+
list(APPEND directories ${dir})
363363
endif()
364-
unset(dir)
365364
endforeach()
366-
if(makeDirectoryCommand)
367-
list(REMOVE_DUPLICATES makeDirectoryCommand)
365+
if(directories)
366+
list(REMOVE_DUPLICATES directories)
368367
list(
369368
PREPEND
370-
makeDirectoryCommand
371-
COMMAND ${CMAKE_COMMAND} -E make_directory
369+
commands
370+
COMMAND ${CMAKE_COMMAND} -E make_directory ${directories}
372371
)
373372
endif()
374373

375374
if(CMAKE_SCRIPT_MODE_FILE)
376375
message(STATUS "${message}")
377-
execute_process(${makeDirectoryCommand} COMMAND ${command})
376+
execute_process(${commands})
378377
return()
379378
endif()
380379

@@ -393,8 +392,7 @@ function(re2c_target)
393392

394393
add_custom_command(
395394
OUTPUT ${outputs}
396-
${makeDirectoryCommand}
397-
COMMAND ${command}
395+
${commands}
398396
DEPENDS ${input} ${parsed_DEPENDS} $<TARGET_NAME_IF_EXISTS:RE2C::RE2C>
399397
COMMENT "${message}"
400398
VERBATIM

0 commit comments

Comments
 (0)