From af1abfe41e2d6778de105a36d383388971a26a09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= <tomaszkax86@gmail.com>
Date: Sun, 13 Aug 2023 20:22:52 +0200
Subject: [PATCH] Updated CI pipeline build for Linux

---
 .github/workflows/build.yml | 16 ++++++----------
 CMakePresets.json           | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c96af8fb..a17a1e36 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -27,24 +27,20 @@ jobs:
     - name: Create build directory
       run: cmake -E make_directory build
     - name: Run CMake (for Linux)
-      working-directory: build
-      run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 ..
+      run: cmake --preset Linux-CI
       if: matrix.target_os == 'linux'
     - name: Build
-      working-directory: build
-      run: make -j `nproc`
+      run: cmake --build --preset Linux-CI
     - name: Install
-      working-directory: build
-      run: DESTDIR=. make install
+      run: cmake --build --preset Linux-CI --target install
     - name: Patch library path
-      working-directory: build
       run: patchelf --set-rpath '.' install/colobot
       if: matrix.target_os == 'linux'
     - name: Upload build
       uses: actions/upload-artifact@v2
       with:
         name: ${{matrix.target_os}}-debug
-        path: build/install
+        path: install
       if: matrix.host_os == 'ubuntu-20.04'
     - name: Create AppImage
       working-directory: build
@@ -60,8 +56,8 @@ jobs:
         
         # Prepare folder for zip
         mkdir -p appimage
-        cp -rp install/data appimage/data
-        cp -rp install/lang appimage/lang
+        cp -rp ../install/data appimage/data
+        cp -rp ../install/lang appimage/lang
         cp -p Colobot-x86_64.AppImage appimage/colobot
       if: matrix.target_os == 'linux'
     - name: Upload AppImage
diff --git a/CMakePresets.json b/CMakePresets.json
index 59af9ea3..359334a8 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -33,6 +33,20 @@
                 "TESTS": true,
                 "DESKTOP": true
             }
+        },
+        {
+            "name": "Linux-CI",
+            "description": "Linux configuration for CI pipeline",
+            "inherits": ["CI"],
+            "cacheVariables": {
+                "CMAKE_SKIP_INSTALL_RPATH": true,
+                "CMAKE_BUILD_TYPE": "RelWithDebInfo",
+                "DEV_BUILD": true,
+                "PORTABLE": true,
+                "TOOLS": true,
+                "TESTS": true,
+                "DESKTOP": true
+            }
         }
     ],
     "buildPresets": [