neovim/cmake/DefCmdTarget.cmake
Dundar Goc 636a309981 build(cmake): simplify def_cmd_target function
Instead of appending to a command output, append to an existing target
instead. The primary benefit is intermediary ...-cmd targets aren't
needed, we can instead append commands to the relevant target directly.
2022-06-19 18:34:28 +02:00

20 lines
616 B
CMake

# Defines a target named ${target}. If ${prg} is undefined the target prints
# "not found".
#
# - Use add_custom_command(TARGET <target_name> ...) to append a command to the
# target.
function(def_cmd_target target prg prg_name prg_fatal)
add_custom_target(${target})
if(NOT prg)
if(prg_fatal)
add_custom_command(TARGET ${target}
COMMAND ${CMAKE_COMMAND} -E echo "${target}: ${prg_name} not found"
COMMAND false)
else()
add_custom_command(TARGET ${target}
COMMAND ${CMAKE_COMMAND} -E echo "${target}: SKIP: ${prg_name} not found")
endif()
endif()
endfunction()