From 7a2ee3142dc81f17b9aa5eb28c3bc9ab7845a29e Mon Sep 17 00:00:00 2001 From: Nicolas Benes Date: Sun, 14 Jun 2026 17:39:16 +0200 Subject: [PATCH] Add pkg-config file Signed-off-by: Nicolas Benes --- fastdds.pc.in | 13 +++++++++++++ src/cpp/CMakeLists.txt | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 fastdds.pc.in diff --git a/fastdds.pc.in b/fastdds.pc.in new file mode 100644 index 00000000000..69472289682 --- /dev/null +++ b/fastdds.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=@includedir_for_pc_file@ +libdir=@libdir_for_pc_file@ + +Name: fastdds +Description: C++ implementation of the DDS (Data Distribution Service) standard +URL: https://github.com/eProsima/Fast-DDS +Version: @PROJECT_VERSION@ + +Requires: fastcdr +Requires.private: @private_requires_for_pc_file@ +Cflags: -I${includedir} +Libs: -L${libdir} -lfastdds diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 070597df613..89bf998fa39 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -391,3 +391,27 @@ install(FILES ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_DESTINATION_PATH} COMPONENT cmake ) + +############################################################################### +# Create pkg-config file +############################################################################### +cmake_path(APPEND includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") +cmake_path(APPEND libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") + +set(private_requires_for_pc_file) +if (LINK_SSL) + list(APPEND private_requires_for_pc_file openssl) +endif() +if (TARGET tinyxml2::tinyxml2) + list(APPEND private_requires_for_pc_file tinyxml2) +endif() +list(JOIN private_requires_for_pc_file ", " private_requires_for_pc_file) + +configure_file( + "${PROJECT_SOURCE_DIR}/fastdds.pc.in" + "${PROJECT_BINARY_DIR}/fastdds.pc" + @ONLY) +install(FILES "${PROJECT_BINARY_DIR}/fastdds.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + COMPONENT pkgconfig + )