cmake: Added assert that will show usage
There is a catch-22 in that you need to run CMake to get a build system that can show you usage, but you need to know the usage to be able to get a build system. This assert could be used to improve the usability somewhat. When invalid usage is detected it can be used to print the usage. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
fa934009cb
commit
6c8ebab183
1 changed files with 18 additions and 0 deletions
|
@ -811,3 +811,21 @@ macro(assert_exists var)
|
||||||
message(FATAL_ERROR "No such file or directory: ${var}: '${${var}}'")
|
message(FATAL_ERROR "No such file or directory: ${var}: '${${var}}'")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# assert_with_usage(BOARD_DIR "No board named '${BOARD}' found")
|
||||||
|
#
|
||||||
|
# will print an error message, show usage, and then end executioon
|
||||||
|
# with a FATAL_ERROR if the test fails.
|
||||||
|
macro(assert_with_usage test comment)
|
||||||
|
if(NOT ${test})
|
||||||
|
message(${comment})
|
||||||
|
message("see usage:")
|
||||||
|
execute_process(
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND} -P $ENV{ZEPHYR_BASE}/cmake/usage/usage.cmake
|
||||||
|
)
|
||||||
|
message(FATAL_ERROR "Invalid usage")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue