Skip to content

Commit

Permalink
Added pkg-config file and .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
lavoiesl committed Oct 29, 2019
1 parent e9e11b8 commit 94dd4a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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@

0 comments on commit 94dd4a1

Please sign in to comment.