mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(cmakev2/utilities): add fail_target function
The fail_target function is used by some existing components, so it should be added to cmakev2 as well. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -535,3 +535,31 @@ function(add_prefix var prefix)
|
|||||||
endforeach()
|
endforeach()
|
||||||
set(${var} "${newlist}" PARENT_SCOPE)
|
set(${var} "${newlist}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
#[[
|
||||||
|
fail_target(<target> <line0> [<line>...])
|
||||||
|
|
||||||
|
:target[in]: Fail target name.
|
||||||
|
:line0[in]: First line of the failed message.
|
||||||
|
:line[in,opt]: Optional additional message lines.
|
||||||
|
|
||||||
|
Create a phony target which fails when invoked. This is used when the
|
||||||
|
necessary conditions for a target are not met, such as configuration. Rather
|
||||||
|
than omitting the target altogether, we fail execution with a helpful
|
||||||
|
message.
|
||||||
|
#]]
|
||||||
|
function(fail_target target_name message_line0)
|
||||||
|
idf_build_get_property(idf_path IDF_PATH)
|
||||||
|
set(message_lines COMMAND ${CMAKE_COMMAND} -E echo "${message_line0}")
|
||||||
|
foreach(message_line ${ARGN})
|
||||||
|
set(message_lines ${message_lines} COMMAND ${CMAKE_COMMAND} -E echo "${message_line}")
|
||||||
|
endforeach()
|
||||||
|
# Generate a timestamp file that gets included. When deleted on build, this forces CMake
|
||||||
|
# to rerun.
|
||||||
|
set(fail_message "Failed executing target (see errors on lines above)")
|
||||||
|
add_custom_target(${target_name}
|
||||||
|
${message_lines}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E env FAIL_MESSAGE=${fail_message}
|
||||||
|
${CMAKE_COMMAND} -P ${idf_path}/tools/cmake/scripts/fail.cmake
|
||||||
|
VERBATIM)
|
||||||
|
endfunction()
|
||||||
|
|||||||
Reference in New Issue
Block a user