From 38c71ae59f7f9683f817dbeffad7b65979b04cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Aradi?= Date: Tue, 21 Nov 2023 14:40:42 +0100 Subject: [PATCH] Add CMake for documentation --- CHANGELOG.md | 4 +++ CMakeLists.txt | 62 +++++++++++----------------------------- README.md | 6 ++++ cmake/Dependencies.cmake | 54 ++++++++++++++++++++++++++++++++++ docs/CMakeLists.txt | 40 ++++++++++++++++++++++++++ docs/doxygen/Doxyfile | 2 +- 6 files changed, 122 insertions(+), 46 deletions(-) create mode 100644 cmake/Dependencies.cmake create mode 100644 docs/CMakeLists.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 309dbc4e..efb4b67a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ Documentation for rocFFT is available at ## rocFFT 1.0.26 for ROCm 6.1.0 +### Additions + +* CMake support for documentation. + ### Changes * Multi-device FFTs now allow batch greater than 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 57d5ce7b..3e362d8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################# -# Copyright (C) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2016 - 2024 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 @@ -47,58 +47,22 @@ endif() set( ROCFFT_BUILD_SCOPE ON ) -project( rocfft LANGUAGES CXX C ) - -# This finds the rocm-cmake project, and installs it if not found -# rocm-cmake contains common cmake code for rocm projects to help setup and install -set( PROJECT_EXTERN_DIR ${CMAKE_CURRENT_BINARY_DIR}/extern ) -find_package( ROCM 0.7.3 CONFIG QUIET PATHS ${ROCM_PATH} /opt/rocm ) -if( NOT ROCM_FOUND ) - set( rocm_cmake_tag "master" CACHE STRING "rocm-cmake tag to download" ) - file( DOWNLOAD https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip - ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip STATUS status LOG log) - - list(GET status 0 status_code) - list(GET status 1 status_string) - - if(NOT status_code EQUAL 0) - message(FATAL_ERROR "error: downloading - 'https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip' failed - status_code: ${status_code} - status_string: ${status_string} - log: ${log} - ") - endif() +include(GNUInstallDirs) - message(STATUS "downloading... done") +project( rocfft LANGUAGES CXX C ) - execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip - WORKING_DIRECTORY ${PROJECT_EXTERN_DIR} ) - execute_process( COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_EXTERN_DIR}/rocm-cmake . - WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag} ) - execute_process( COMMAND ${CMAKE_COMMAND} --build rocm-cmake-${rocm_cmake_tag} --target install - WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}) +# Append our library helper cmake path and the cmake path for hip (for +# convenience). +# Users may override HIP path by specifying their own in CMAKE_MODULE_PATH +list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) - find_package( ROCM 0.7.3 REQUIRED CONFIG PATHS ${PROJECT_EXTERN_DIR}/rocm-cmake ) -endif( ) -include( ROCMSetupVersion ) -include( ROCMCreatePackage ) -include( ROCMInstallTargets ) -include( ROCMPackageConfigHelpers ) -include( ROCMInstallSymlinks ) -include( ROCMCheckTargetIds ) -include( ROCMClients ) -include( ROCMHeaderWrapper ) +# Handle dependencies +include(Dependencies) # Using standardized versioning from rocm-cmake set ( VERSION_STRING "1.0.26" ) rocm_setup_version( VERSION ${VERSION_STRING} ) -# Append our library helper cmake path and the cmake path for hip (for -# convenience). -# Users may override HIP path by specifying their own in CMAKE_MODULE_PATH -list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) - # Enable verbose output option( BUILD_VERBOSE "Output additional build information" OFF ) @@ -137,6 +101,9 @@ if(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY AND NOT WIN32) ) endif() +# Enable documentation build +option(BUILD_DOCS "Build documentation" OFF) + set( WARNING_FLAGS -Wall -Wno-unused-function -Wimplicit-fallthrough -Wunreachable-code -Wsign-compare ) if( WERROR ) set( WARNING_FLAGS ${WARNING_FLAGS} -Werror ) @@ -237,6 +204,11 @@ if( BUILD_CLIENTS_SAMPLES add_subdirectory( clients ) endif( ) +# Build docs +if(BUILD_DOCS) + add_subdirectory(docs) +endif() + if(WIN32) set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP") diff --git a/README.md b/README.md index 5cea4559..8e46fdd2 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,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 install rocFFT using pre-built packages or building from source. diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake new file mode 100644 index 00000000..83ace982 --- /dev/null +++ b/cmake/Dependencies.cmake @@ -0,0 +1,54 @@ +# MIT License +# +# Copyright (c) 2023-2024 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. + +# ########################### +# ROCm dependencies +# ########################### + +include(FetchContent) + +find_package(ROCM 0.11.0 CONFIG QUIET PATHS "${ROCM_PATH}") # First version with Sphinx doc gen improvement +if(NOT ROCM_FOUND) + message(STATUS "ROCm CMake not found. Fetching...") + set(rocm_cmake_tag + "rocm-6.0.0" + CACHE STRING "rocm-cmake tag to download") + FetchContent_Declare( + rocm-cmake + GIT_REPOSITORY https://github.com/ROCm/rocm-cmake.git + GIT_TAG ${rocm_cmake_tag} + SOURCE_SUBDIR "DISABLE ADDING TO BUILD" # We don't really want to consume the build and test targets of ROCm CMake. + ) + FetchContent_MakeAvailable(rocm-cmake) + find_package(ROCM CONFIG REQUIRED NO_DEFAULT_PATH PATHS "${rocm-cmake_SOURCE_DIR}") +else() + find_package(ROCM 0.11.0 CONFIG REQUIRED PATHS "${ROCM_PATH}") +endif() + +include(ROCMSetupVersion) +include(ROCMCreatePackage) +include(ROCMInstallTargets) +include(ROCMPackageConfigHelpers) +include(ROCMInstallSymlinks) +include(ROCMCheckTargetIds) +include(ROCMClients) +include(ROCMHeaderWrapper) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 00000000..e0059ae2 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,40 @@ +# MIT License +# +# Copyright (c) 2023-2024 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 2027e53f..0f4ea627 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -969,7 +969,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