From 1b213e471ff00c0d2338bd3212bb6c0837625747 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Wed, 12 Oct 2022 20:55:42 +0200
Subject: [PATCH] CMAKE: Add a way to override the cargo path

---
 .gitlab-ci.yml | 2 +-
 CMakeLists.txt | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 609e1b49..51356792 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -31,7 +31,7 @@
         - ./rustup.sh -y --default-toolchain beta
         - source ~/.cargo/env
     script:
-        - cmake -Bbuild -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} && make -Cbuild
+        - cmake -Bbuild -DCMAKE_RUST_COMPILER=~/.cargo/bin/cargo -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} && make -Cbuild
 
 variables:
     GIT_DEPTH: 3 # No need to clone all the history
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f744475d..c1d2fed2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,6 +111,13 @@ find_program(MKVPROPEDIT mkvpropedit REQUIRED)   # To DL karas and apply metadat
 find_program(XXD         xxd         REQUIRED)   # To embed the sqlite db schemas into the binary
 find_program(CARGO       cargo       REQUIRED)   # For rust things
 
+if(CMAKE_RUST_COMPILER)
+    message(STATUS "Override cargo path: ${CMAKE_RUST_COMPILER}")
+    set(CARGO "${CMAKE_RUST_COMPILER}")
+else()
+    message(STATUS "Using cargo: ${CARGO}")
+endif()
+
 message(STATUS "The installation prefix is ${CMAKE_INSTALL_PREFIX}")
 
 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
-- 
GitLab