From e60491fc6994ccd77a7bc101c49c5b7e1eb1a379 Mon Sep 17 00:00:00 2001
From: Don Kjer <don@lindenlab.com>
Date: Thu, 11 Oct 2012 20:10:11 +0000
Subject: [PATCH] Adding multi-arch hints to CMake, allowing it to correctly
 find libraries on multi-arch debian-based systems.

---
 indra/cmake/Variables.cmake | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 28315e66e07..405d80aeb09 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -73,19 +73,36 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
   # If someone has specified a word size, use that to determine the
   # architecture.  Otherwise, let the architecture specify the word size.
   if (WORD_SIZE EQUAL 32)
+    #message(STATUS "WORD_SIZE is 32")
     set(ARCH i686)
   elseif (WORD_SIZE EQUAL 64)
+    #message(STATUS "WORD_SIZE is 64")
     set(ARCH x86_64)
   else (WORD_SIZE EQUAL 32)
+    #message(STATUS "WORD_SIZE is UNDEFINED")
     execute_process(COMMAND uname -m COMMAND sed s/i.86/i686/
                     OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
     if (ARCH STREQUAL x86_64)
+      #message(STATUS "ARCH is detected as 64; ARCH is ${ARCH}")
       set(WORD_SIZE 64)
     else (ARCH STREQUAL x86_64)
+      #message(STATUS "ARCH is detected as 32; ARCH is ${ARCH}")
       set(WORD_SIZE 32)
     endif (ARCH STREQUAL x86_64)
   endif (WORD_SIZE EQUAL 32)
 
+  if (WORD_SIZE EQUAL 32)
+    set(DEB_ARCHITECTURE i386)
+  else (WORD_SIZE EQUAL 32)
+    set(DEB_ARCHITECTURE amd64)
+  endif (WORD_SIZE EQUAL 32)
+
+  execute_process(COMMAND dpkg-architecture -a${DEB_ARCHITECTURE} -qDEB_HOST_MULTIARCH RESULT_VARIABLE DPKG_RESULT OUTPUT_VARIABLE DPKG_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
+  #message (STATUS "DPKG_RESULT ${DPKG_RESULT}, DPKG_ARCH ${DPKG_ARCH}")
+  if (DPKG_RESULT EQUAL 0)
+    set(CMAKE_LIBRARY_ARCHITECTURE ${DPKG_ARCH})
+  endif (DPKG_RESULT EQUAL 0)
+
   set(LL_ARCH ${ARCH}_linux)
   set(LL_ARCH_DIR ${ARCH}-linux)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-- 
GitLab