mstring_generate( <out-var> <message-file>
                  [MODULE <name>]
                  [OUTPUT_DIRECTORY <dir>]
                  [HEADER_EXTENSION <ext>] [SOURCE_EXTENSION <ext>]
                  [NOHEADER] [NOSOURCE | INLINE]
                  [IMPORT_DIRECTORIES <dir>...]
                  [OPTIONS <mstring option>...]
                  [DEPENDS <file>...] )

Appends the generated files' paths to <out-var>; add them to a target.

Argument
MODULEpassed as mstring -m, so CMake knows the file names. Default: the message file's name without its extension
OUTPUT_DIRECTORYdefault ${CMAKE_CURRENT_BINARY_DIR}; put it on the target's include path
HEADER_EXTENSION, SOURCE_EXTENSIONmust match the file's $MODULE (defaults hh, cpp)
NOHEADER, NOSOURCE, INLINEthe file's $MODULE shape — the output that is not produced is not waited for
IMPORT_DIRECTORIESpassed as mstring -I
OPTIONSextra options, e.g. -w
DEPENDSthe files the message file $IMPORTs, so editing them regenerates
mstring_generate(ERRORS errors.msg OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen)
add_library(core ${SOURCES} ${ERRORS})
target_include_directories(core PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/gen)

Which mstring

The mstring target when it is built in the same project, else MSTRING_EXECUTABLE, else mstring found on the PATH (a Conan tool_requires puts it there).

Rebuilds

Generation reruns when the message file (or a DEPENDS file, or mstring itself) changes. Because mstring only rewrites changed files, an edit that does not change the output does not recompile anything.