Hi,
I have a C++ project with Doxygen documentation. I set variables in the CMake script, such as
set(P4LBM_HOME ${CMAKE_CURRENT_SOURCE_DIR})
set(P4LBM_DOC ${P4LBM_HOME}/docs)
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
In Doxyfile.in, I read the values of these variables using e.g.
HTML_FOOTER = @P4LBM_DOC@/doxygen_footer.html
The documentation is built successfully with make docs
.
Now I want to be able to build the documentation in GitLab CI without building the main code and without CMake. So I replace the CMake set
commands with environment variables in the .gitlab-ci.yml file:
pages:
stage: deploy
script:
- mkdir build
- export ROOT=$PWD
- export P4LBM_DOC=$ROOT/docs
- doxygen docs/Doxyfile.in
Environment variables in Doxygen are read with the $(...)
syntax, not with @...@
. In the example above:
HTML_FOOTER = $(P4LBM_DOC)/doxygen_footer.html
Once I perform these changes in Doxyfile.in, the documentation builds properly on the CI.
Now I cannot build the documentation locally with CMake using make docs
because Doxyfile.in expects environment variables, not CMake variables. And adding the ENV
keywords, e.g.
set(ENV{P4LBM_DOC} ${P4LBM_HOME}/docs)
does not make a difference, probably because CMake cannot inject environment variables into the parent process. Is there a way to let Doxygen know about these environment variables from within CMake? Alternatively, I thought about writing the documentation creation commands
export ROOT=$PWD
export P4LBM_DOC=$ROOT/docs
doxygen docs/Doxyfile.in
into a Bash script and call this script from CMake. The drawback is that it would only work on OSs which can interpret Bash scripts.