diff --git a/.github/workflows/all-dev-builds.yml b/.github/workflows/all-dev-builds.yml new file mode 100644 index 00000000..32b3ed31 --- /dev/null +++ b/.github/workflows/all-dev-builds.yml @@ -0,0 +1,11 @@ +name: Matrix Development Builds + +on: [push, pull_request] + +jobs: + Linux: + uses: ./.github/workflows/ubuntu-builds.yml + Windows: + uses: ./.github/workflows/windows-builds.yml + MacOS: + uses: ./.github/workflows/macos-builds.yml diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml deleted file mode 100644 index 3e450213..00000000 --- a/.github/workflows/cmake-build.yml +++ /dev/null @@ -1,349 +0,0 @@ -name: CMake Build Matrix - -on: [push, pull_request] - -env: - CMAKE_VERSION: 3.21.1 - NINJA_VERSION: 1.10.2 - BUILD_TYPE: Release - -jobs: - build: - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Windows Latest MSVC", - os: windows-latest, - artifact: "Windows-MSVC.7z", - build_type: "Release", - cc: "cl", - cxx: "cl", - environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", - archiver: "7z a", - generators: "Visual Studio 17 2022", - } - - { - name: "Ubuntu_GCC_10", - os: ubuntu-latest, - artifact: "Linux.7z", - build_type: "Release", - cc: "gcc-10", - cxx: "g++-10", - archiver: "7z a", - generators: "Ninja", - } - - { - name: "Ubuntu_GCC_11", - os: ubuntu-latest, - artifact: "Linux-GCC-11.7z", - build_type: "Release", - cc: "gcc", - cxx: "g++", - archiver: "7z a", - generators: "Ninja", - } - - { - name: "macOS Latest Clang", - os: macos-latest, - artifact: "macOS.7z", - build_type: "Release", - cc: "clang", - cxx: "clang++", - archiver: "7za a", - generators: "Ninja", - } - - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Print env - run: | - echo github.event.action: ${{ github.event.action }} - echo github.event_name: ${{ github.event_name }} - - - name: Download Ninja and CMake - shell: cmake -P {0} - run: | - set(cmake_version $ENV{CMAKE_VERSION}) - set(ninja_version $ENV{NINJA_VERSION}) - - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - - if ("${{ runner.os }}" STREQUAL "Windows") - set(ninja_suffix "win.zip") - set(cmake_suffix "windows-x86_64.zip") - set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(ninja_suffix "linux.zip") - set(cmake_suffix "linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(ninja_suffix "mac.zip") - set(cmake_suffix "macos-universal.tar.gz") - set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") - endif() - - set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") - file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) - - set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") - file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) - - # Add to PATH environment variable - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}") - - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process( - COMMAND chmod +x ninja - COMMAND chmod +x ${cmake_dir}/cmake - ) - endif() - - - name: Install gcc-11 - shell: bash - if: endsWith(matrix.config.name, 'GCC_11') - run: | - sudo apt-get update - sudo apt-get install gcc-11 g++-11 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 - - - name: Install ccache - shell: cmake -P {0} - run: | - if("${{ runner.os }}" STREQUAL "Windows") - # If ccache behaves badly on windows, skip this step - execute_process(COMMAND choco install ccache) - elseif("${{ runner.os }}" STREQUAL "macOS") - execute_process(COMMAND brew install ccache) - elseif("${{ runner.os }}" STREQUAL "Linux") - set(ccache_version "4.6.3") - set(ccache_dist "ccache-${ccache_version}-linux-x86_64") - set(ccache_url "https://github.com/ccache/ccache/releases/download/v${ccache_version}/${ccache_dist}.tar.xz") - file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxvf ./ccache.tar.xz) - # Add to PATH environment variable - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${ccache_dist}" ccache_dir) - set(path_separator ":") - file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${ccache_dir}") - else() - message(FATAL_ERROR, "${{ runner.os }} is not supported") - endif() - - - name: Setup ccache - # If ccache behaves badly on windows, skip this step - # if: runner.os != 'Windows' - uses: Chocobo1/setup-ccache-action@v1 - with: - install_ccache: false - update_packager_index: false - prepend_symlinks_to_path: false - windows_compile_environment: msvc # this field is required - - - name: Configure - shell: cmake -P {0} - run: | - set(ENV{CC} ${{ matrix.config.cc }}) - set(ENV{CXX} ${{ matrix.config.cxx }}) - - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - execute_process( - COMMAND "${{ matrix.config.environment_script }}" && set - OUTPUT_FILE environment_script_output.txt - ) - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") - - # If ccache shows some strange behavior on windows, you can easily - # disable it here by setting the variable to "OFF" - if (NOT "${{ runner.os }}" STREQUAL "Windows") - set(enable_ccache "ON") - else() - set(enable_ccache "ON") - endif() - - execute_process( - COMMAND cmake - -S . - -B build - -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -G Ninja - -D USE_CCACHE=${enable_ccache} - -D CMAKE_MAKE_PROGRAM=ninja - -D ASAP_BUILD_TESTS=ON - -D ASAP_BUILD_EXAMPLES=ON - -D CMAKE_INSTALL_PREFIX=install - -D CMAKE_VERBOSE_MAKEFILE=ON - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() - - - name: Build - shell: cmake -P {0} - run: | - set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") - - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - - execute_process( - COMMAND cmake --build build --target all - RESULT_VARIABLE result - OUTPUT_VARIABLE output - ERROR_VARIABLE output - ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE - ) - if (NOT result EQUAL 0) - string(REGEX MATCH "FAILED:.*$" error_message "${output}") - string(REPLACE "\n" "%0A" error_message "${error_message}") - message("::error::${error_message}") - message(FATAL_ERROR "Build failed") - endif() - - - name: Run tests - shell: cmake -P {0} - run: | - include(ProcessorCount) - ProcessorCount(N) - - set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") - - execute_process( - COMMAND ctest -j ${N} - WORKING_DIRECTORY build - RESULT_VARIABLE result - OUTPUT_VARIABLE output - ERROR_VARIABLE output - ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE - ) - if (NOT result EQUAL 0) - string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec.*$" test_results "${output}") - string(REPLACE "\n" "%0A" test_results "${test_results}") - message("::error::${test_results}") - message(FATAL_ERROR "Running tests failed!") - endif() - - - name: Install Strip - run: cmake --install build --strip - - - name: Pack - working-directory: install - run: cmake -E tar cfv ../${{ matrix.config.artifact }} --format=7zip . - - - name: Upload - uses: actions/upload-artifact@v1 - with: - path: ./${{ matrix.config.artifact }} - name: ${{ matrix.config.artifact }} - - release: - if: contains(github.ref, 'tags/v') - runs-on: ubuntu-latest - needs: build - - steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Store Release url - run: | - echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url - - - uses: actions/upload-artifact@v1 - with: - path: ./upload_url - name: upload_url - - publish: - if: contains(github.ref, 'tags/v') - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Windows Latest MSVC", - artifact: "Windows-MSVC.7z", - os: windows-latest, - } - - { - name: "Ubuntu Latest GCC", - artifact: "Linux.7z", - os: ubuntu-latest, - } - - { - name: "macOS Latest Clang", - artifact: "macOS.7z", - os: macos-latest, - } - needs: release - - steps: - - name: Download artifact - uses: actions/download-artifact@v1 - with: - name: ${{ matrix.config.artifact }} - path: ./ - - - name: Download URL - uses: actions/download-artifact@v1 - with: - name: upload_url - path: ./ - - - id: set_upload_url - run: | - upload_url=`cat ./upload_url` - echo ::set-output name=upload_url::$upload_url - shell: bash - - - name: Upload to Release - id: upload_to_release - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.set_upload_url.outputs.upload_url }} - asset_path: ./${{ matrix.config.artifact }} - asset_name: ${{ matrix.config.artifact }} - asset_content_type: application/x-gtar diff --git a/.github/workflows/macos-builds.yml b/.github/workflows/macos-builds.yml new file mode 100644 index 00000000..cbe40af0 --- /dev/null +++ b/.github/workflows/macos-builds.yml @@ -0,0 +1,86 @@ +name: macos-builds + +on: workflow_call + +env: + CMAKE_VERSION: 3.21.1 + NINJA_VERSION: 1.11.1 + CCACHE_VERSION: 4.8 + CC: clang + CXX: clang++ + +jobs: + dev-build: + runs-on: macos-latest + strategy: + matrix: + generator: ['Unix Makefiles', Xcode] + build_type: [Debug, Release] + include: + - build_type: Debug + examples: ON + tests: OFF # the template asap has no unit tests + - build_type: Release + examples: ON + tests: OFF # the template asap has no unit tests + + steps: + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1 + with: + cmake-version: ${{ env.CMAKE_VERSION }} + + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + with: + install_ccache: true + update_packager_index: false + prepend_symlinks_to_path: false + + - name: Setup XCode + if: matrix.generator == 'Xcode' + uses: mobiledevops/xcode-select-version-action@v1 + with: + xcode-select-version: 13.1 + + - name: Log environment properties + run: | + echo "Build Type : ${{matrix.build_type}}" + echo "Generator : ${{matrix.generator}}" + cmake --version + clang --version + ccache --version + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure build + working-directory: ${{runner.workspace}} + run: | + cmake -B build -S $GITHUB_WORKSPACE \ + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -G "${{ matrix.generator }}" \ + -D USE_CCACHE=ON \ + -D ASAP_BUILD_TESTS=${{matrix.tests}} \ + -D ASAP_BUILD_EXAMPLES=${{matrix.examples}} \ + -D ASAP_BUILD_DOCS=OFF \ + -D CMAKE_INSTALL_PREFIX=install \ + -D CMAKE_VERBOSE_MAKEFILE=ON + + - name: Build main targets + working-directory: ${{runner.workspace}} + run: | + cmake --build build --config ${{matrix.build_type}} + + - name: Build test targets + working-directory: ${{runner.workspace}} + if: ${{ matrix.tests == true }} + run: | + cmake --build build --config ${{matrix.build_type}} --target build-all-tests + + - name: Run tests with ctest + working-directory: ${{runner.workspace}} + # Hardcode 2 cores we know are there + run: | + ctest --test-dir build -C ${{matrix.build_type}} -j 2 --output-on-failure diff --git a/.github/workflows/ubuntu-builds.yml b/.github/workflows/ubuntu-builds.yml new file mode 100644 index 00000000..e3477aee --- /dev/null +++ b/.github/workflows/ubuntu-builds.yml @@ -0,0 +1,198 @@ +name: ubuntu-builds + +on: workflow_call + +env: + CMAKE_VERSION: 3.21.1 + NINJA_VERSION: 1.11.1 + CCACHE_VERSION: 4.8 + CC: '' + CXX: '' + GCC_VERSION: '' + CLANG_VERSION: '' + +jobs: + dev-build: + runs-on: ubuntu-22.04 + strategy: + matrix: + compiler: [gcc-10, gcc-11, gcc-12, clang-14, clang-15, clang-16] + build_type: [Debug, Release] + include: + - build_type: Debug + examples: ON + tests: OFF # the template asap has no unit tests + - build_type: Release + examples: ON + tests: OFF # the template asap has no unit tests + + steps: + - name: Split compiler name and version + id: split + env: + COMPILER: ${{ matrix.compiler }} + COMPILER_NAME: '' + COMPILER_VERSION: '' + run: | + COMPILER_NAME=${COMPILER%%-*} + COMPILER_VERSION=${COMPILER##*-} + echo "compiler_name=$COMPILER_NAME" >> $GITHUB_OUTPUT + if [ $COMPILER_NAME == 'gcc' ] + then + echo "gcc_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT + elif [ $COMPILER_NAME == 'clang' ] + then + echo "clang_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT + echo "gcc_version=11" >> $GITHUB_OUTPUT + fi + + - name: Install basic OS packages + run: | + sudo apt-get -qq update + sudo apt-get -qq -y install \ + software-properties-common \ + apt-transport-https \ + lsb-release \ + ca-certificates \ + curl \ + gnupg \ + build-essential + + - name: Install GCC (always runs) + run: | + # sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt-get -qq update && \ + sudo apt-get -qq -y install gcc-${{steps.split.outputs.gcc_version}} g++-${{steps.split.outputs.gcc_version}} + + - name: Install clang (only if building with clang) + if: ${{ steps.split.outputs.compiler_name == 'clang' }} + run: | + curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{steps.split.outputs.clang_version}} main' + sudo apt-get -qq update + sudo apt-get -qq -y install \ + libllvm${{steps.split.outputs.clang_version}} \ + llvm-${{steps.split.outputs.clang_version}} \ + llvm-${{steps.split.outputs.clang_version}}-dev \ + llvm-${{steps.split.outputs.clang_version}}-runtime \ + llvm-${{steps.split.outputs.clang_version}}-linker-tools \ + lld-${{steps.split.outputs.clang_version}} \ + clang-${{steps.split.outputs.clang_version}} \ + clang-tools-${{steps.split.outputs.clang_version}} \ + clang-format-${{steps.split.outputs.clang_version}} \ + libclang1-${{steps.split.outputs.clang_version}} \ + libc++-${{steps.split.outputs.clang_version}}-dev \ + libc++abi-${{steps.split.outputs.clang_version}}-dev \ + clang-format-${{steps.split.outputs.clang_version}} \ + python3-clang-${{steps.split.outputs.clang_version}} \ + clang-tools-${{steps.split.outputs.clang_version}} \ + clang-tidy-${{steps.split.outputs.clang_version}} + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Use GNU compilers (only if building with gcc/g++) + if: ${{ steps.split.outputs.compiler_name == 'gcc' }} + run: | + echo "CC=gcc" >> $GITHUB_ENV + echo "CXX=g++" >> $GITHUB_ENV + sudo update-alternatives --install \ + /usr/bin/gcc gcc /usr/bin/gcc-${{steps.split.outputs.gcc_version}} 110 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-${{steps.split.outputs.gcc_version}} \ + --slave /usr/bin/gcov gcov /usr/bin/gcov-${{steps.split.outputs.gcc_version}} + + - name: Use clang (only if building with clang/clang++) + if: ${{ steps.split.outputs.compiler_name == 'clang' }} + run: | + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + for command in clang clang++ clang-apply-replacements clang-check \ + clang-query clang-tidy clang-format scan-build scan-view llvm-cov \ + llvm-profdata + do + sudo update-alternatives --install /usr/bin/$command $command \ + /usr/bin/$command-${{steps.split.outputs.clang_version}} 110 + done + clang --version + + - name: Setup ninja + # Do not use ninja-build from the distro repos as it is always old + uses: abdes/gha-setup-ninja@master + with: + version: ${{ env.NINJA_VERSION }} + + - name: Setup cmake + # Do not use cmake from the distro repos as it is not the version we + # want + uses: jwlawson/actions-setup-cmake@v1 + with: + cmake-version: ${{ env.CMAKE_VERSION }} + + - name: Install ccache from latest + run: | + CCACHE_DIST="ccache-${{ env.CCACHE_VERSION }}-linux-x86_64" + CCACHE_URL="https://github.com/ccache/ccache/releases/download/v$CCACHE_VERSION/$CCACHE_DIST.tar.xz" + echo "Installing ccache from: $CCACHE_URL" + curl -s -L -o ./ccache.tar.xz $CCACHE_URL + tar xf ./ccache.tar.xz + rm -f ./ccache.tar.xz + echo "$GITHUB_WORKSPACE/$CCACHE_DIST" >> $GITHUB_PATH + + - name: Log environment properties + run: | + echo "Build Type : ${{matrix.build_type}}" + echo "Compiler Name : ${{steps.split.outputs.compiler_name}}" + if [ ${{steps.split.outputs.compiler_name}} == 'clang' ] + then + echo "Clang Version : ${{steps.split.outputs.clang_version}}" + fi + echo "GCC Version : ${{steps.split.outputs.gcc_version}}" + ninja --version + cmake --version + gcc --version + clang --version + ccache --version + + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + with: + install_ccache: false + update_packager_index: false + prepend_symlinks_to_path: false + windows_compile_environment: msvc # this field is required + + - name: Configure build + working-directory: ${{runner.workspace}} + run: | + cmake -B build -S $GITHUB_WORKSPACE \ + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -G Ninja \ + -D CMAKE_MAKE_PROGRAM=ninja \ + -D USE_CCACHE=ON \ + -D ASAP_BUILD_TESTS=${{matrix.tests}} \ + -D ASAP_BUILD_EXAMPLES=${{matrix.examples}} \ + -D ASAP_BUILD_DOCS=OFF \ + -D CMAKE_INSTALL_PREFIX=install \ + -D CMAKE_VERBOSE_MAKEFILE=ON + + - name: Build main targets + working-directory: ${{runner.workspace}} + run: | + cmake --build build --target all + + - name: Build test targets + working-directory: ${{runner.workspace}} + if: ${{ matrix.tests == true }} + run: | + cmake --build build --target build-all-tests + + - name: Run tests with ctest + working-directory: ${{runner.workspace}} + # Hardcode 2 cores we know are there + run: | + ctest \ + --test-dir build \ + -C ${{matrix.build_type}} \ + -j 2 \ + --output-on-failure diff --git a/.github/workflows/windows-builds.yml b/.github/workflows/windows-builds.yml new file mode 100644 index 00000000..34d92891 --- /dev/null +++ b/.github/workflows/windows-builds.yml @@ -0,0 +1,91 @@ +name: windows-builds + +on: workflow_call + +env: + CMAKE_VERSION: 3.21.1 + NINJA_VERSION: 1.11.1 + CCACHE_VERSION: 4.8 + +jobs: + dev-build: + runs-on: windows-latest + strategy: + matrix: + generator: ['Ninja', 'NMake Makefiles', 'Visual Studio 17 2022'] + build_type: [Debug, Release] + include: + - build_type: Debug + examples: ON + tests: OFF # the template asap has no unit tests + - build_type: Release + examples: ON + tests: OFF # the template asap has no unit tests + + steps: + - name: Setup ninja (only if the generator is 'Ninja') + if: matrix.generator == 'Ninja' + uses: abdes/gha-setup-ninja@master + with: + version: ${{ env.NINJA_VERSION }} + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1 + with: + cmake-version: ${{ env.CMAKE_VERSION }} + + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + with: + install_ccache: true + update_packager_index: false + prepend_symlinks_to_path: false + windows_compile_environment: msvc # this field is required + + - name: Set MSVC environment + uses: ilammy/msvc-dev-cmd@v1 + + - name: Log environment properties + run: | + echo "Build Type : ${{matrix.build_type}}" + echo "Generator : ${{matrix.generator}}" + if ('${{matrix.generator}}' -eq 'Ninja') { + ninja --version + } + cmake --version + ccache --version + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure build + working-directory: ${{runner.workspace}} + run: | + cmake -B build -S asap ` + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} ` + -G "${{ matrix.generator }}" ` + -D USE_CCACHE=ON ` + -D ASAP_BUILD_TESTS=${{matrix.tests}} ` + -D ASAP_BUILD_EXAMPLES=${{matrix.examples}} ` + -D ASAP_BUILD_DOCS=OFF ` + -D CMAKE_INSTALL_PREFIX=install ` + -D CMAKE_VERBOSE_MAKEFILE=ON + dir build + + - name: Build main targets + working-directory: ${{runner.workspace}} + run: | + cmake --build build --config ${{matrix.build_type}} + + - name: Build test targets + working-directory: ${{runner.workspace}} + if: matrix.tests == true + run: | + cmake --build build --config ${{matrix.build_type}} --target build-all-tests + + - name: Run tests with ctest + working-directory: ${{runner.workspace}} + # Hardcode 2 cores we know are there + run: | + ctest --test-dir build -C ${{matrix.build_type}} -j 2 --output-on-failure diff --git a/.vscode/settings.json b/.vscode/settings.json index 4783ab06..ae392489 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { - "esbonio.sphinx.confDir": "doc", + "esbonio.sphinx.confDir": "${workspaceFolder}/doc", + "esbonio.sphinx.buildDir": "${workspaceFolder}/out/html", "editor.rulers": [ 80, 100 @@ -292,4 +293,4 @@ "files.exclude": { "**/.sphinx": true }, -} +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 48045331..e54a4565 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,9 @@ asap_push_project(${META_PROJECT_NAME}) # Project options # cmake-format: off option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON) -option(ASAP_BUILD_TESTS "Build tests." OFF) -option(ASAP_BUILD_EXAMPLES "Build examples." OFF) +option(ASAP_BUILD_TESTS "Setup target to build and run tests." OFF) +option(ASAP_BUILD_EXAMPLES "Setup target to build the examples." OFF) +option(ASAP_BUILD_DOCS "Setup target to build the doxygen and sphinx docs." ON) option(ASAP_WITH_GOOGLE_ASAN "Instrument code with address sanitizer" OFF) option(ASAP_WITH_GOOGLE_UBSAN "Instrument code with undefined behavior sanitizer" OFF) option(ASAP_WITH_GOOGLE_TSAN "Instrument code with thread sanitizer" OFF) @@ -146,18 +147,22 @@ configure_file(.clangd.in ${CMAKE_SOURCE_DIR}/.clangd @ONLY) # Documentation - doxygen, sphinx/breathe/exhale # ------------------------------------------------------------------------------ -# Doxygen -set(DOXYGEN_BUILD_DIR "${CMAKE_BINARY_DIR}/dox") -include(DoxGeneration) +if (ASAP_BUILD_DOCS) + # Doxygen + set(DOXYGEN_BUILD_DIR "${CMAKE_BINARY_DIR}/dox") + include(DoxGeneration) -# Sphinx/breathe/exhale -set(SPHINX_BUILD_DIR "${CMAKE_BINARY_DIR}/sphinx") -include(SphinxGeneration) + # Sphinx/breathe/exhale + set(SPHINX_BUILD_DIR "${CMAKE_BINARY_DIR}/sphinx") + include(SphinxGeneration) +endif() # ------------------------------------------------------------------------------ # Testing # ------------------------------------------------------------------------------ +include(CTest) + if(ASAP_BUILD_TESTS) include(GoogleSanitizers) include(CodeCoverage) @@ -177,7 +182,6 @@ if(ASAP_BUILD_TESTS) "INSTALL_GTEST OFF") include(GoogleTest) - include(CTest) endif() # ------------------------------------------------------------------------------ diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 8302129a..cce9b677 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -7,8 +7,8 @@ # Do this only once for the project by checking if we already have loaded CPM # which will define the CURRENT_CPM_VERSION, and if that version is what we want # to have here. -if(NOT CURRENT_CPM_VERSION VERSION_EQUAL 0.35.6) - set(CPM_DOWNLOAD_VERSION 0.35.6) +if(NOT CURRENT_CPM_VERSION VERSION_EQUAL 0.38.7) + set(CPM_DOWNLOAD_VERSION 0.38.1) if(CPM_SOURCE_CACHE) # Expand relative path. This is important if the provided path contains a diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake index 0f5e8bdb..da1138b2 100644 --- a/cmake/CompileOptions.cmake +++ b/cmake/CompileOptions.cmake @@ -57,8 +57,8 @@ function(asap_set_compile_options) if(NOT x_WARNING) target_compile_options(${target} PRIVATE /WX) endif() - # Enable coverage profiling in Debug builds - # (see https://github.com/abdes/asap/issues/22) + # Enable coverage profiling in Debug builds (see + # https://github.com/abdes/asap/issues/22) target_link_options(${target} PRIVATE $<$:/PROFILE>) endforeach() endif() diff --git a/cmake/SphinxGeneration.cmake b/cmake/SphinxGeneration.cmake index b0388c46..41fb2a4f 100644 --- a/cmake/SphinxGeneration.cmake +++ b/cmake/SphinxGeneration.cmake @@ -90,27 +90,26 @@ if(SPHINX_FOUND) # invoked. set_target_properties(sphinx PROPERTIES EXCLUDE_FROM_ALL TRUE) - # Add a target for copying the index.html from the doc dir to the sphinx - # build dir. A dependency on this target will be added to the master sphinx - # target. - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.html - COMMAND - ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/doc/index.html - ${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.html - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/doc/index.html) - add_custom_target(copy_doc_index ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.html) - # Setup sphinx doc master target and add other submodules as dependencies function(_add_master_sphinx_target) _master_sphinx_target() asap_with_sphinx(${master_sphinx_target}) - add_dependencies( - ${master_sphinx_target}_sphinx copy_doc_index - # Add more submodule documentation targets after this, using variables - # in the target names consistently with the module's CMakeLists.txt. - ) + + set(index_file_src "${CMAKE_CURRENT_SOURCE_DIR}/doc/index.html") + set(index_file_out "${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.html") + if(EXISTS ${index_file_src}) + message( + STATUS "Will use project custom doc index file: ${index_file_src}") + # Add a target for copying the index.html from the doc dir to the sphinx + # build dir. A dependency on this target will be added to the master + # sphinx target. + add_custom_command( + OUTPUT ${index_file_out} + COMMAND ${CMAKE_COMMAND} -E copy ${index_file_src} ${index_file_out} + DEPENDS ${index_file_src}) + add_custom_target(copy_doc_index ALL DEPENDS ${index_file_out}) + add_dependencies(${master_sphinx_target}_sphinx copy_doc_index) + endif() add_dependencies(sphinx ${master_sphinx_target}_sphinx) endfunction() _add_master_sphinx_target() diff --git a/cmake/common b/cmake/common index 6376d609..954e6ceb 160000 --- a/cmake/common +++ b/cmake/common @@ -1 +1 @@ -Subproject commit 6376d60940d252b7e303bf01486e88d839bb03b5 +Subproject commit 954e6cebe4c902d07d33beef166df89073a7b4f2 diff --git a/doc/conf.py.in b/doc/conf.py.in index 587d3b11..f81f445e 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -48,9 +48,16 @@ extensions = [ 'sphinx.ext.viewcode', 'sphinx-prompt', 'sphinx_copybutton', - 'myst_parser' + 'myst_parser', + 'breathe' ] +# Setup the breathe extension +# breathe_projects = { +# "xxxxxx": "@DOXYGEN_BUILD_DIR@/asap_xxxxxx/xml" +# } +# breathe_default_project = "xxxxxx" + # Tell sphinx what the primary language being documented is. primary_domain = 'cpp' @@ -115,7 +122,7 @@ html_theme_options = { "use_fullscreen_button": True, # We don't want the default navigation bar footer to be displayed on every # page. Mention of the book theme will be added in the home page. - "extra_navbar": "" + "extra_footer": "" } # -- Extension configuration ------------------------------------------------- @@ -125,11 +132,8 @@ html_theme_options = { intersphinx_mapping = { # Add intersphinx config for submodules and third party libs # 'common': ( - # 'https://abdes.github.io/asap/asap_common/html', - # '@SPHINX_BUILD_DIR@/asap_common/html/objects.inv'), - # 'contract': ( - # 'https://abdes.github.io/asap/asap_contract/html', - # '@SPHINX_BUILD_DIR@/asap_contract/html/objects.inv'), + # 'https://asap-projects.github.io/asap-common/asap_common/html', + # 'https://asap-projects.github.io/asap-common/asap_common/html/objects.inv'), } # -- Options for todo extension ---------------------------------------------- diff --git a/doc/index.rst b/doc/index.rst index b4ac5fe9..3ebe4661 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -22,7 +22,6 @@ Last Updated on |date| getting-started/index project-development/index documentation/index - library-modules/index tools/index license changelog.md @@ -41,29 +40,20 @@ Parts of the documentation :doc:`Getting Started! ` ----------------------------------------------- - *start here to understand how to use this project as a starter for your own project* :doc:`Project Development ` ------------------------------------------------------ - *refer to this part of the documentation to understand the build system specifics for this project, the development workflow, coding and unit testing guidelines* :doc:`Documentation ` ------------------------------------------ - *refer to this part of the documentation to understand how project documentation is structured and built from source using `doxygen` and `sphinx`.* -:doc:`Library Modules ` ----------------------------------------------- -*check this out to explore the different modules part of this project. From -there, you can also jump to the detailed API documentation of each of those -modules.* - :doc:`Project Tools ` ---------------------------------- *get an introduction to the programs and scripts under the `tools` folder, @@ -74,7 +64,7 @@ use the project artifacts.* Acknowledgements ================ -.. figure:: https://executablebooks.org/en/latest/_static/logo-wide.png +.. figure:: https://executablebooks.org/en/latest/_static/logo-wide.svg :figclass: margin :alt: Executable Books Project :name: executable_book_logo diff --git a/doc/library-modules/index.rst b/doc/library-modules/index.rst deleted file mode 100644 index 6a11656d..00000000 --- a/doc/library-modules/index.rst +++ /dev/null @@ -1,35 +0,0 @@ -.. Structure conventions - # with overline, for parts - * with overline, for chapters - = for sections - - for subsections - ^ for sub-subsections - " for paragraphs - -############### -Library Modules -############### - -.. |date| date:: - -Last Updated on |date| - -.. toctree:: - :maxdepth: 2 - :titlesonly: - :hidden: - -.. - Add modules below, for example: - - Module: common - Module: contract - - The `asap` projects comes with two built-in modules, offering some core basic - functionality: - - :doc:`common ` - ============================ - *offers some core and low level features such as platform/environment - detection and C++ language features not consistently provided by all - compilers on all platforms.* diff --git a/doc/project-development/modules.rst b/doc/project-development/modules.rst index 71d0fd56..4282b090 100644 --- a/doc/project-development/modules.rst +++ b/doc/project-development/modules.rst @@ -206,48 +206,40 @@ Adding documentation to a module Documentation comes in two forms: `doxygen` API documentation and `sphinx` documentation. The former is embedded in the source code files, while the latter is written in its own separate files placed in a ```doc``` subdirectory under -the module root. - -1. The contents of the `doc` directory can be started by copying some of the - files from another existing module. In particular, the ```conf.py.in``` file, - can be copied from an existing module and used without modification. - - The module's `CMakeLists.txt` should then be modified to add the targets for - `doxygen` and `sphinx` documentation build as appropriate. - - .. code-block:: CMake - - # -------------------------------------------- - # API Documentation - # -------------------------------------------- - - asap_with_doxygen( - MODULE_NAME - ${MODULE_TARGET_NAME} - VERSION - ${META_MODULE_VERSION} - TITLE - "\"MyApp Module\"" - BRIEF - "\"Provides some stuff for MyApp.\"" - INPUT_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include") - - asap_with_sphinx(${MODULE_TARGET_NAME}) - -2. Add target dependencies from the master sphinx documentation target to the - module's sphinx documentation target. This step is only required if you have - added a module sphinx documentation target. - - .. code-block:: CMake - - add_dependencies(master_sphinx - copy_doc_index - # Hardcode `asap` in the module name as we do not want this prefix to - # change with the forked project name. - asap_common_sphinx - asap_logging_sphinx - # Add more submodule documentation targets after this, using variables - # in the target names consistently with the module's CMakeLists.txt. - myapp - ) +the module root or in a sub-directory under the root ```doc``` directory. + +The module's `CMakeLists.txt` should be modified to add the targets for +`doxygen` as appropriate. .. code-block:: CMake + +.. code-block:: CMake + + asap_with_doxygen( + MODULE_NAME + ${MODULE_TARGET_NAME} + VERSION + ${META_MODULE_VERSION} + TITLE + "\"MyApp Module\"" + BRIEF + "\"Provides some stuff for MyApp.\"" + INPUT_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include") + +For sphinx documentation, the recommended approach is to have all documentation +reside within the root ```doc``` directory in order to be able to have one +single configuration file and most importantly in order to make most IDEs happy +and generate previews. + +The contents of the `doc` directory can be started by copying some of the files +from another existing module. In particular, the ```conf.py.in``` file, can be +copied from an existing module and used without modification. + +If the module documentation is preferred to be inside the module itself, then a +separate sphinx project is required. The module's `CMakeLists.txt` should then +be modified to add the targets for `doxygen` and `sphinx` documentation build as +appropriate. The module's `CMakeLists.txt` should then be modified to add the targets for +`sphinx` as appropriate. + +.. code-block:: CMake + + asap_with_sphinx(${MODULE_TARGET_NAME}) diff --git a/doxygen/doxygen-awesome-css b/doxygen/doxygen-awesome-css index 245c7c94..df88fe4f 160000 --- a/doxygen/doxygen-awesome-css +++ b/doxygen/doxygen-awesome-css @@ -1 +1 @@ -Subproject commit 245c7c94c20eac22730ef89035967f78b77bf405 +Subproject commit df88fe4fdd97714fadfd3ef17de0b4401f804052 diff --git a/tools/version-info/CMakeLists.txt b/tools/version-info/CMakeLists.txt index d30acf29..56277671 100644 --- a/tools/version-info/CMakeLists.txt +++ b/tools/version-info/CMakeLists.txt @@ -48,7 +48,6 @@ asap_add_executable(${MODULE_TARGET_NAME} WARNING SOURCES "src/main.cpp") target_compile_features(${MODULE_TARGET_NAME} PUBLIC cxx_constexpr) -target_compile_features(${MODULE_TARGET_NAME} PUBLIC cxx_constexpr) cmake_path(SET version_include_dir ${CMAKE_CURRENT_BINARY_DIR}/../../include NORMALIZE) target_include_directories( @@ -60,12 +59,11 @@ target_include_directories( # Run executable test # ------------------------------------------------------------------------------ -if(ASAP_BUILD_TESTS) - add_test( - NAME version-info - COMMAND ${MODULE_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -endif() +# Always run the version-info as part of ctest suite +add_test( + NAME "Misc:version-info" + COMMAND ${MODULE_TARGET_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # ============================================================================== # Deployment instructions