aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorDundar Goc <gocdundar@gmail.com>2022-06-18 17:31:01 +0200
committerDundar Goc <gocdundar@gmail.com>2022-06-19 18:34:28 +0200
commit636a30998166668f49a8ccca9daa193f6e7ca432 (patch)
tree74b4a330e84514ca9ca142e00c78d1d7359940d8 /cmake
parentcd1b2998d394ad85f1f48a5f2a8cb064ae31b521 (diff)
downloadrneovim-636a30998166668f49a8ccca9daa193f6e7ca432.tar.gz
rneovim-636a30998166668f49a8ccca9daa193f6e7ca432.tar.bz2
rneovim-636a30998166668f49a8ccca9daa193f6e7ca432.zip
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.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/DefCmdTarget.cmake32
1 files changed, 12 insertions, 20 deletions
diff --git a/cmake/DefCmdTarget.cmake b/cmake/DefCmdTarget.cmake
index 1ee5cdd60e..48e90cf5c8 100644
--- a/cmake/DefCmdTarget.cmake
+++ b/cmake/DefCmdTarget.cmake
@@ -1,27 +1,19 @@
-# Defines a target named ${target} and a command with (symbolic) output
-# ${target}-cmd. If ${prg} is undefined the target prints "not found".
+# Defines a target named ${target}. If ${prg} is undefined the target prints
+# "not found".
#
-# - Use add_custom_command(…APPEND) to build the command after this.
-# - Use add_custom_target(…DEPENDS) to run the command from a target.
+# - Use add_custom_command(TARGET <target_name> ...) to append a command to the
+# target.
function(def_cmd_target target prg prg_name prg_fatal)
- # Define a mostly-empty command, which can be appended-to.
- add_custom_command(OUTPUT ${target}-cmd
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND ${CMAKE_COMMAND} -E echo "${target}"
- )
- # Symbolic (does not generate an artifact).
- set_source_files_properties(${target}-cmd PROPERTIES SYMBOLIC "true")
+ add_custom_target(${target})
- if(prg OR NOT prg_fatal)
- add_custom_target(${target}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${target}-cmd)
- if(NOT prg)
- add_custom_command(OUTPUT ${target}-cmd APPEND
+ 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()
- else()
- add_custom_target(${target} false
- COMMENT "${target}: ${prg_name} not found")
endif()
endfunction()