diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 00000000..33a4afc7 --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,112 @@ +name: Build +on: [push, pull_request] +env: + 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 + cc: "cl" + cxx: "cl" + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + - name: "Ubuntu Latest GCC" + os: ubuntu-latest + cc: "gcc-9" + cxx: "g++-9" + - name: "macOS Latest Clang" + os: macos-latest + cc: "clang" + cxx: "clang++" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Install package dependencies + id: cmake_and_ninja + shell: cmake -P {0} + run: | + if ("${{ runner.os }}" STREQUAL "Windows") + execute_process(COMMAND choco install ninja) + elseif ("${{ runner.os }}" STREQUAL "Linux") + execute_process(COMMAND sudo apt-get update) + execute_process(COMMAND sudo apt-get install libharfbuzz-dev) + execute_process(COMMAND sudo apt-get install libunibreak-dev) + execute_process(COMMAND sudo apt-get install fontconfig) + execute_process(COMMAND sudo apt-get install libgtkglext1-dev) + execute_process(COMMAND sudo apt-get install libgtk-3-devv) + elseif ("${{ runner.os }}" STREQUAL "macOS") + execute_process(COMMAND brew install fontconfig) + endif() + - name: Configure + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + # If the environment has boost_root defined, set BOOST_ROOT to it + if ( NOT "x${{ matrix.config.boost_root }}" STREQUAL "x") + set(ENV{BOOST_ROOT} $ENV{${{ matrix.config.boost_root }}}) + endif() + + # If we are on windows, run the environment script, parse it with cmake + # and set environment variables with it (required for Visual Studio) + 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() + + execute_process( + COMMAND ${CMAKE_COMMAND} + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + -G Ninja + -D CMAKE_MAKE_PROGRAM=ninja + RESULT_VARIABLE result + ERROR_VARIABLE error_message + ) + + if (NOT result EQUAL 0) + message(FATAL_ERROR "Could not run with ${CMAKE_COMMAND}: Got ${error_message} - ${result}") + endif() + - name: Build + shell: cmake -P {0} + run: | + # If we are on windows, run the environment script, parse it with cmake + # and set environment variables with it (required for Visual Studio) + 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() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build build + RESULT_VARIABLE result + ERROR_VARIABLE error_message + ) + + if (NOT result EQUAL 0) + message(FATAL_ERROR "Could not run with ${CMAKE_COMMAND}: Got ${error_message} - ${result}") + endif() diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml deleted file mode 100644 index 708539d0..00000000 --- a/.github/workflows/cmake-multi-platform.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build and Test - -on: [push, pull_request] - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. - fail-fast: false - - # Set up a matrix - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Release] - c_compiler: [gcc, clang, cl] - include: - - os: windows-latest - c_compiler: cl - cpp_compiler: cl - environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" - - os: ubuntu-latest - c_compiler: gcc - cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ - - os: macos-latest - c_compiler: "clang" - cpp_compiler: "clang++" - exclude: - - os: windows-latest - c_compiler: gcc - - os: windows-latest - c_compiler: clang - - os: ubuntu-latest - c_compiler: cl - - os: macos-latest - c_compiler: cl - c_compiler: g++ - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - name: Install package dependencies - id: cmake_and_ninja - shell: cmake -P {0} - run: | - if ("${{ runner.os }}" STREQUAL "Windows") - execute_process(COMMAND choco install ninja) - elseif ("${{ runner.os }}" STREQUAL "Linux") - execute_process(COMMAND sudo apt-get update) - execute_process(COMMAND sudo apt-get install libharfbuzz-dev) - execute_process(COMMAND sudo apt-get install libunibreak-dev) - execute_process(COMMAND sudo apt-get install fontconfig) - execute_process(COMMAND sudo apt-get install libgtkglext1-dev) - execute_process(COMMAND sudo apt-get install libgtk-3-devv) - elseif ("${{ runner.os }}" STREQUAL "macOS") - execute_process(COMMAND brew install fontconfig) - endif() - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} - - - name: Build - # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest --build-config ${{ matrix.build_type }}