From 37290f5e9e2651a061cc3e5b65f8678fa08c11e1 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 19 Aug 2025 13:28:14 +0200 Subject: [PATCH] feat(cmakev2/utilities): add add_deprecated_target_alias function The add_deprecated_target_alias function is used by some existing components, so it should be added to cmakev2 as well. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/utilities.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/cmakev2/utilities.cmake b/tools/cmakev2/utilities.cmake index bab5ca6339d..629be58c308 100644 --- a/tools/cmakev2/utilities.cmake +++ b/tools/cmakev2/utilities.cmake @@ -590,3 +590,20 @@ function(file_generate output) set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${output}") endfunction() + +#[[ + add_deprecated_target_alias( ) + + :old_target[in]: Old target name. + :new_target[in]: New target name. + + Create an alias for the existing target and display a deprecation warning. +#]] +function(add_deprecated_target_alias old_target new_target) + add_custom_target(${old_target} + # `COMMAND` is important to print the `COMMENT` message at the end of the target action. + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMENT "Warning: command \"${old_target}\" is deprecated. Have you wanted to run \"${new_target}\" instead?" + ) + add_dependencies(${old_target} ${new_target}) +endfunction()