From 7cf1ea6a2982f733a8e27c1e9357a70ec107f3d8 Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Mon, 5 Dec 2011 23:34:29 -0500 Subject: [PATCH] cmake: Use new GNUInstallDirs module for BINDIR and LIBDIR. 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 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ce66a491..db580b9e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)