[Beignet] [PATCH] Enable multiarch (32/64-bit co-installation)

Rebecca N. Palmer rebecca_palmer at zoho.com
Thu Feb 26 10:12:27 PST 2015


It is currently not possible to have 32- and 64-bit builds of beignet
installed on the same system, as the path in intel-beignet.icd
can only be one of the two installations.  This fixes this by giving
this file a different name when beignet is installed in a multiarch
directory:
intel-beignet-i386-linux-gnu.icd -> /usr/lib/i386-linux-gnu/beignet/libCL.so
intel-beignet-x86_64-linux-gnu.icd -> /usr/lib/x86_64-linux-gnu/beignet/libCL.so

Discussion and possible alternative approaches:
http://lists.alioth.debian.org/pipermail/pkg-opencl-devel/Week-of-Mon-20150223/date.html

While preparing this patch I noticed that intel-beignet.icd.in
uses @LIB_INSTALL_DIR@/beignet/ rather than @BEIGNET_INSTALL_DIR@,
which will obviously break if the latter is set directly. Is
that a bug or is this intended to be an internal-only variable?

Signed-off-by: Rebecca Palmer <rebecca_palmer at zoho.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c398e9..52f94ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,13 +38,30 @@ INCLUDE (FindPkgConfig)
  
  SET(CMAKE_VERBOSE_MAKEFILE "false")
  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/")
+
+INCLUDE (GNUInstallDirs OPTIONAL)
+# support old CMake without GNUInstallDirs
+if (NOT CMAKE_INSTALL_FULL_LIBDIR)
+  set (CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
+  set (CMAKE_LIBRARY_ARCHITECTURE "")
+endif (NOT CMAKE_INSTALL_FULL_LIBDIR)
+
  if (NOT LIB_INSTALL_DIR)
-  set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+  set (LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
  endif (NOT LIB_INSTALL_DIR)
  if (NOT BEIGNET_INSTALL_DIR)
    set (BEIGNET_INSTALL_DIR "${LIB_INSTALL_DIR}/beignet/")
  endif (NOT BEIGNET_INSTALL_DIR)
  
+# allow co-installation of 32- and 64-bit versions:
+# https://wiki.debian.org/Multiarch
+if (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
+  set (ICD_FILE_NAME "intel-beignet.icd")
+else (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
+  set (ICD_FILE_NAME "intel-beignet-${CMAKE_LIBRARY_ARCHITECTURE}.icd")
+endif (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
+
+
  # Force Release with debug info
  if (NOT CMAKE_BUILD_TYPE)
    set (CMAKE_BUILD_TYPE RelWithDebInfo)
@@ -172,9 +189,9 @@ IF(OCLIcd_FOUND)
    MESSAGE(STATUS "Looking for OCL ICD header file - found")
    configure_file (
      "intel-beignet.icd.in"
-    "intel-beignet.icd"
+    "${ICD_FILE_NAME}"
    )
-  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/intel-beignet.icd DESTINATION /etc/OpenCL/vendors)
+  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${ICD_FILE_NAME} DESTINATION /etc/OpenCL/vendors)
  ELSE(OCLIcd_FOUND)
    MESSAGE(STATUS "Looking for OCL ICD header file - not found")
  ENDIF(OCLIcd_FOUND)



More information about the Beignet mailing list