doxygen_add_docs install output directory

I’m trying to install generated doxygen directory like this:

    set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxy")
    doxygen_add_docs(
    			mylib_docs
    			include
    			COMMENT "Generate docs"
    	)
    add_custom_command(OUTPUT "${DOXYGEN_OUTPUT_DIRECTORY}" DEPENDS mylib_docs)
    install(DIRECTORY "${DOXYGEN_OUTPUT_DIRECTORY}" TYPE DOC)

But for some reason when installing it complains about directory not existing, shouldn’t it be marked generated? CMake project version 3.10, tried both on linux and windows with different generators. Is there any way to get this behavior without adding a dummy custom target?

If you are installing the docs, you probably want the docs to be part of the default “all” build target. You can do that by adding the ALL keyword to your doxygen_add_docs() call. Without this, doxygen won’t be run unless you explicitly build the mylib_docs target.

Your call to add_custom_command() won’t work for a couple of reasons. Firstly, it doesn’t create any target, so there’s nothing in the build system to attach the dependency to. Secondly, you’ve specified a directory as an output, but only files can be specified as outputs with add_custom_command(OUTPUT...).

1 Like

Thanks! It seems like add_doc’s ALL option was added in 3.12, so I’ll probably stick with proxy custom ALL target that depends on add_docs target for now. My initial idea was that custom command would mark directory as GENERATED, so install DIRECTORY would invoke command that depends on target when installing, seemed like a clever idea, but well.