cmake: fix distribution CI portability #5845
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build-cmake | |
| on: [ push, pull_request ] | |
| jobs: | |
| build-linux: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [ gcc, clang ] | |
| config: [ Release, Debug ] | |
| platform: | |
| - os: ubuntu-24.04 | |
| arch: x86_64 | |
| cuda-keyring: x86_64 | |
| jobs: 8 | |
| unity: OFF | |
| - os: ubuntu-24.04-arm | |
| arch: aarch64 | |
| cuda-keyring: sbsa | |
| jobs: 4 | |
| unity: OFF | |
| name: ${{ matrix.config }} / ${{ matrix.platform.os }} / ${{ matrix.platform.arch }} / ${{ matrix.compiler }} | |
| runs-on: ${{ matrix.platform.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: "Install Dependencies" | |
| run: | | |
| sudo apt-get update | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh 20 all | |
| sudo apt-get -y install build-essential wget cmake ninja-build uuid-dev libxinerama-dev libxcursor-dev libxi-dev libembree-dev libvulkan-dev libglfw3-dev libspdlog-dev libxxhash-dev liblmdb-dev libwayland-dev wayland-protocols | |
| - name: "Install CUDA Keyring" | |
| run: | | |
| wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/${{ matrix.platform.cuda-keyring }}/cuda-keyring_1.1-1_all.deb | |
| sudo apt-get -y remove --purge -s '*cuda*' '*nvidia*' | |
| sudo dpkg -i cuda-keyring_1.1-1_all.deb | |
| - name: "Setup CUDA" | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get -y install cuda | |
| sudo apt-get -y clean # save some space | |
| - name: "Setup Vulkan" | |
| uses: johnnynunez/setup-vulkan-sdk@v1 | |
| with: | |
| vulkan-query-version: 1.4.304.1 | |
| vulkan-components: Vulkan-Headers, Vulkan-Loader | |
| vulkan-use-cache: true | |
| - name: "Configure and Build" | |
| run: | | |
| if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
| export LUISA_CC=gcc | |
| export LUISA_CXX=g++ | |
| export LUISA_FLAGS="" | |
| else | |
| export LUISA_CC=clang-20 | |
| export LUISA_CXX=clang++-20 | |
| export LUISA_FLAGS="-stdlib=libc++" | |
| fi | |
| export LUISA_PACKAGE=OFF | |
| if [ "${{ matrix.config }}" = "Release" ]; then | |
| export LUISA_PACKAGE=ON | |
| # A distribution consumer must not need an unexported global flag. | |
| # Use Clang's platform-default system C++ runtime for the archive. | |
| export LUISA_FLAGS="" | |
| fi | |
| cmake -S . -B build -G Ninja -D LUISA_COMPUTE_ENABLE_PACKAGE_DISTRIBUTION=${LUISA_PACKAGE} -D LUISA_COMPUTE_ENABLE_RUST=OFF -D LUISA_COMPUTE_ENABLE_REMOTE=OFF -D LUISA_COMPUTE_ENABLE_CPU=OFF -D LUISA_COMPUTE_ENABLE_UNITY_BUILD=${{ matrix.platform.unity }} -D CMAKE_BUILD_TYPE=${{ matrix.config }} -D CMAKE_C_COMPILER=${LUISA_CC} -D CMAKE_CXX_COMPILER=${LUISA_CXX} -D CMAKE_CXX_FLAGS="${LUISA_FLAGS}" | |
| cmake --build build -j ${{ matrix.platform.jobs }} | |
| - name: "Build and Verify Distribution Package" | |
| if: matrix.config == 'Release' | |
| run: | | |
| cmake --build build --target luisa-compute-package-e2e | |
| - name: "Upload Distribution Package" | |
| if: matrix.config == 'Release' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: LuisaCompute-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.compiler }} | |
| path: | | |
| build/package/LuisaCompute-*.tar.gz | |
| build/package/LuisaCompute-*.tar.gz.sha256 | |
| if-no-files-found: error | |
| build-macos: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [ homebrew-clang, system-clang ] | |
| config: [ Release, Debug ] | |
| name: macOS / ${{ matrix.config }} / ${{ matrix.compiler }} | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: "Install Dependencies" | |
| run: | | |
| brew reinstall cmake | |
| brew install llvm molten-vk ninja embree vulkan-headers vulkan-loader glfw spdlog xxhash lmdb | |
| - name: "Configure and Build" | |
| run: | | |
| export LUISA_LLVM_PREFIX="$(brew --prefix llvm)" | |
| export PATH="$PATH:$LUISA_LLVM_PREFIX/bin" | |
| if [ "${{ matrix.compiler }}" = "homebrew-clang" ]; then | |
| export CC="$LUISA_LLVM_PREFIX/bin/clang" | |
| export CXX="$LUISA_LLVM_PREFIX/bin/clang++" | |
| export SDKROOT=$(xcrun --show-sdk-path) | |
| else | |
| export CC=/usr/bin/clang | |
| export CXX=/usr/bin/clang++ | |
| fi | |
| export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)" | |
| export LUISA_PACKAGE=OFF | |
| if [ "${{ matrix.config }}" = "Release" ]; then | |
| export LUISA_PACKAGE=ON | |
| fi | |
| cmake -S . -B build -G Ninja -D LUISA_COMPUTE_ENABLE_PACKAGE_DISTRIBUTION=${LUISA_PACKAGE} -D LUISA_COMPUTE_ENABLE_RUST=OFF -D LUISA_COMPUTE_ENABLE_REMOTE=OFF -D LUISA_COMPUTE_ENABLE_CPU=OFF -D LUISA_COMPUTE_ENABLE_VULKAN=OFF -D CMAKE_BUILD_TYPE=${{ matrix.config }} -D LUISA_COMPUTE_ENABLE_UNITY_BUILD=OFF | |
| cmake --build build | |
| - name: "Build and Verify Distribution Package" | |
| if: matrix.config == 'Release' | |
| run: | | |
| cmake --build build --target luisa-compute-package-e2e | |
| - name: "Upload Distribution Package" | |
| if: matrix.config == 'Release' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: LuisaCompute-macos-${{ matrix.compiler }} | |
| path: | | |
| build/package/LuisaCompute-*.tar.gz | |
| build/package/LuisaCompute-*.tar.gz.sha256 | |
| if-no-files-found: error | |
| build-windows: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: [ Release, Debug ] | |
| compiler: [ cl, clang, clang-cl ] | |
| name: Windows / ${{ matrix.config }} / ${{ matrix.compiler }} | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: "Setup Ninja" | |
| uses: ashutoshvarma/setup-ninja@master | |
| with: | |
| version: 1.11.1 | |
| - name: "Setup CUDA" | |
| uses: Jimver/cuda-toolkit@v0.2.22 | |
| with: | |
| cuda: 12.8.1 | |
| sub-packages: '[ "cudart", "nvrtc", "nvrtc_dev", "nvjitlink", "nvcc", "nvtx" ]' | |
| - name: "Setup Vulkan" | |
| uses: johnnynunez/setup-vulkan-sdk@v1 | |
| with: | |
| vulkan-query-version: 1.4.304.1 | |
| vulkan-components: Vulkan-Headers, Vulkan-Loader | |
| vulkan-use-cache: true | |
| - name: "Setup MSVC" | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: "Configure and Build" | |
| shell: cmd | |
| run: | | |
| cmake --version | |
| ninja --version | |
| IF "${{ matrix.compiler }}" == "clang" ( | |
| set CC=clang | |
| set CXX=clang++ | |
| ) ELSE ( | |
| set CC=${{ matrix.compiler }} | |
| set CXX=${{ matrix.compiler }} | |
| ) | |
| set LUISA_PACKAGE=OFF | |
| IF "${{ matrix.config }}" == "Release" set LUISA_PACKAGE=ON | |
| cmake -S . -G Ninja -B build -D LUISA_COMPUTE_ENABLE_PACKAGE_DISTRIBUTION=%LUISA_PACKAGE% -D LUISA_COMPUTE_ENABLE_RUST=OFF -D LUISA_COMPUTE_ENABLE_REMOTE=OFF -D LUISA_COMPUTE_ENABLE_CPU=OFF -D CMAKE_BUILD_TYPE=${{ matrix.config }} | |
| cmake --build build | |
| - name: "Build and Verify Distribution Package" | |
| if: matrix.config == 'Release' | |
| shell: pwsh | |
| run: | | |
| cmake --build build --target luisa-compute-package-e2e | |
| - name: "Upload Distribution Package" | |
| if: matrix.config == 'Release' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: LuisaCompute-windows-${{ matrix.compiler }} | |
| path: | | |
| build/package/LuisaCompute-*.zip | |
| build/package/LuisaCompute-*.zip.sha256 | |
| if-no-files-found: error |