Fix building docs from subprojects by not using CMAKE_SOURCE_DIR (#6016)

The generate_documentation function needs assets from the top-level SDK
directory. CMAKE_SOURCE_DIR will not point there if building from a
subproject like sdk/core/azure-core.

Fix this by defining SDK_ROOT_DIR, which is based on PROJECT_SOURCE_DIR.
This should always work as long as each subproject calling the function
is always 3 levels down, which is currently the case.
This commit is contained in:
James Le Cuirot 2024-09-26 00:39:10 +01:00 коммит произвёл GitHub
Родитель 023469bc18
Коммит f3119bd899
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -14,8 +14,14 @@ function(generate_documentation PROJECT_NAME PROJECT_VERSION)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION})
# Doc assets are needed from the top-level SDK directory.
# CMAKE_SOURCE_DIR will not point there if building from a subproject
# like sdk/core/azure-core, so use PROJECT_SOURCE_DIR instead.
# Subprojects are assumed to always be 3 levels down from the root.
set(SDK_ROOT_DIR ${PROJECT_SOURCE_DIR}/../../..)
set(DOXYGEN_OUTPUT_DIRECTORY docs)
set(DOXYGEN_LAYOUT_FILE ${CMAKE_SOURCE_DIR}/eng/docs/api/assets/DoxygenLayout.xml)
set(DOXYGEN_LAYOUT_FILE ${SDK_ROOT_DIR}/eng/docs/api/assets/DoxygenLayout.xml)
set(DOXYGEN_RECURSIVE YES)
if (MSVC)
set(DOXYGEN_WARN_FORMAT "$file($line) : $text")
@ -45,10 +51,10 @@ function(generate_documentation PROJECT_NAME PROJECT_VERSION)
az_
AZ_
)
set(DOXYGEN_HTML_HEADER ${CMAKE_SOURCE_DIR}/eng/docs/api/assets/header.html)
set(DOXYGEN_HTML_FOOTER ${CMAKE_SOURCE_DIR}/eng/docs/api/assets/footer.html)
set(DOXYGEN_HTML_STYLESHEET ${CMAKE_SOURCE_DIR}/eng/docs/api/assets/style.css)
set(DOXYGEN_PROJECT_LOGO ${CMAKE_SOURCE_DIR}/eng/common/docgeneration/assets/logo.svg)
set(DOXYGEN_HTML_HEADER ${SDK_ROOT_DIR}/eng/docs/api/assets/header.html)
set(DOXYGEN_HTML_FOOTER ${SDK_ROOT_DIR}/eng/docs/api/assets/footer.html)
set(DOXYGEN_HTML_STYLESHEET ${SDK_ROOT_DIR}/eng/docs/api/assets/style.css)
set(DOXYGEN_PROJECT_LOGO ${SDK_ROOT_DIR}/eng/common/docgeneration/assets/logo.svg)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_GENERATE_LATEX NO)