macos.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. name: macOS
  2. on: [push, pull_request]
  3. jobs:
  4. build:
  5. name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.target}}
  6. runs-on: ${{matrix.os}}
  7. defaults:
  8. run:
  9. shell: bash -e -o pipefail {0}
  10. env:
  11. CCACHE_DIR: ${{github.workspace}}/ccache
  12. CMAKE_GENERATOR: Ninja
  13. strategy:
  14. fail-fast: true
  15. matrix:
  16. os:
  17. - macos-11
  18. - macos-12
  19. - macos-13
  20. build_type:
  21. - Release
  22. lib:
  23. - shared
  24. - static
  25. target:
  26. - host
  27. - ios
  28. steps:
  29. - uses: actions/checkout@v3
  30. - name: Setup Dependencies (iOS)
  31. if: matrix.target == 'ios'
  32. run: |
  33. brew install \
  34. ccache \
  35. eigen \
  36. ninja
  37. - name: Setup Dependencies (Host)
  38. if: matrix.target == 'host'
  39. run: |
  40. brew install \
  41. ccache \
  42. eigen \
  43. gflags \
  44. glog \
  45. google-benchmark \
  46. metis \
  47. ninja \
  48. suite-sparse
  49. - name: Cache Build
  50. id: cache-build
  51. uses: actions/cache@v3
  52. with:
  53. path: ${{env.CCACHE_DIR}}
  54. key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.target}}-${{github.run_id}}
  55. restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.target}}-
  56. - name: Setup Environment
  57. if: matrix.build_type == 'Release'
  58. run: |
  59. echo 'CXXFLAGS=-flto' >> $GITHUB_ENV
  60. - name: Configure (iOS)
  61. if: matrix.target == 'ios'
  62. run: |
  63. cmake -S . -B build_${{matrix.build_type}} \
  64. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
  65. -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
  66. -DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
  67. -DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
  68. -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/cmake/iOS.cmake \
  69. -DEigen3_DIR=/usr/local/share/eigen3/cmake \
  70. -DIOS_PLATFORM=OS \
  71. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
  72. - name: Configure (Host)
  73. if: matrix.target == 'host'
  74. run: |
  75. cmake -S . -B build_${{matrix.build_type}} \
  76. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
  77. -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
  78. -DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
  79. -DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
  80. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
  81. - name: Build
  82. run: |
  83. cmake --build build_${{matrix.build_type}} \
  84. --config ${{matrix.build_type}}
  85. - name: Test
  86. if: matrix.target == 'host'
  87. run: |
  88. ctest --test-dir build_${{matrix.build_type}} \
  89. --config ${{matrix.build_type}} \
  90. --output-on-failure \
  91. -j$(sysctl -n hw.ncpu)
  92. - name: Install
  93. run: |
  94. cmake --build build_${{matrix.build_type}}/ \
  95. --config ${{matrix.build_type}} \
  96. --target install