我正在尝试设置CMake以自动生成我的Doxygen文档。我目前使用以下代码。
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file("docs/Doxyfile.in" "${PROJECT_BINARY_DIR}/Doxyfile")
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE}
"${PROJECT_BINARY_DIR}/Doxyfile"
SOURCES "${PROJECT_BINARY_DIR}/Doxyfile")
install(DIRECTORY "${PROJECT_BINARY_DIR}/docs/"
DESTINATION "docs")
endif()
当您输入make docs
它在PROJECT_BINARY_DIR/docs
中生成文档时,它可以正常工作。当您输入make install
时,它会将docs子目录复制到CMAKE_INSTALL_PREFIX
。但是,当用户不希望生成文档并仅键入make install
时,会发生以下错误:
CMake Error at cmake_install.cmake:36 (FILE):
file INSTALL cannot find "/home/lukas/workspace/TheGame/build/docs".
如果构建自定义目标(install
)(或docs
中存在子目录docs
),如何指示仅PROJECT_BINARY_DIR
命令执行?
答案 0 :(得分:6)
您是否尝试使用OPTIONAL标志?
install(DIRECTORY "${PROJECT_BINARY_DIR}/docs/" DESTINATION "docs" OPTIONAL)