1#
2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6
7# This module declares a macro for debugging purposes.
8# Simply place a call to set_break() in your build files and you will get a prompt
9
10macro(set_break)
11    include(cmakerepl)
12endmacro()
13
14# Mechanism for switching complex commands into and out of the foreground
15# Ninja restricts access to stdio for running commands by default.
16# Any output will only be printed once the task has completed.
17# This can be confusing for commands that take a long time to complete or hang
18# on failure instead of returning.
19# Foregrounding the tasks by setting USES_TERMINAL solves this problem as Ninja
20# lets the process directly access stdio. However this places the command into
21# a job pool that only allows one command to run at a time.
22# Therefore, CMakeForegroundComplexCommands is provided to allow bulk switching
23# of these commands between foreground and background. The intention is that it
24# is typically left off unless a build requires debugging in which case performance
25# is no longer as important as being able to get more helpful debug info of the
26# failing command.
27# Note: This requires correctly annotating complex commands with USES_TERMINAL_DEBUG
28# in the correct add_custom_command calls.
29set(CMakeForegroundComplexCommands OFF CACHE BOOL "Set USES_TERMINAL on specially marked tasks. \
30This makes the task run in the foreground and can directly access stdio. This is helpful for \
31debugging tasks that take a long time, or want to insert a breakpoint into the process. \
32Note: Only one task can run in foreground at a time.")
33mark_as_advanced(CMakeForegroundComplexCommands)
34if(CMakeForegroundComplexCommands)
35    set(USES_TERMINAL_DEBUG USES_TERMINAL)
36else()
37    set(USES_TERMINAL_DEBUG "")
38endif()
39