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 | |
|---|---|
MODULE | passed as mstring -m, so CMake knows the file names. Default: the message file's name without its extension |
OUTPUT_DIRECTORY | default ${CMAKE_CURRENT_BINARY_DIR}; put it on the target's include path |
HEADER_EXTENSION, SOURCE_EXTENSION | must match the file's $MODULE (defaults hh, cpp) |
NOHEADER, NOSOURCE, INLINE | the file's $MODULE shape — the output that is not produced is not waited for |
IMPORT_DIRECTORIES | passed as mstring -I |
OPTIONS | extra options, e.g. -w |
DEPENDS | the 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.

