build_cmake.yml 3.8 KB

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