StormByte - Build Master
Loading...
Searching...
No Matches
helpers.cmake
Go to the documentation of this file.
1
15macro(add_tool srcdir)
16 # Optional indent level
17 if(${ARGC} GREATER 1)
18 set(_indent_level "${ARGV1}")
19 string(REPEAT "\t" ${_indent_level} _INDENT_)
20 else()
21 set(_INDENT_ "")
22 endif()
23
24 message(STATUS "${_INDENT_}Setting up ${srcdir}")
25 add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/${srcdir}")
26 include("${CMAKE_CURRENT_LIST_DIR}/${srcdir}/propagate_vars.cmake")
27endmacro()
28
29
36macro(ensure_extra_tool_is_available tool_name)
37 # Append the tool name to the global property BUILDMASTER_PLUGINS_EXTRA
38 get_property(available_extra_tools GLOBAL PROPERTY BUILDMASTER_PLUGINS_EXTRA_AVAILABLE)
39 list(FIND available_extra_tools "${tool_name}" _found_index)
40 if(_found_index EQUAL -1)
41 message(FATAL_ERROR "The extra tool '${tool_name}' is not available. Available extra tools are: ${available_extra_tools}")
42 endif()
43endmacro()
44
45
51macro(propagate_vars_extra_tool tool_name)
52 # Append the tool name to the global property BUILDMASTER_PLUGINS_EXTRA
53 get_property(configured_extra_tools GLOBAL PROPERTY BUILDMASTER_PLUGINS_EXTRA_ENABLED)
54 list(FIND configured_extra_tools "${tool_name}" _found_index)
55 if(_found_index GREATER -1)
56 include(${tool_name}/propagate_vars.cmake)
57 endif()
58endmacro()
59
60
63macro(propagate_all_vars_extra_tools)
64 # Get the list of configured extra tools
65 get_property(configured_extra_tools GLOBAL PROPERTY BUILDMASTER_PLUGINS_EXTRA_ENABLED)
66 foreach(tool_name IN LISTS configured_extra_tools)
67 include(${BUILDMASTER_TOOLS_SRCDIR}/extra/${tool_name}/propagate_vars.cmake)
68 endforeach()
69endmacro()
70
71
79macro(configure_extra_tool tool_name)
80 # Read the list of already-enabled tools (may be undefined)
81 get_property(configured_extra_tools GLOBAL PROPERTY BUILDMASTER_PLUGINS_EXTRA_ENABLED)
82
83 # Check if the tool is already registered
84 list(FIND configured_extra_tools "${tool_name}" _found_index)
85
86 if(_found_index EQUAL -1)
87 # Append cleanly using list(APPEND) — works even if the variable is undefined
88 list(APPEND configured_extra_tools "${tool_name}")
89
90 # Write back to the global property
91 set_property(GLOBAL PROPERTY BUILDMASTER_PLUGINS_EXTRA_ENABLED
92 "${configured_extra_tools}")
93
94 # Add the tool directory and propagate its variables
95 add_subdirectory(${tool_name})
96 include(${tool_name}/propagate_vars.cmake)
97 endif()
98endmacro()