Skip to content

Commit

Permalink
CMakeLists: generate and install pkg-config file
Browse files Browse the repository at this point in the history
  • Loading branch information
pabigot committed Apr 20, 2018
1 parent d857fba commit 789d512
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

# project name
project(amqpcpp)
set (VERSION_MAJOR 3)
set (VERSION_MINOR 0)
set (VERSION_PATCH 2)
set (SO_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})

# build options
option(AMQP-CPP_BUILD_SHARED "Build shared library. If off, build will be static." OFF)
Expand Down Expand Up @@ -75,7 +79,7 @@ if(AMQP-CPP_BUILD_SHARED)
# create shared lib
add_library(${PROJECT_NAME} SHARED ${SRCS})
# set shared lib version
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 3.0)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${SO_VERSION})
else()
# create static lib
add_library(${PROJECT_NAME} STATIC ${SRCS})
Expand Down Expand Up @@ -105,3 +109,9 @@ install(FILES include/amqpcpp.h DESTINATION include)

install(EXPORT ${PROJECT_NAME}Config DESTINATION cmake)
export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake)

set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
set(PRIVATE_LIBS "-llibamqpcc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/amqpcpp.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" DESTINATION lib/pkgconfig)
10 changes: 10 additions & 0 deletions amqpcpp.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@DEST_DIR@
libdir=${prefix}/lib
includedir=${prefix}/include

Name: amqpcpp
Description: AMQP-CPP is a C++ library for communicating with a RabbitMQ message broker
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@

Libs: -L${libdir} -lamqpcpp
Cflags: -I${includedir}

0 comments on commit 789d512

Please sign in to comment.