windows.yml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. name: Windows
  2. on: [push, pull_request]
  3. jobs:
  4. build-mingw:
  5. name: ${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}
  6. runs-on: windows-latest
  7. defaults:
  8. run:
  9. shell: msys2 {0}
  10. env:
  11. CCACHE_DIR: ${{github.workspace}}/ccache
  12. strategy:
  13. fail-fast: true
  14. matrix:
  15. build_type: [Release]
  16. sys: [mingw32, mingw64]
  17. lib: [shared, static]
  18. include:
  19. - sys: mingw32
  20. env: i686
  21. - sys: mingw64
  22. env: x86_64
  23. steps:
  24. - uses: actions/checkout@v3
  25. - name: Setup Dependencies
  26. uses: msys2/setup-msys2@v2
  27. with:
  28. msystem: ${{matrix.sys}}
  29. install: >-
  30. mingw-w64-${{matrix.env}}-ccache
  31. mingw-w64-${{matrix.env}}-cmake
  32. mingw-w64-${{matrix.env}}-eigen3
  33. mingw-w64-${{matrix.env}}-gcc
  34. mingw-w64-${{matrix.env}}-gflags
  35. mingw-w64-${{matrix.env}}-glog
  36. mingw-w64-${{matrix.env}}-metis
  37. mingw-w64-${{matrix.env}}-ninja
  38. mingw-w64-${{matrix.env}}-suitesparse
  39. - name: Setup Environment
  40. if: ${{matrix.build_type == 'Release'}}
  41. run: |
  42. echo 'CFLAGS=-flto' >> ~/.bash_profile
  43. echo 'CXXFLAGS=-flto' >> ~/.bash_profile
  44. - name: Cache Build
  45. id: cache-build
  46. uses: actions/cache@v3
  47. with:
  48. path: ${{env.CCACHE_DIR}}
  49. key: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-ccache-${{github.run_id}}
  50. restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-ccache-
  51. - name: Configure
  52. run: |
  53. cmake -S . -B build_${{matrix.build_type}}/ \
  54. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
  55. -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
  56. -DCMAKE_C_COMPILER_LAUNCHER:FILEPATH=ccache \
  57. -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \
  58. -G Ninja
  59. - name: Build
  60. run: |
  61. cmake --build build_${{matrix.build_type}}/ \
  62. --config ${{matrix.build_type}}
  63. - name: Test
  64. run: |
  65. cd build_${{matrix.build_type}}/
  66. ctest --config ${{matrix.build_type}} \
  67. --output-on-failure \
  68. -j$(nproc)
  69. - name: Install
  70. run: |
  71. cmake --build build_${{matrix.build_type}}/ \
  72. --config ${{matrix.build_type}} \
  73. --target install
  74. build-msvc:
  75. name: ${{matrix.msvc}}-${{matrix.arch}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}
  76. runs-on: ${{matrix.os}}
  77. defaults:
  78. run:
  79. shell: powershell
  80. env:
  81. CL: /MP
  82. CMAKE_GENERATOR: ${{matrix.generator}}
  83. CMAKE_GENERATOR_PLATFORM: ${{matrix.arch}}
  84. strategy:
  85. fail-fast: true
  86. matrix:
  87. arch:
  88. - x64
  89. build_type:
  90. - Release
  91. msvc:
  92. - VS-16-2019
  93. - VS-17-2022
  94. lib:
  95. - shared
  96. gpu:
  97. - cuda
  98. - no-cuda
  99. include:
  100. - msvc: VS-16-2019
  101. os: windows-2019
  102. generator: 'Visual Studio 16 2019'
  103. marker: vc16
  104. - msvc: VS-17-2022
  105. os: windows-2022
  106. generator: 'Visual Studio 17 2022'
  107. marker: vc17
  108. steps:
  109. - uses: actions/checkout@v3
  110. - name: Download and install CUDA toolkit
  111. if: matrix.gpu == 'cuda'
  112. run: |
  113. Invoke-WebRequest https://developer.download.nvidia.com/compute/cuda/12.2.1/network_installers/cuda_12.2.1_windows_network.exe -OutFile cuda_toolkit_windows.exe
  114. Start-Process -Wait -FilePath .\cuda_toolkit_windows.exe -ArgumentList "-s cusolver_dev_12.2 cusparse_dev_12.2 cublas_dev_12.2 thrust_12.2 nvcc_12.2 cudart_12.2 nvrtc_dev_12.2 visual_studio_integration_12.2"
  115. Remove-Item .\cuda_toolkit_windows.exe
  116. $CUDA_PATH = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2"
  117. echo "CUDA_PATH=$CUDA_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  118. echo "CUDA_PATH_V12_2=$CUDA_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  119. echo "$CUDA_PATH/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  120. - name: Cache gflags
  121. id: cache-gflags
  122. uses: actions/cache@v3
  123. with:
  124. path: gflags/
  125. key: ${{matrix.msvc}}-gflags-2.2.2-${{matrix.arch}}-${{matrix.build_type}}-${{matrix.lib}}
  126. - name: Download gflags
  127. if: steps.cache-gflags.outputs.cache-hit != 'true'
  128. run: |
  129. (New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip");
  130. Expand-Archive -Path v2.2.2.zip -DestinationPath .;
  131. - name: Setup gflags
  132. if: steps.cache-gflags.outputs.cache-hit != 'true'
  133. run: |
  134. cmake -S gflags-2.2.2 -B build-gflags `
  135. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
  136. -DBUILD_TESTING=OFF `
  137. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags
  138. cmake --build build-gflags `
  139. --config ${{matrix.build_type}} `
  140. --target install
  141. - name: Cache glog
  142. id: cache-glog
  143. uses: actions/cache@v3
  144. with:
  145. path: glog/
  146. key: ${{matrix.msvc}}-glog-0.6.0-${{matrix.arch}}-${{matrix.build_type}}-${{matrix.lib}}
  147. - name: Download glog
  148. if: steps.cache-glog.outputs.cache-hit != 'true'
  149. run: |
  150. (New-Object System.Net.WebClient).DownloadFile("https://github.com/google/glog/archive/refs/tags/v0.6.0.zip", "v0.6.0.zip");
  151. Expand-Archive -Path v0.6.0.zip -DestinationPath .;
  152. - name: Setup glog
  153. if: steps.cache-glog.outputs.cache-hit != 'true'
  154. run: |
  155. cmake -S glog-0.6.0 -B build-glog `
  156. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
  157. -DBUILD_TESTING=OFF `
  158. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/glog `
  159. -DCMAKE_PREFIX_PATH=${{github.workspace}}/gflags
  160. cmake --build build-glog `
  161. --config ${{matrix.build_type}} `
  162. --target install
  163. - name: Cache SuiteSparse
  164. id: cache-suitesparse
  165. uses: actions/cache@v3
  166. with:
  167. path: suitesparse/
  168. key: ${{matrix.msvc}}-suitesparse-5.13.0-cmake.3-${{matrix.arch}}-${{matrix.build_type}}-${{matrix.lib}}
  169. - name: Download SuiteSparse
  170. if: steps.cache-suitesparse.outputs.cache-hit != 'true'
  171. run: |
  172. (New-Object System.Net.WebClient).DownloadFile("https://github.com/sergiud/SuiteSparse/releases/download/5.13.0-cmake.3/SuiteSparse-5.13.0-cmake.3-${{matrix.marker}}-Win64-${{matrix.build_type}}-${{matrix.lib}}-gpl-metis.zip", "suitesparse.zip");
  173. Expand-Archive -Path suitesparse.zip -DestinationPath ${{github.workspace}}/suitesparse;
  174. - name: Cache Eigen
  175. id: cache-eigen
  176. uses: actions/cache@v3
  177. with:
  178. path: eigen/
  179. key: ${{runner.os}}-eigen-3.4.0
  180. - name: Download Eigen
  181. if: steps.cache-eigen.outputs.cache-hit != 'true'
  182. run: |
  183. (New-Object System.Net.WebClient).DownloadFile("https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip", "eigen-3.4.0.zip");
  184. Expand-Archive -Path eigen-3.4.0.zip -DestinationPath .;
  185. - name: Setup Eigen
  186. if: steps.cache-eigen.outputs.cache-hit != 'true'
  187. run: |
  188. cmake -S eigen-3.4.0 -B build-eigen `
  189. -DBUILD_TESTING=OFF `
  190. -DCMAKE_Fortran_COMPILER= `
  191. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/eigen `
  192. -DEIGEN_BUILD_DOC=OFF
  193. cmake --build build-eigen `
  194. --config ${{matrix.build_type}} `
  195. --target install
  196. - name: Setup Build Environment
  197. run: |
  198. echo "Eigen3_ROOT=${{github.workspace}}/eigen" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  199. echo "gflags_ROOT=${{github.workspace}}/gflags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  200. echo "glog_ROOT=${{github.workspace}}/glog" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  201. echo "CMAKE_PREFIX_PATH=${{github.workspace}}/suitesparse" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  202. - name: Setup Runtime Environment
  203. run: |
  204. echo '${{github.workspace}}\gflags\bin' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  205. echo '${{github.workspace}}\glog\bin' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  206. echo '${{github.workspace}}\suitesparse\bin' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  207. - name: Configure
  208. run: |
  209. cmake -S . -B build_${{matrix.build_type}}/ `
  210. -DBLAS_blas_LIBRARY=${{github.workspace}}/suitesparse/lib/libblas.lib `
  211. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
  212. -DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} `
  213. -DCMAKE_INSTALL_PREFIX:PATH=${{github.workspace}}/install `
  214. -DLAPACK_lapack_LIBRARY=${{github.workspace}}/suitesparse/lib/liblapack.lib
  215. - name: Build
  216. run: |
  217. cmake --build build_${{matrix.build_type}}/ `
  218. --config ${{matrix.build_type}}
  219. - name: Test
  220. if: matrix.gpu == 'no-cuda'
  221. env:
  222. CTEST_OUTPUT_ON_FAILURE: 1
  223. run: |
  224. cmake --build build_${{matrix.build_type}}/ `
  225. --config ${{matrix.build_type}} `
  226. --target RUN_TESTS
  227. - name: Install
  228. run: |
  229. cmake --build build_${{matrix.build_type}}/ `
  230. --config ${{matrix.build_type}} `
  231. --target INSTALL