Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pkg-config file and .gitignore #86

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(Snappy VERSION 1.1.7 LANGUAGES C CXX)

set(SNAPPY_VER 1.1.7)

project(Snappy VERSION ${SNAPPY_VER} LANGUAGES C CXX)

# This project requires C++11.
set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -107,6 +110,21 @@ configure_file(
"${PROJECT_BINARY_DIR}/config.h"
)

include(GNUInstallDirs)
set(PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX})
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
set(PKG_CONFIG_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(PKG_CONFIG_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
else()
set(PKG_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
endif(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/libsnappy.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/libsnappy.pc")

# We don't want to define HAVE_ macros in public headers. Instead, we use
# CMake's variable substitution with 0/1 variables, which will be seen by the
# preprocessor as constants.
Expand Down Expand Up @@ -253,3 +271,6 @@ install(
"${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy"
)

install(FILES ${PROJECT_BINARY_DIR}/libsnappy.pc
DESTINATION ${INSTALL_PKGCONFIG_DIR})
10 changes: 10 additions & 0 deletions cmake/libsnappy.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@PKG_CONFIG_PREFIX@
exec_prefix=@PKG_CONFIG_PREFIX@
libdir=@PKG_CONFIG_LIBDIR@
includedir=@PKG_CONFIG_INCLUDEDIR@

Name: snappy
Description: Fast compressor/decompressor library.
Version: @SNAPPY_VER@
Libs: -L@PKG_CONFIG_LIBDIR@ -lsnappy
Cflags: -I@PKG_CONFIG_INCLUDEDIR@