diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /cmake/Util.cmake | |
parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'cmake/Util.cmake')
-rw-r--r-- | cmake/Util.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/Util.cmake b/cmake/Util.cmake index 80f81fd0b4..f09de78668 100644 --- a/cmake/Util.cmake +++ b/cmake/Util.cmake @@ -148,6 +148,33 @@ function(add_glob_target) add_custom_target(${ARG_TARGET} DEPENDS ${touch_list}) endfunction() +# A wrapper function that combines add_custom_command and add_custom_target. It +# essentially models the "make" dependency where a target is only rebuilt if +# any dependencies have been changed. +# +# Important to note is that `DEPENDS` is a bit misleading; it should not only +# specify dependencies but also the files that are being generated/output +# files in order to work correctly. +function(add_target) + cmake_parse_arguments(ARG + "" + "" + "COMMAND;DEPENDS;CUSTOM_COMMAND_ARGS" + ${ARGN} + ) + set(target ${ARGV0}) + + set(touch_file ${TOUCHES_DIR}/${target}) + add_custom_command( + OUTPUT ${touch_file} + COMMAND ${CMAKE_COMMAND} -E touch ${touch_file} + COMMAND ${CMAKE_COMMAND} -E env "VIMRUNTIME=${NVIM_RUNTIME_DIR}" ${ARG_COMMAND} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS ${ARG_DEPENDS} + ${ARG_CUSTOM_COMMAND_ARGS}) + add_custom_target(${target} DEPENDS ${touch_file}) +endfunction() + # Set default build type to BUILD_TYPE. Also limit the list of allowable build # types to the ones defined in variable allowableBuildTypes. # |