Objective
I am trying to have CMake find Doxygen on a bunch of different systems and configurations:
- Online documentation is generated on Ubuntu
- Local tests and development is done on Macos
- Doxygen can be installed system-wide, through brew or through conan depending on the use case
Problem
I struggle finding a uniform approach that does not involve a lot of OS-specific operations. I am vaguely tempted to glue together the 3 following approaches, but I am still surprised/concerned/unsure a more elegant solution does not exist.
Sub-solution 1
What I have presently works only for system-wide installations:
find_package(Doxygen
REQUIRED dot
OPTIONAL_COMPONENTS mscgen dia)
if(DOXYGEN_FOUND)
# doxygen settings can be set here, prefixed with "DOXYGEN_"
# ...
# this target will only be built if specifically asked to.
# run "make docs" to create the doxygen documentation
doxygen_add_docs(
docs
${PROJECT_SOURCE_DIR}
COMMENT "Generate API-documents."
)
else (DOXYGEN_FOUND)
message([WARNING] " Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
Sub-solution 2:
I am aware I can try to access Conan-installed executable through CONAN_BIN_DIRS_DOXYGEN/doxygen
, as explained here
Sub-solution 3:
I am also aware I can try to locate Homebrew installations as described here.