From 55924d11095df25ab25c405fadfe93d0a46f82eb Mon Sep 17 00:00:00 2001 From: costan Date: Wed, 16 Aug 2017 18:46:27 -0700 Subject: [PATCH] Add GNUInstallDirs to CMake configuration. This is modeled after https://github.com/google/googletest/pull/1160. The immediate benefit is fixing the library install paths on 64-bit Linux distributions, which tend to support running 32-bit and 64-bit code side by side by installing 32-bit libraries in /usr/lib and 64-bit libraries in /usr/lib64. --- CMakeLists.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a90a08..035f862 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,14 +140,20 @@ if(SNAPPY_BUILD_TESTS) COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest") endif(SNAPPY_BUILD_TESTS) -install(TARGETS snappy EXPORT SnappyTargets DESTINATION lib) +include(GNUInstallDirs) +install(TARGETS snappy + EXPORT SnappyTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) install( FILES "${PROJECT_SOURCE_DIR}/snappy-c.h" "${PROJECT_SOURCE_DIR}/snappy-sinksource.h" "${PROJECT_SOURCE_DIR}/snappy.h" "${PROJECT_BINARY_DIR}/snappy-stubs-public.h" - DESTINATION include + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) include(CMakePackageConfigHelpers) @@ -155,10 +161,14 @@ write_basic_package_version_file( "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" COMPATIBILITY SameMajorVersion ) -install(EXPORT SnappyTargets NAMESPACE Snappy:: DESTINATION lib/cmake/Snappy) +install( + EXPORT SnappyTargets + NAMESPACE Snappy:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy" +) install( FILES "${PROJECT_SOURCE_DIR}/cmake/SnappyConfig.cmake" "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" - DESTINATION lib/cmake/Snappy + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy" )