Skip to content

Commit

Permalink
Generate pkgconfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
morxa committed Jun 27, 2021
1 parent 97cd484 commit e84e269
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.12)

project(protobuf_comm VERSION 0.9.0)
project(protobuf_comm VERSION 0.9.0
DESCRIPTION "Protobuf wrapper for peer-to-peer communication")

find_package(Protobuf REQUIRED)
find_package(Boost REQUIRED COMPONENTS thread system)
Expand Down Expand Up @@ -44,3 +45,19 @@ install(
install(FILES cmake/ProtobufCommConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ProtobufCommConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ProtobufComm)

set(PKG_CONFIG_REQUIRES "protobuf libcrypto")
get_target_property(PKG_CONFIG_PUBLIC_LIBS protobuf_comm INTERFACE_LINK_LIBRARIES)
get_target_property(PKG_CONFIG_PRIVATE_LIBS protobuf_comm LINK_LIBRARIES)
get_target_property(PKG_CONFIG_CFLAGS protobuf_comm COMPILE_FLAGS)
if ("${PKG_CONFIG_CFLAGS}" STREQUAL "PKG_CONFIG_CFLAGS-NOTFOUND")
set(PKG_CONFIG_CFLAGS "")
endif()

set(PKG_CONFIG_PUBLIC_LIBS "-lcrypto -lprotobuf -lboost_thread -lboost_system")
set(PKG_CONFIG_PRIVATE_LIBS "")
set(PKG_CONFIG_CFLAGS "")

configure_file(protobuf_comm.pc.in ${CMAKE_CURRENT_BINARY_DIR}/protobuf_comm.pc @ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf_comm.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
7 changes: 7 additions & 0 deletions protobuf_comm.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Requires: @PKG_CONFIG_REQUIRES@
Cflags: @PKG_CONFIG_CFLAGS@
Libs: -lprotobuf_comm @PKG_CONFIG_PUBLIC_LIBS@
Libs.private: @PKG_CONFIG_PRIVATE_LIBS@

0 comments on commit e84e269

Please sign in to comment.