cmake: Use new GNUInstallDirs module for BINDIR and LIBDIR.
authorMike Gilbert <floppym@gentoo.org>
Tue, 6 Dec 2011 04:34:29 +0000 (23:34 -0500)
committerMike Gilbert <floppym@gentoo.org>
Tue, 6 Dec 2011 04:34:29 +0000 (23:34 -0500)
Should automatically correct libdir handling for 64 bit linux distros.

See also:
http://public.kitware.com/Bug/view.php?id=3976
http://public.kitware.com/Bug/view.php?id=11964

CMakeLists.txt

index 0ce66a4..db580b9 100644 (file)
@@ -27,6 +27,19 @@ include(CheckLibraryExists)
 include(FindPkgConfig)
 include(TestBigEndian)
 
+# GNUInstallDirs is a relatively new cmake module
+include(GNUInstallDirs OPTIONAL RESULT_VARIABLE GID_PATH)
+if(GID_PATH EQUAL NOTFOUND)
+       # Set default libdir
+       if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
+               set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "object code libraries (lib)")
+       endif()
+       # Set default bindir
+       if(NOT DEFINED CMAKE_INSTALL_BINDIR)
+               set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
+       endif()
+endif()
+
 # Include our extra modules
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
 
@@ -47,16 +60,6 @@ if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Release")
 endif()
 
-# Set default libdir
-if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
-       set(CMAKE_INSTALL_LIBDIR "lib")
-endif()
-
-# Set default bindir
-if(NOT DEFINED CMAKE_INSTALL_BINDIR)
-       set(CMAKE_INSTALL_BINDIR "bin")
-endif()
-
 # build shared libs
 if(NOT BUILD_SHARED_LIBS)
     set(BUILD_SHARED_LIBS ON)