From aae0d2b0adc3a0df321d4601ce55eee5b4f235b2 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 16 Jan 2013 23:34:26 +0100 Subject: [PATCH] Supplement GNUInstallDirs to support multi-arch Debian object code libraries are in directories which include the platform name to allow several of these to co-exist. Other distros such as Fedora uses a simpler naming scheme (e.g. "lib64/") which is more backward-compatible. --- cmake/Modules/UseMultiArch.cmake | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmake/Modules/UseMultiArch.cmake diff --git a/cmake/Modules/UseMultiArch.cmake b/cmake/Modules/UseMultiArch.cmake new file mode 100644 index 00000000..6f55b495 --- /dev/null +++ b/cmake/Modules/UseMultiArch.cmake @@ -0,0 +1,28 @@ +# - Multiarch support in object code library directories +# +# This module sets the following variable +# CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu depending +# the platform. +# +# Note that it will override the results of GNUInstallDirs if included after +# that module. + +# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu +if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + # Debian or Ubuntu? + if (EXISTS "/etc/debian_version") + set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}") + else (EXISTS "/etc/debian_version") + # 64-bit system? + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (_libdir_def "lib64") + else (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (_libdir_def "lib") + endif (CMAKE_SIZEOF_VOID_P EQUAL 8) + endif (EXISTS "/etc/debian_version") +else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set (_libdir_def "lib") +endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + +# let the user override if somewhere else is desirable +set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries")