Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Generate pgkconfig file
  • Loading branch information
simonspa committed Nov 5, 2024
commit a7c18b7dc4606eeacd5f8195633ef9c003d34d44
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,26 @@ INSTALL (
DESTINATION "${cmake_config_path}"
COMPONENT msgpack-cxx
)

# pkgconfig file generation:

SET(PKG_CONFIG_LIBDIR
"\${prefix}/${CMAKE_INSTALL_LIBDIR}"
)
SET(PKG_CONFIG_INCLUDEDIR
"\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
)
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)
Loading