Set environment variables for doxygen_add_docs


in a Doxyfile (supported with CONFIG_FILE) you can reference files via environment. e.g.

@INCLUDE               = include.doxygen

S.a. Doxygen Manual: Configuration

Can you set environment variables for doxygen_add_docs()?

1 Like

You can set environment variables in a build preset, but other than that, I think the only option would be to create a custom target that runs a script which first sets the environment variables and then calls Doxygen.

custom target that runs … Doxygen

That is deprecated, as DOXYGEN_EXECUTABLE is deprecated. I cannot run doxygen without knowing where DOXYGEN_EXECUTABLE is.

My current workaround is to “configure” my doxyfile and replace these $(<var>) things manually by string(REPLACE).

That’s not quite true, you can specify the name of an executable target (such as Doxygen::doxygen) as the COMMAND of a custom command. And if that is not enough for you, you can always use the genex $<TARGET_FILE:Doxygen::doxygen> to access the path at generate time.


Please consider the straight forward way, to create the desired configuration with configure_file and alike.

When using cmake -E env: Depending on the content of your variable, quoting for the shell is needed in a portable way. And Windows has a low limit for command line length.
Writing a e.g. cmake script which sets the env var and then executes doxygen: does not make it easier than generating the full config directly.