Skip to content

Add pkgconfig file #1147

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

Open
wants to merge 4 commits into
base: cpp_master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,19 @@ INSTALL (
DESTINATION "${cmake_config_path}"
COMPONENT msgpack-cxx
)

# Generate the pkgconfig file:
SET(PKG_CONFIG_LIBS
"-L\${libdir}"
)
SET(PKG_CONFIG_CFLAGS
"-I\${includedir}"
Copy link

@stephanlachnit stephanlachnit Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incomplete, since this misses the compilation flags. This is actually a bit tricky and why I never went further.

The obvious ones are the target compile option (MSGPACK_USE_X3_PARSE needs fixing since it is set via CMAKE_CXX_FLAGS), the more tricky one is that you actually also needs to handle the Boost deps here.

There are two options:

  • export all the Boost flags to the .pc file (if there are any, would have to be checked)
  • never enable Boost (not nice since it breaks common workflows)

I would also move the default -I and -L flags directly in the pkg-config file as well, since they are static anyway and really only clutter the CMakeLists.txt

)

CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)

INSTALL(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
8 changes: 8 additions & 0 deletions cmake/pkg-config.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Name: ${PROJECT_NAME}
Description: ${PROJECT_DESCRIPTION}
Version: ${PROJECT_VERSION}
prefix=${CMAKE_INSTALL_PREFIX}
includedir=${prefix}/${CMAKE_INSTALL_INCLUDEDIR}
libdir=${prefix}/${CMAKE_INSTALL_LIBDIR}
Libs: ${PKG_CONFIG_LIBS}
Cflags: ${PKG_CONFIG_CFLAGS}
Loading