From fb94c38540f300bde619d6fd6634ae390c7706a6 Mon Sep 17 00:00:00 2001
From: Amin Bandali <amin.bandali@savoirfairelinux.com>
Date: Mon, 3 Oct 2022 11:16:47 -0400
Subject: [PATCH] build: Fix find_library for contrib avutil on GNU/Linux.

* src/libclient/CMakeLists.txt: Set the right 'hint' path for the call
to find_library for ffmpeg avutil from daemon's contrib, to match the
directory name used by daemon's 'contrib/bootstrap' script: the name
of the directory is the value returned by the C++ compiler (either GNU
or Clang) when invoked with the '-dumpmachine' option.

Change-Id: I03de150aa941a1e32471e5b4cbe507e5d09787f5
---
 src/libclient/CMakeLists.txt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/libclient/CMakeLists.txt b/src/libclient/CMakeLists.txt
index 260f80fe5..79d74acbd 100644
--- a/src/libclient/CMakeLists.txt
+++ b/src/libclient/CMakeLists.txt
@@ -329,9 +329,16 @@ find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h
   ${LIBJAMI_CONTRIB_DIR}/native/ffmpeg
   ${LIBJAMI_CONTRIB_DIR}/build/ffmpeg/Build/win32/x64/include)
 include_directories(${AVUTIL_INCLUDE_DIR})
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    OUTPUT_VARIABLE CC_MACHINE)
+else()
+  set(CC_MACHINE "")
+endif()
 find_library(AVUTIL_LIBRARY avutil
   HINTS
-  ${LIBJAMI_CONTRIB_DIR}/native/ffmpeg
+  ${LIBJAMI_CONTRIB_DIR}/${CC_MACHINE}/lib
   ${LIBJAMI_CONTRIB_DIR}/x86_64-apple-darwin${CMAKE_HOST_SYSTEM_VERSION}/lib)
 
 if(ENABLE_LIBWRAP)
-- 
GitLab