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.
This commit is contained in:
costan 2017-08-16 18:46:27 -07:00 committed by Victor Costan
parent 632cd0f128
commit 55924d1109
1 changed files with 14 additions and 4 deletions

View File

@ -140,14 +140,20 @@ if(SNAPPY_BUILD_TESTS)
COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest") COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
endif(SNAPPY_BUILD_TESTS) 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( install(
FILES FILES
"${PROJECT_SOURCE_DIR}/snappy-c.h" "${PROJECT_SOURCE_DIR}/snappy-c.h"
"${PROJECT_SOURCE_DIR}/snappy-sinksource.h" "${PROJECT_SOURCE_DIR}/snappy-sinksource.h"
"${PROJECT_SOURCE_DIR}/snappy.h" "${PROJECT_SOURCE_DIR}/snappy.h"
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h" "${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
DESTINATION include DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
@ -155,10 +161,14 @@ write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake"
COMPATIBILITY SameMajorVersion COMPATIBILITY SameMajorVersion
) )
install(EXPORT SnappyTargets NAMESPACE Snappy:: DESTINATION lib/cmake/Snappy) install(
EXPORT SnappyTargets
NAMESPACE Snappy::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy"
)
install( install(
FILES FILES
"${PROJECT_SOURCE_DIR}/cmake/SnappyConfig.cmake" "${PROJECT_SOURCE_DIR}/cmake/SnappyConfig.cmake"
"${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake"
DESTINATION lib/cmake/Snappy DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy"
) )