Skip to content

Commit

Permalink
Merge pull request #346 from Exawind/revise-docs
Browse files Browse the repository at this point in the history
Revise openturbine documentation
  • Loading branch information
faisal-bhuiyan authored Feb 17, 2025
2 parents 3c88feb + c39a225 commit edd5491
Show file tree
Hide file tree
Showing 42 changed files with 2,556 additions and 892 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/correctness-linux.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: OpenTurbine-CI

on: push
on:
push:
paths-ignore:
- 'docs/**'
- '.github/workflows/deploy_docs.yaml'

jobs:
Correctness-Linux:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/correctness-macos.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: OpenTurbine-CI

on: push
on:
push:
paths-ignore:
- 'docs/**'
- '.github/workflows/deploy_docs.yaml'

jobs:
Correctness-MacOS:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy OpenTurbine Documentation

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{github.ref}}-${{github.head_ref}}-docs
cancel-in-progress: true

jobs:
Deploy-Docs:
runs-on: ubuntu-latest
steps:
- name: Cache install source dependencies
id: cache-dependencies
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/spack
key: linux-spack
- name: Install source dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
git clone https://github.com/spack/spack.git
source spack/share/spack/setup-env.sh
spack compiler find
spack install yaml-cpp
spack install trilinos@master~epetra ^kokkos-kernels+blas+lapack
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Clone repository
uses: actions/checkout@v4
with:
path: openturbine
- name: Install documentation dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends graphviz libenchant-2-dev doxygen
python3 -m pip install --upgrade pip
pip install -r openturbine/docs/requirements.txt
- name: Build OpenTurbine with documentation
run: |
source spack/share/spack/setup-env.sh
spack load trilinos yaml-cpp
cd openturbine
mkdir build
cd build
cmake .. \
-DOpenTurbine_ENABLE_TESTS=OFF \
-DOpenTurbine_ENABLE_DOCUMENTATION=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build .
- name: Deploy documentation
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ github.workspace }}/openturbine/build/docs/sphinx/html
10 changes: 5 additions & 5 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: OpenTurbine-CI

on: push
on:
push:
paths-ignore:
- 'docs/**'
- '.github/workflows/deploy_docs.yaml'

jobs:
clang-format:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run clang-format
run: |
clang-format --version
find . -regex '.*\.\(cpp\|hpp\|c\|h\)' -exec clang-format-18 -i {} \;
- name: Check for formatting changes
run: |
if [[ `git status --porcelain` ]]; then
Expand All @@ -24,4 +25,3 @@ jobs:
else
echo "Code is properly formatted."
fi
43 changes: 34 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -----------------------------------------------------------------------------
# Basic project setup
# -----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)

# Set C++ standard, prefer 17, no extensions
# Set C++ standard requirements -- prefer 17, no extensions
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -13,7 +16,11 @@ project(
LANGUAGES CXX
)

# -----------------------------------------------------------------------------
# Project configuration and options
# -----------------------------------------------------------------------------
# Include custom CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(cmake/PreventInSourceBuilds.cmake)
include(cmake/OpenTurbineOptions.cmake)

Expand All @@ -28,26 +35,36 @@ openturbine_setup_dependencies()
# Setup local project options
openturbine_local_options()

# -----------------------------------------------------------------------------
# Version information
# -----------------------------------------------------------------------------
# Generate a shortened Git SHA for versioning
set(GIT_SHA "Unknown" CACHE STRING "SHA this build was generated from")
string(SUBSTRING "${GIT_SHA}" 0 8 GIT_SHORT_SHA)

# Set Openturbine Version
# Set OpenTurbine Version
set(OPENTURBINE_VERSION_MAJOR 0 CACHE STRING "major version" FORCE)
set(OPENTURBINE_VERSION_MINOR 1 CACHE STRING "minor version" FORCE)
set(OPENTURBINE_VERSION ${OPENTURBINE_VERSION_MAJOR}.${OPENTURBINE_VERSION_MINOR} CACHE STRING "version" FORCE)

# -----------------------------------------------------------------------------
# Library targets
# -----------------------------------------------------------------------------
# Alias libraries for ease of use in targets
add_library(OpenTurbine::openturbine_options ALIAS openturbine_options)
add_library(OpenTurbine::openturbine_warnings ALIAS openturbine_warnings)

# Add the main source directory
add_subdirectory(src)

# -----------------------------------------------------------------------------
# Installation configuration
# -----------------------------------------------------------------------------
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenTurbineConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfig.cmake"
INSTALL_DESTINATION lib/cmake/OpenTurbine
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenTurbineConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfig.cmake"
INSTALL_DESTINATION lib/cmake/OpenTurbine
)

write_basic_package_version_file(
Expand All @@ -57,13 +74,21 @@ write_basic_package_version_file(
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfigVersion.cmake"
DESTINATION lib/cmake/OpenTurbine
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/OpenTurbineConfigVersion.cmake"
DESTINATION lib/cmake/OpenTurbine
)

# Enable testing if requested
# -----------------------------------------------------------------------------
# Optional components
# -----------------------------------------------------------------------------
# Build tests
include(CTest)
if(OpenTurbine_ENABLE_TESTS)
add_subdirectory(tests)
endif()

# Build documentation
if(OpenTurbine_ENABLE_DOCUMENTATION)
add_subdirectory(docs)
endif()
26 changes: 26 additions & 0 deletions cmake/FindDoxysphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#----------------------------------------------------------------------------------------
# Finds the Doxysphinx executable and version required for generating Sphinx-compatible
# documentation from Doxygen outputs
#----------------------------------------------------------------------------------------
find_program(DOXYSPHINX_EXECUTABLE NAMES doxysphinx
DOC "Doxysphinx Documentation Builder"
)

if(DOXYSPHINX_EXECUTABLE)
execute_process(
COMMAND ${DOXYSPHINX_EXECUTABLE} --version
OUTPUT_VARIABLE DOXYSPHINX_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if("${DOXYSPHINX_VERSION_OUTPUT}" MATCHES "version ([0-9]+\\.[0-9]+\\.[0-9]+)")
set(DOXYSPHINX_VERSION "${CMAKE_MATCH_1}")
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Doxysphinx
REQUIRED_VARS DOXYSPHINX_EXECUTABLE
VERSION_VAR DOXYSPHINX_VERSION
)

mark_as_advanced(DOXYSPHINX_EXECUTABLE)
25 changes: 25 additions & 0 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#----------------------------------------------------------------------------------------
# Finds the Sphinx documentation builder and its version
#----------------------------------------------------------------------------------------
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
)

if(SPHINX_EXECUTABLE)
execute_process(
COMMAND ${SPHINX_EXECUTABLE} --version
OUTPUT_VARIABLE SPHINX_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if("${SPHINX_VERSION_OUTPUT}" MATCHES ".* ([^\n]+)\n")
set(SPHINX_VERSION "${CMAKE_MATCH_1}")
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx
REQUIRED_VARS SPHINX_EXECUTABLE
VERSION_VAR SPHINX_VERSION
)

mark_as_advanced(SPHINX_EXECUTABLE)
69 changes: 57 additions & 12 deletions cmake/OpenTurbineOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
include(cmake/SystemLink.cmake)

#--------------------------------------------------------------------------
# OpenTurbine Build Options
#--------------------------------------------------------------------------
macro(openturbine_setup_options)
# Define project options with default values
#----------------------------------------
# Core build options
#----------------------------------------
option(OpenTurbine_ENABLE_TESTS "Build Tests" ON)
option(OpenTurbine_ENABLE_DOCUMENTATION "Build Documentation" OFF)
option(OpenTurbine_ENABLE_COVERAGE "Enable coverage reporting" OFF)
option(OpenTurbine_ENABLE_IPO "Enable IPO/LTO (Interprocedural Optimization/Link Time Optimization)" OFF)
option(OpenTurbine_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)

#----------------------------------------
# Sanitizer options
#----------------------------------------
option(OpenTurbine_ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF)
option(OpenTurbine_ENABLE_SANITIZER_LEAK "Enable leak sanitizer" OFF)
option(OpenTurbine_ENABLE_SANITIZER_UNDEFINED "Enable undefined behavior sanitizer" OFF)
option(OpenTurbine_ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF)
option(OpenTurbine_ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF)

#----------------------------------------
# Build optimization options
#----------------------------------------
option(OpenTurbine_ENABLE_UNITY_BUILD "Enable unity builds" OFF)
option(OpenTurbine_ENABLE_PCH "Enable precompiled headers" OFF)

#----------------------------------------
# Static analysis options
#----------------------------------------
option(OpenTurbine_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF)
option(OpenTurbine_ENABLE_CPPCHECK "Enable CppCheck analysis" OFF)
option(OpenTurbine_ENABLE_PCH "Enable precompiled headers" OFF)

#----------------------------------------
# External dependencies
#----------------------------------------
option(OpenTurbine_ENABLE_VTK "Use VTK for visualization" OFF)
option(OpenTurbine_BUILD_OPENFAST_ADI "Build the OpenFAST ADI external project" OFF)
option(OpenTurbine_BUILD_ROSCO_CONTROLLER "Build the ROSCO controller external project" OFF)
endmacro()

#--------------------------------------------------------------------------
# OpenTurbine Global Options
#--------------------------------------------------------------------------
macro(openturbine_global_options)
# Enable IPO/LTO if the option is set
if(OpenTurbine_ENABLE_IPO)
Expand All @@ -28,13 +53,21 @@ macro(openturbine_global_options)
endif()
endmacro()

#--------------------------------------------------------------------------
# Project-Wide Configuration Options
#--------------------------------------------------------------------------
macro(openturbine_local_options)
#----------------------------------------
# Core setup
#----------------------------------------
# Include standard project settings and create interface libraries
include(cmake/StandardProjectSettings.cmake)
add_library(openturbine_warnings INTERFACE)
add_library(openturbine_options INTERFACE)

# Set compiler warnings
#----------------------------------------
# Compiler warnings
#----------------------------------------
include(cmake/CompilerWarnings.cmake)
openturbine_set_project_warnings(
openturbine_warnings
Expand All @@ -44,7 +77,9 @@ macro(openturbine_local_options)
""
)

# Enable sanitizers if specified
#----------------------------------------
# Sanitizers configuration
#----------------------------------------
include(cmake/Sanitizers.cmake)
openturbine_enable_sanitizers(
openturbine_options
Expand All @@ -55,22 +90,30 @@ macro(openturbine_local_options)
${OpenTurbine_ENABLE_SANITIZER_MEMORY}
)

# Set unity build i.e. compile multiple source files into one
set_target_properties(openturbine_options PROPERTIES UNITY_BUILD ${OpenTurbine_ENABLE_UNITY_BUILD})
#----------------------------------------
# Build optimizations
#----------------------------------------
# Configure unity build
set_target_properties(openturbine_options
PROPERTIES UNITY_BUILD ${OpenTurbine_ENABLE_UNITY_BUILD}
)

# Enable precompiled headers if specified
# Configure precompiled headers
if(OpenTurbine_ENABLE_PCH)
target_precompile_headers(
openturbine_options
INTERFACE
<vector>
<string>
<utility>
<vector>
<string>
<utility>
)
endif()

# Enable static analysis tools if specified
#----------------------------------------
# Static analysis tools
#----------------------------------------
include(cmake/StaticAnalyzers.cmake)

if(OpenTurbine_ENABLE_CLANG_TIDY)
openturbine_enable_clang_tidy(openturbine_options ${OpenTurbine_WARNINGS_AS_ERRORS})
endif()
Expand All @@ -79,7 +122,9 @@ macro(openturbine_local_options)
openturbine_enable_cppcheck(${OpenTurbine_WARNINGS_AS_ERRORS} "")
endif()

# Enable coverage reporting if specified
#----------------------------------------
# Coverage configuration
#----------------------------------------
if(OpenTurbine_ENABLE_COVERAGE)
include(cmake/Tests.cmake)
openturbine_enable_coverage(openturbine_options)
Expand Down
Loading

0 comments on commit edd5491

Please sign in to comment.