summaryrefslogtreecommitdiff
path: root/Modules/GNUInstallDirs.cmake
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2011-03-28 21:10:52 +0200
committerBrad King <brad.king@kitware.com>2011-03-31 14:45:48 -0400
commit126c993d031f6f7be4970a67621da92f580d4e5a (patch)
treeebdeff27da3746c082d55b02ad8ca440de1ead84 /Modules/GNUInstallDirs.cmake
parent148b528f9d7d991dc01f277624df4a8aa41feccc (diff)
downloadcmake-126c993d031f6f7be4970a67621da92f580d4e5a.tar.gz
Fix #11964 Handle lib64 library on Linux
The AMD64 ABI document http://www.x86-64.org/documentation/abi.pdf does specify that 64bits binary libraries should end up in <prefix>/lib64 and 32bits ones in <prefix>/lib. All but debian based distros do so, and some like OpenSUSE even enforce the rule when packaging with RPM and refuse to build the RPM if this is not the case. After some discussion (see the bug notes) we cannot do that behind the scene and the current fix supposes that the user shall use the CMAKE_INSTALL_LIBDIR variables content in its INSTALL rules if he wants to put the lib in the right place. CMAKE_INSTALL_LIBDIR shall have the appropriate value depending on the Linux distribution found and 32/64bitness of the host. The cross-compiling case (even 32bits compile on a 64bits host) is not handled.
Diffstat (limited to 'Modules/GNUInstallDirs.cmake')
-rw-r--r--Modules/GNUInstallDirs.cmake25
1 files changed, 23 insertions, 2 deletions
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index bb651dec79..a114dcb2e1 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -11,7 +11,7 @@
# SYSCONFDIR - read-only single-machine data (etc)
# SHAREDSTATEDIR - modifiable architecture-independent data (com)
# LOCALSTATEDIR - modifiable single-machine data (var)
-# LIBDIR - object code libraries (lib)
+# LIBDIR - object code libraries (lib or lib64)
# INCLUDEDIR - C header files (include)
# OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
# DATAROOTDIR - read-only architecture-independent data root (share)
@@ -69,7 +69,28 @@ if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
- set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "object code libraries (lib)")
+ set(_LIBDIR_DEFAULT "lib")
+ # Override this default 'lib' with 'lib64' iff:
+ # - we are on Linux system but NOT cross-compiling
+ # - we are NOT on debian
+ # - we are on a 64 bits system
+ # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
+ # Note that the future of multi-arch handling may be even
+ # more complicated than that: http://wiki.debian.org/Multiarch
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux"
+ AND NOT CMAKE_CROSSCOMPILING
+ AND NOT EXISTS "/etc/debian_version")
+ if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
+ message(AUTHOR_WARNING
+ "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
+ "Please enable at least one language before including GNUInstallDirs.")
+ else()
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(_LIBDIR_DEFAULT "lib64")
+ endif()
+ endif()
+ endif()
+ set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
endif()
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)