From 3a203e0f3f4fe70e258bcb40842ed91ee7506e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Aradi?= Date: Tue, 28 Nov 2023 13:52:04 +0100 Subject: [PATCH] Add CMake support for documentation --- .gitignore | 1 + CHANGELOG.md | 1 + CMakeLists.txt | 11 ++++++++++- README.md | 6 ++++++ cmake/dependencies.cmake | 3 +++ docs/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ docs/doxygen/Doxyfile | 2 +- 7 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 56c2e3e..52b4822 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ tags .*.swp # Visual Studio Code +.venv .vscode # documentation artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md index cc23af9..d842a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Documentation for hipFFT is available at * `hipfftXtSetGPUs`, `hipfftXtMalloc, hipfftXtMemcpy`, `hipfftXtFree`, and `hipfftXtExecDescriptor` APIs have been implemented to allow FFT computing on multiple devices in a single process +* CMake support for documentation. ## hipFFT 1.0.12 for ROCm 5.6.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1143fe6..5b6fcc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################# -# Copyright (C) 2020 - 2022 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2020 - 2023 Advanced Micro Devices, Inc. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -67,6 +67,10 @@ option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF) option( WERROR "Treat warnings as errors" OFF ) +option(BUILD_DOCS "Build documentation" OFF) + +include(GNUInstallDirs) + # Set internal BUILD_WITH_COMPILER. if( NOT CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) set( BUILD_WITH_COMPILER "HOST-default" ) @@ -215,6 +219,11 @@ if( BUILD_CLIENTS_BENCH OR BUILD_CLIENTS_SAMPLES OR BUILD_CLIENTS_TESTS ) add_subdirectory( clients ) endif() +# Build docs +if(BUILD_DOCS) + add_subdirectory(docs) +endif() + # Packaging... if(WIN32) set(CPACK_SOURCE_GENERATOR "ZIP") diff --git a/README.md b/README.md index 474584e..49b0cf4 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ pip3 install -r sphinx/requirements.txt python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html ``` +Alternatively, build with CMake: + +```bash +cmake -DBUILD_DOCS=ON ... +``` + ## Build and install You can download pre-built packages from the diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index bdbf689..77e2c3e 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -93,3 +93,6 @@ if( ROCM_FOUND ) else() message(WARNING "Could not find rocm-cmake, packaging will fail.") endif( ) + +# Documenation dependencies +include(FetchContent) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..3dd4c4f --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,40 @@ +# MIT License +# +# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +include(ROCMSphinxDoc) + +file(COPY + "${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile" + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + +rocm_add_sphinx_doc( + "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_DIR html + BUILDER html + USES_DOXYGEN + VARS + "doxyfile=${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" +) + +install( + DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" + DESTINATION "${CMAKE_INSTALL_DOCDIR}") diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index bca353c..92696cd 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -968,7 +968,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = ../README.md +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing