build_cmake.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. name: Building(CMake)
  2. on:
  3. push:
  4. branches: [ master ]
  5. paths-ignore:
  6. - 'README.md'
  7. - 'LICENSE'
  8. pull_request:
  9. branches: [ master ]
  10. paths-ignore:
  11. - 'README.md'
  12. - 'LICENSE'
  13. env:
  14. # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  15. BUILD_TYPE: RelWithDebInfo
  16. jobs:
  17. linux-build:
  18. name: ${{ matrix.os}}
  19. runs-on: ${{ matrix.os }}
  20. strategy:
  21. matrix:
  22. os: [ubuntu-22.04]
  23. steps:
  24. - name: Checkout Source code
  25. if: github.event_name == 'push'
  26. uses: actions/checkout@v3
  27. - name: Checkout Source code
  28. if: github.event_name == 'pull_request'
  29. uses: actions/checkout@v3
  30. with:
  31. ref: ${{ github.event.pull_request.head.sha }}
  32. - name: Install Dependencies
  33. run: |
  34. sudo apt-get -y -qq update
  35. sudo apt-get -y --no-install-recommends install \
  36. cmake \
  37. extra-cmake-modules \
  38. build-essential \
  39. qtbase5-dev \
  40. qttools5-dev-tools \
  41. qttools5-dev \
  42. libqt5dbus5 \
  43. libqt5network5 \
  44. libqt5core5a \
  45. libqt5widgets5 \
  46. libqt5gui5 \
  47. libqt5svg5-dev
  48. - name: Create Build Environment
  49. # Some projects don't allow in-source building, so create a separate build directory
  50. # We'll use this as our working directory for all subsequent commands
  51. run: cmake -E make_directory ${{runner.workspace}}/build
  52. - name: Configure CMake
  53. # Use a bash shell so we can use the same syntax for environment variable
  54. # access regardless of the host operating system
  55. shell: bash
  56. working-directory: ${{runner.workspace}}/build
  57. # Note the current convention is to use the -S and -B options here to specify source
  58. # and build directories, but this is only available with CMake 3.13 and higher.
  59. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
  60. #
  61. # We need to source the profile file to make sure conan is in PATH
  62. run: |
  63. cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
  64. - name: Build
  65. working-directory: ${{runner.workspace}}/build
  66. shell: bash
  67. # Execute the build. You can specify a specific target with "--target <NAME>"
  68. run: cmake --build . --config $BUILD_TYPE
  69. - name: Test
  70. working-directory: ${{runner.workspace}}/build
  71. shell: bash
  72. # Execute tests defined by the CMake configuration.
  73. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
  74. run: ctest -C $BUILD_TYPE
  75. windows-build:
  76. runs-on: ${{ matrix.config.os }}
  77. strategy:
  78. fail-fast: false
  79. matrix:
  80. config:
  81. - {
  82. name: "Windows 2019 MSVC",
  83. artifact: "Windows-MSVC.tar.xz",
  84. os: windows-2019,
  85. cc: "cl", cxx: "cl",
  86. environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
  87. }
  88. steps:
  89. - uses: actions/checkout@v2
  90. - name: Cache Qt
  91. id: cache-qt
  92. uses: actions/cache@v3
  93. with:
  94. path: ./build/Qt
  95. key: ${{ runner.os }}-QtCache
  96. - name: Install Qt
  97. uses: jurplel/install-qt-action@v2
  98. with:
  99. version: 5.15.2
  100. target: desktop
  101. dir: '${{ github.workspace }}/build/'
  102. - name: Configure
  103. working-directory: build
  104. shell: powershell
  105. run: |
  106. cmake -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE ../
  107. - name: Build
  108. working-directory: build
  109. shell: powershell
  110. run: |
  111. cmake --build . --config $env:BUILD_TYPE