diff --git a/cmake/Assertion.cmake b/cmake/Assertion.cmake index 3a5dc2b..c0b1a81 100644 --- a/cmake/Assertion.cmake +++ b/cmake/Assertion.cmake @@ -22,3 +22,21 @@ function(assert_false CONDITION) message(FATAL_ERROR "expected the condition to be false") endif() endfunction() + +# Mocks the 'message' function. +# +# This function mocks the 'message' function by modifying its behavior to store +# the message into a list variable instead of printing it to the log. +function(mock_message) + function(message MODE MESSAGE) + list(APPEND ${MODE}_MESSAGES "${MESSAGE}") + set(${MODE}_MESSAGES "${${MODE}_MESSAGES}" PARENT_SCOPE) + if("${MODE}" STREQUAL FATAL_ERROR) + return() + endif() + endfunction() + + # Prevents the function from being mocked twice. + function(mock_message) + endfunction() +endfunction()