From c1d36909b90c84ef7fb7cb7f5be75df61bc01d5d Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Sun, 26 Jul 2026 22:07:40 +0200 Subject: [PATCH 01/15] feat (hdds-c): allow C code to be included inside C++ projects Signed-off-by: Davide Bertelli --- cmake/hddsConfig.cmake.in | 1 + crates/hdds-c/cbindgen.toml | 1 + crates/hdds-c/hdds.h | 8 ++++++++ sdk/c/include/hdds.h | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 cmake/hddsConfig.cmake.in diff --git a/cmake/hddsConfig.cmake.in b/cmake/hddsConfig.cmake.in new file mode 100644 index 0000000..23ba2ef --- /dev/null +++ b/cmake/hddsConfig.cmake.in @@ -0,0 +1 @@ +@PACKAGE_INIT@ \ No newline at end of file diff --git a/crates/hdds-c/cbindgen.toml b/crates/hdds-c/cbindgen.toml index 6fbf258..8c9d500 100644 --- a/crates/hdds-c/cbindgen.toml +++ b/crates/hdds-c/cbindgen.toml @@ -2,6 +2,7 @@ language = "C" include_guard = "HDDS_H" +cpp_compat = true header = """ /* * HDDS C FFI Bindings diff --git a/crates/hdds-c/hdds.h b/crates/hdds-c/hdds.h index 9f96453..900c38c 100644 --- a/crates/hdds-c/hdds.h +++ b/crates/hdds-c/hdds.h @@ -844,6 +844,10 @@ typedef struct HddsParticipantConfig { uint8_t PRIVATE[0]; } HddsParticipantConfig; +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /** * Create a new DDS Participant with default settings (UdpMulticast transport) * @@ -2953,4 +2957,8 @@ enum HddsError hdds_config_set_security(struct HddsParticipantConfig *aConfig, */ struct HddsParticipant *hdds_config_build(struct HddsParticipantConfig *aConfig); +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + #endif /* HDDS_H */ diff --git a/sdk/c/include/hdds.h b/sdk/c/include/hdds.h index fa1cc80..7e29221 100644 --- a/sdk/c/include/hdds.h +++ b/sdk/c/include/hdds.h @@ -847,6 +847,10 @@ typedef struct HddsParticipantConfig { uint8_t PRIVATE[0]; } HddsParticipantConfig; +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /** * Create a new DDS Participant with default settings (UdpMulticast transport) * @@ -2956,4 +2960,8 @@ enum HddsError hdds_config_set_security(struct HddsParticipantConfig *aConfig, */ struct HddsParticipant *hdds_config_build(struct HddsParticipantConfig *aConfig); +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + #endif /* HDDS_H */ From 8156d5112c7acc0775556647d10d5c21a228bbf6 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Sun, 26 Jul 2026 22:08:09 +0200 Subject: [PATCH 02/15] feat (CMake): improved CMake by allowing usage as third party without manually calling `cargo build` Signed-off-by: Davide Bertelli --- CMakeLists.txt | 148 ++++++++++++++++++++++++++++++++ sdk/cxx/CMakeLists.txt | 66 +++++++------- sdk/cxx/examples/CMakeLists.txt | 3 +- 3 files changed, 185 insertions(+), 32 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..11fafa2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,148 @@ +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) +project(hdds + VERSION 1.0.11 + DESCRIPTION "High-performance DDS" + LANGUAGES C CXX +) + +option(BUILD_SHARED_LIBS "Build static or shared library" OFF) +option(BUILD_HDDS_CXX "Enable building hdds_cxx library" ON) +option(HDDS_BUILD_INSTALL "Build install target" OFF) + +# Directly set MSVC to avoid mismatch between cmake configuration and detected build type +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type for the library, directly set for MSVC") + +# Ensure cargo is installed +set(CARGO_EXECUTABLE) +find_program(CARGO_EXECUTABLE NAMES cargo) +if("${CARGO_EXECUTABLE}" STREQUAL "CARGO_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Cargo not found. Look at: https://rust-lang.org/learn/get-started") +endif() + +# Determine library extensions and suffixes for the current OS +if(WIN32) + set(HDDS_SHARED_LIBRARY_EXTENSION "dll") + set(HDDS_STATIC_LIBRARY_EXTENSION "lib") + set(HDDS_LIBRARY_PREFIX "") +else() + set(HDDS_SHARED_LIBRARY_EXTENSION "so") + set(HDDS_STATIC_LIBRARY_EXTENSION "a") + set(HDDS_LIBRARY_PREFIX "lib") +endif() +set(HDDS_C_LIBRARY_NAME ${HDDS_LIBRARY_PREFIX}hdds_c) + +# Use the build type to know the folder in which the library will be built +string(TOLOWER ${CMAKE_BUILD_TYPE} HDDS_BUILD_TYPE) + +set(HDDS_CMAKE_LIBRARY_TYPE "STATIC") +if(BUILD_SHARED_LIBS) + set(HDDS_CMAKE_LIBRARY_TYPE "SHARED") +endif() + +# Set the path to the library binary file depending on the build type +set(HDDS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${HDDS_BUILD_TYPE}") +if(BUILD_SHARED_LIBS) + set(HDDS_LIBRARY_OUTPUT ${HDDS_OUTPUT_DIR}/${HDDS_C_LIBRARY_NAME}.${HDDS_SHARED_LIBRARY_EXTENSION}) +else() + set(HDDS_LIBRARY_OUTPUT ${HDDS_OUTPUT_DIR}/${HDDS_C_LIBRARY_NAME}.${HDDS_STATIC_LIBRARY_EXTENSION}) +endif() + +# Set location of library headers +set(HDDS_C_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sdk/c/include") +set(HDDS_C_HEADERS "${HDDS_C_INCLUDE_DIR}/hdds.h") + +# Set build flag for cargo given the build type +set(HDDS_CARGO_BUILD_FLAG "--${HDDS_BUILD_TYPE}") + +# Add a custom command to build the library and a custom target that depends on the output of the command +# that will triger the cargo build task +add_custom_target(${PROJECT_NAME}_rust ALL + ${CARGO_EXECUTABLE} "rustc" "--manifest-path" "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml" + "--package" "hdds-c" "${HDDS_CARGO_BUILD_FLAG}" + "--crate-type" $,"cdylib","staticlib"> + "--target-dir" "${CMAKE_CURRENT_BINARY_DIR}" + DEPENDS ${HDDS_C_HEADERS} # CMake will re-run the command whenever the files change +) + +# Generate the imported library for HDDS and link it to the custom target to ensure the custom command to be called +add_library(${PROJECT_NAME}_c ${HDDS_CMAKE_LIBRARY_TYPE} IMPORTED GLOBAL ${HDDS_C_HEADERS}) +add_library(${PROJECT_NAME}::${PROJECT_NAME}_c ALIAS ${PROJECT_NAME}_c) + +if (WIN32) + # Link Windows libraries + target_link_libraries(${PROJECT_NAME}_c INTERFACE ntdll kernel32 ws2_32 userenv iphlpapi) +endif() + +# Manually specify the dependency between HDDS target and the fake one to ensure compiler will not invert the order +add_dependencies(${PROJECT_NAME}_c ${PROJECT_NAME}_rust) + +# Change imported library location to the built one +set(HDDS_LIBRARY_IMPORTED_LOCATION ${HDDS_LIBRARY_OUTPUT}) + +# Set imported target library location and implib. +# On Windows if the library is static then both properties +# must be the same .lib file. On Linux the 'IMPORTED_IMPLIB' will be ignored +set_target_properties( + ${PROJECT_NAME}_c + PROPERTIES IMPORTED_LOCATION ${HDDS_LIBRARY_IMPORTED_LOCATION} + IMPORTED_IMPLIB ${HDDS_LIBRARY_OUTPUT}.${HDDS_STATIC_LIBRARY_EXTENSION} +) + +target_include_directories(${PROJECT_NAME}_c INTERFACE + "${HDDS_C_INCLUDE_DIR}" # Allows inclusion as '#include ' +) + +# Expose also hdds_cxx target +if(BUILD_HDDS_CXX) + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/sdk/cxx") +endif() + +if(HDDS_BUILD_INSTALL) + include(CMakePackageConfigHelpers) + + get_filename_component(file ${HDDS_C_HEADERS} ABSOLUTE) + install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + # Configuration + configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion + ) + # Package + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) + install( + EXPORT ${PROJECT_NAME}Targets + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) + install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + + # + # CPack + # + set(CPACK_GENERATOR DEB RPM TXZ TGZ) + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION}) + set(CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}" + ) + set(CPACK_PACKAGE_RPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/Linux/RPM") + include(CPack) +endif() \ No newline at end of file diff --git a/sdk/cxx/CMakeLists.txt b/sdk/cxx/CMakeLists.txt index 82aa495..2c9868d 100644 --- a/sdk/cxx/CMakeLists.txt +++ b/sdk/cxx/CMakeLists.txt @@ -3,58 +3,64 @@ project(hdds_cxx VERSION 0.8.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -# Find hdds-c library -set(HDDS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to HDDS root") -set(HDDS_C_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../c/include" CACHE PATH "Path to hdds-c headers") -set(HDDS_C_LIB "${HDDS_ROOT}/target/release" CACHE PATH "Path to hdds-c library") +option(BUILD_SHARED_LIBS "Build static or shared library" OFF) +option(HDDS_BUILD_INSTALL "Build install target" OFF) +option(BUILD_EXAMPLES "Build examples" ON) +option(BUILD_TESTS "Build tests" ON) + +# Find thread library +find_package(Threads REQUIRED) # Library -add_library(hdds_cxx STATIC - src/participant.cpp - src/writer.cpp - src/reader.cpp - src/qos.cpp - src/waitset.cpp - src/logging.cpp - src/telemetry.cpp - src/pubsub.cpp +set(HDDS_CXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/hdds_listener.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/hdds.hpp ) +set(HDDS_CXX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/participant.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pubsub.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/qos.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/reader.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/telemetry.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/waitset.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/writer.cpp +) + +add_library(hdds_cxx ${HDDS_CXX_HEADERS} ${HDDS_CXX_SOURCES}) +add_library(hdds::hdds_cxx ALIAS hdds_cxx) target_include_directories(hdds_cxx PUBLIC $ $ - PRIVATE - ${HDDS_C_INCLUDE} ) -target_link_directories(hdds_cxx PRIVATE ${HDDS_C_LIB}) -target_link_libraries(hdds_cxx PRIVATE hdds_c pthread dl m) +target_link_libraries(hdds_cxx PUBLIC hdds::hdds_c PRIVATE Threads::Threads ${CMAKE_DL_LIBS}) # Install -install(TARGETS hdds_cxx - EXPORT hdds_cxx-targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) +if(HDDS_BUILD_INSTALL) + install(TARGETS hdds_cxx + EXPORT hdds_cxx-targets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) -install(DIRECTORY include/ DESTINATION include) + install(DIRECTORY include/ DESTINATION include) -install(EXPORT hdds_cxx-targets - FILE hdds_cxxTargets.cmake - NAMESPACE hdds:: - DESTINATION lib/cmake/hdds_cxx -) + install(EXPORT hdds_cxx-targets + FILE hdds_cxxTargets.cmake + NAMESPACE hdds:: + DESTINATION lib/cmake/hdds_cxx + ) +endif() # Examples -option(BUILD_EXAMPLES "Build examples" ON) if(BUILD_EXAMPLES) add_subdirectory(examples) endif() # Tests -option(BUILD_TESTS "Build tests" ON) if(BUILD_TESTS) enable_testing() add_subdirectory(tests) diff --git a/sdk/cxx/examples/CMakeLists.txt b/sdk/cxx/examples/CMakeLists.txt index bca8a82..7489ad1 100644 --- a/sdk/cxx/examples/CMakeLists.txt +++ b/sdk/cxx/examples/CMakeLists.txt @@ -1,3 +1,2 @@ add_executable(basic_pubsub basic_pubsub.cpp) -target_link_directories(basic_pubsub PRIVATE ${HDDS_C_LIB}) -target_link_libraries(basic_pubsub hdds_cxx hdds_c pthread dl m) +target_link_libraries(basic_pubsub PRIVATE hdds::hdds_cxx) From 610e833295f74f79db6afe1e2ec87caecaf04713 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:21:31 +0200 Subject: [PATCH 03/15] fix (CMake): fixed default configuration fails due to CMAKE_BUILD_TYPE Signed-off-by: Davide Bertelli --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11fafa2..4037215 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,11 @@ option(BUILD_SHARED_LIBS "Build static or shared library" OFF) option(BUILD_HDDS_CXX "Enable building hdds_cxx library" ON) option(HDDS_BUILD_INSTALL "Build install target" OFF) -# Directly set MSVC to avoid mismatch between cmake configuration and detected build type -set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type for the library, directly set for MSVC") +# Set CMAKE_BUILD_TYPE if neither parent nor project set it or if we are using +# a multi-config generator +if(NOT CMAKE_BUILD_TYPE OR NOT GENERATOR_IS_MULTI_CONFIG) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type for the library" FORCE) +endif() # Ensure cargo is installed set(CARGO_EXECUTABLE) @@ -32,7 +35,11 @@ endif() set(HDDS_C_LIBRARY_NAME ${HDDS_LIBRARY_PREFIX}hdds_c) # Use the build type to know the folder in which the library will be built +if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug") string(TOLOWER ${CMAKE_BUILD_TYPE} HDDS_BUILD_TYPE) +else() + set(HDDS_BUILD_TYPE "release") +endif() set(HDDS_CMAKE_LIBRARY_TYPE "STATIC") if(BUILD_SHARED_LIBS) From 5688da7bb774941c6388977ca5ec304259334523 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:23:05 +0200 Subject: [PATCH 04/15] fix (CMake): invalid cargo build flags Signed-off-by: Davide Bertelli --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4037215..a4ee666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,14 +58,16 @@ endif() set(HDDS_C_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sdk/c/include") set(HDDS_C_HEADERS "${HDDS_C_INCLUDE_DIR}/hdds.h") -# Set build flag for cargo given the build type -set(HDDS_CARGO_BUILD_FLAG "--${HDDS_BUILD_TYPE}") +# Set build flag for cargo only if building in Release +if(${HDDS_BUILD_TYPE} STREQUAL "release") + set(HDDS_CARGO_RELEASE_BUILD_FLAG "--${HDDS_BUILD_TYPE}") +endif() # Add a custom command to build the library and a custom target that depends on the output of the command # that will triger the cargo build task add_custom_target(${PROJECT_NAME}_rust ALL ${CARGO_EXECUTABLE} "rustc" "--manifest-path" "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml" - "--package" "hdds-c" "${HDDS_CARGO_BUILD_FLAG}" + "--package" "hdds-c" "${HDDS_CARGO_RELEASE_BUILD_FLAG}" "--crate-type" $,"cdylib","staticlib"> "--target-dir" "${CMAKE_CURRENT_BINARY_DIR}" DEPENDS ${HDDS_C_HEADERS} # CMake will re-run the command whenever the files change From b3ed237025c55ac0692beb023cf0bf69c86fa100 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:24:13 +0200 Subject: [PATCH 05/15] fix (CMake): added missing `bcrypt` linking on Windows Signed-off-by: Davide Bertelli --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4ee666..7596967 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ add_library(${PROJECT_NAME}::${PROJECT_NAME}_c ALIAS ${PROJECT_NAME}_c) if (WIN32) # Link Windows libraries - target_link_libraries(${PROJECT_NAME}_c INTERFACE ntdll kernel32 ws2_32 userenv iphlpapi) + target_link_libraries(${PROJECT_NAME}_c INTERFACE ntdll kernel32 ws2_32 userenv iphlpapi bcrypt) endif() # Manually specify the dependency between HDDS target and the fake one to ensure compiler will not invert the order From 6d679643841bd5356e240a396f38932a071cd237 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:28:10 +0200 Subject: [PATCH 06/15] fix (CMake): removed install and CPack directives Signed-off-by: Davide Bertelli --- CMakeLists.txt | 53 +-------------------------------------- cmake/hddsConfig.cmake.in | 1 - sdk/cxx/CMakeLists.txt | 18 ------------- 3 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 cmake/hddsConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7596967..34a32d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ project(hdds option(BUILD_SHARED_LIBS "Build static or shared library" OFF) option(BUILD_HDDS_CXX "Enable building hdds_cxx library" ON) -option(HDDS_BUILD_INSTALL "Build install target" OFF) # Set CMAKE_BUILD_TYPE if neither parent nor project set it or if we are using # a multi-config generator @@ -36,7 +35,7 @@ set(HDDS_C_LIBRARY_NAME ${HDDS_LIBRARY_PREFIX}hdds_c) # Use the build type to know the folder in which the library will be built if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug") -string(TOLOWER ${CMAKE_BUILD_TYPE} HDDS_BUILD_TYPE) + string(TOLOWER ${CMAKE_BUILD_TYPE} HDDS_BUILD_TYPE) else() set(HDDS_BUILD_TYPE "release") endif() @@ -105,53 +104,3 @@ target_include_directories(${PROJECT_NAME}_c INTERFACE if(BUILD_HDDS_CXX) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/sdk/cxx") endif() - -if(HDDS_BUILD_INSTALL) - include(CMakePackageConfigHelpers) - - get_filename_component(file ${HDDS_C_HEADERS} ABSOLUTE) - install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - - # Configuration - configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} - ) - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion - ) - # Package - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} - ) - install( - EXPORT ${PROJECT_NAME}Targets - FILE ${PROJECT_NAME}Targets.cmake - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} - ) - install( - TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}Targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) - - # - # CPack - # - set(CPACK_GENERATOR DEB RPM TXZ TGZ) - set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) - set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION}) - set(CPACK_PACKAGE_FILE_NAME - "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}" - ) - set(CPACK_PACKAGE_RPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/Linux/RPM") - include(CPack) -endif() \ No newline at end of file diff --git a/cmake/hddsConfig.cmake.in b/cmake/hddsConfig.cmake.in deleted file mode 100644 index 23ba2ef..0000000 --- a/cmake/hddsConfig.cmake.in +++ /dev/null @@ -1 +0,0 @@ -@PACKAGE_INIT@ \ No newline at end of file diff --git a/sdk/cxx/CMakeLists.txt b/sdk/cxx/CMakeLists.txt index 2c9868d..e2a31db 100644 --- a/sdk/cxx/CMakeLists.txt +++ b/sdk/cxx/CMakeLists.txt @@ -6,7 +6,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) option(BUILD_SHARED_LIBS "Build static or shared library" OFF) -option(HDDS_BUILD_INSTALL "Build install target" OFF) option(BUILD_EXAMPLES "Build examples" ON) option(BUILD_TESTS "Build tests" ON) @@ -38,23 +37,6 @@ target_include_directories(hdds_cxx target_link_libraries(hdds_cxx PUBLIC hdds::hdds_c PRIVATE Threads::Threads ${CMAKE_DL_LIBS}) -# Install -if(HDDS_BUILD_INSTALL) - install(TARGETS hdds_cxx - EXPORT hdds_cxx-targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) - - install(DIRECTORY include/ DESTINATION include) - - install(EXPORT hdds_cxx-targets - FILE hdds_cxxTargets.cmake - NAMESPACE hdds:: - DESTINATION lib/cmake/hdds_cxx - ) -endif() - # Examples if(BUILD_EXAMPLES) add_subdirectory(examples) From a4682465478b921494a2843a539e5061a7aa80cc Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:29:11 +0200 Subject: [PATCH 07/15] chore (CMake): CMake project version matches workspace one Signed-off-by: Davide Bertelli --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34a32d9..bd565fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(hdds - VERSION 1.0.11 + VERSION 1.1.2 DESCRIPTION "High-performance DDS" LANGUAGES C CXX ) From 2f376659a33c61e945570ffc76a1d396cdd8ea61 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Tue, 28 Jul 2026 23:30:06 +0200 Subject: [PATCH 08/15] chore (CMake): disabled default building for CXX tests and examples Signed-off-by: Davide Bertelli --- sdk/cxx/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/cxx/CMakeLists.txt b/sdk/cxx/CMakeLists.txt index e2a31db..5af42ac 100644 --- a/sdk/cxx/CMakeLists.txt +++ b/sdk/cxx/CMakeLists.txt @@ -6,8 +6,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) option(BUILD_SHARED_LIBS "Build static or shared library" OFF) -option(BUILD_EXAMPLES "Build examples" ON) -option(BUILD_TESTS "Build tests" ON) +option(BUILD_EXAMPLES "Build examples" OFF) +option(BUILD_TESTS "Build tests" OFF) # Find thread library find_package(Threads REQUIRED) From b315a35a220b5a500980fc277152a2162864024e Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Wed, 29 Jul 2026 21:32:44 +0200 Subject: [PATCH 09/15] fix (CMake): fixed `GENERATOR_IS_MULTI_CONFIG` and `CMAKE_BUILD_TYPE` evaluation Signed-off-by: Davide Bertelli --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd565fe..e169a55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,9 @@ option(BUILD_HDDS_CXX "Enable building hdds_cxx library" ON) # Set CMAKE_BUILD_TYPE if neither parent nor project set it or if we are using # a multi-config generator -if(NOT CMAKE_BUILD_TYPE OR NOT GENERATOR_IS_MULTI_CONFIG) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type for the library" FORCE) +get_property(HDDS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT HDDS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type for the library") endif() # Ensure cargo is installed @@ -35,7 +36,7 @@ set(HDDS_C_LIBRARY_NAME ${HDDS_LIBRARY_PREFIX}hdds_c) # Use the build type to know the folder in which the library will be built if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug") - string(TOLOWER ${CMAKE_BUILD_TYPE} HDDS_BUILD_TYPE) + string(TOLOWER "${CMAKE_BUILD_TYPE}" HDDS_BUILD_TYPE) else() set(HDDS_BUILD_TYPE "release") endif() From 9e6dc2f3cec093cfb54cf0308923db0253a6ee8e Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Wed, 29 Jul 2026 22:33:06 +0200 Subject: [PATCH 10/15] feat (CMake): read project version from `cargo.toml` Signed-off-by: Davide Bertelli --- CMakeLists.txt | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e169a55..fb6b30f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,31 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR) + +set(HDDS_PROJECT_VERSION "") + +if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cargo.toml") + message(WARNING "Unable to find 'cargo.toml' in current directory: project version UNKNOWN") +else() + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/cargo.toml" HDDS_CARGO_TOML) + set(HDDS_SEARCHING_FOR_VERSION OFF) + foreach(line IN LISTS HDDS_CARGO_TOML) + # Search in cargo.toml for the pattern 'major[.minor][.patch][.tweak]' + if(HDDS_SEARCHING_FOR_VERSION AND "${line}" MATCHES "version[\r\n\t ]*=[\r\n\t ]*\"?([0-9]*([\.][0-9]+)?([\.][0-9]+)?([\.][0-9]+)?)\"?$") + set(HDDS_PROJECT_VERSION ${CMAKE_MATCH_1}) + break() + endif() + + if(${line} MATCHES "workspace.package") + set(HDDS_SEARCHING_FOR_VERSION ON) + endif() + endforeach() +endif() + +if(NOT HDDS_PROJECT_VERSION) + message(WARNING "Unable to read rust library version") +endif() + project(hdds - VERSION 1.1.2 + VERSION ${HDDS_PROJECT_VERSION} DESCRIPTION "High-performance DDS" LANGUAGES C CXX ) From 587dca059af2e6d2b1025882b8d7d1a29e8f16c5 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Wed, 29 Jul 2026 23:00:14 +0200 Subject: [PATCH 11/15] fix (CMake): missing quoted `CMAKE_BUILD_TYPE` evaluation Signed-off-by: Davide Bertelli --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb6b30f..8582da1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ endif() set(HDDS_C_LIBRARY_NAME ${HDDS_LIBRARY_PREFIX}hdds_c) # Use the build type to know the folder in which the library will be built -if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") string(TOLOWER "${CMAKE_BUILD_TYPE}" HDDS_BUILD_TYPE) else() set(HDDS_BUILD_TYPE "release") From 53500fe11b30f1dd34da4e5426e63780591b83f6 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Fri, 31 Jul 2026 17:17:35 +0200 Subject: [PATCH 12/15] fix (CMake): using `Cargo.toml` with uppercase letter Signed-off-by: Davide Bertelli --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8582da1..7a14a43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR) set(HDDS_PROJECT_VERSION "") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cargo.toml") - message(WARNING "Unable to find 'cargo.toml' in current directory: project version UNKNOWN") +if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml") + message(WARNING "Unable to find 'Cargo.toml' in current directory: project version UNKNOWN") else() - file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/cargo.toml" HDDS_CARGO_TOML) + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml" HDDS_CARGO_TOML) set(HDDS_SEARCHING_FOR_VERSION OFF) foreach(line IN LISTS HDDS_CARGO_TOML) - # Search in cargo.toml for the pattern 'major[.minor][.patch][.tweak]' + # Search in Cargo.toml for the pattern 'major[.minor][.patch][.tweak]' if(HDDS_SEARCHING_FOR_VERSION AND "${line}" MATCHES "version[\r\n\t ]*=[\r\n\t ]*\"?([0-9]*([\.][0-9]+)?([\.][0-9]+)?([\.][0-9]+)?)\"?$") set(HDDS_PROJECT_VERSION ${CMAKE_MATCH_1}) break() From b20b2a1dbd53eaf895b9ef57d311ce964766d728 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Fri, 31 Jul 2026 17:19:23 +0200 Subject: [PATCH 13/15] fix (CMake): workspace version regex matches empty string Signed-off-by: Davide Bertelli --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a14a43..518e7c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ else() set(HDDS_SEARCHING_FOR_VERSION OFF) foreach(line IN LISTS HDDS_CARGO_TOML) # Search in Cargo.toml for the pattern 'major[.minor][.patch][.tweak]' - if(HDDS_SEARCHING_FOR_VERSION AND "${line}" MATCHES "version[\r\n\t ]*=[\r\n\t ]*\"?([0-9]*([\.][0-9]+)?([\.][0-9]+)?([\.][0-9]+)?)\"?$") + if(HDDS_SEARCHING_FOR_VERSION AND "${line}" MATCHES "version[\r\n\t ]*=[\r\n\t ]*\"?([0-9]+([\.][0-9]+)?([\.][0-9]+)?([\.][0-9]+)?)\"?$") set(HDDS_PROJECT_VERSION ${CMAKE_MATCH_1}) break() endif() From 71faf44bfc85d7dabdf4646e301e63f446223f2d Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Fri, 31 Jul 2026 17:22:21 +0200 Subject: [PATCH 14/15] fix (CMake): removed quoting from `--crate-type` argument and added `VERBATIM` to add_custom_target Signed-off-by: Davide Bertelli --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 518e7c5..ac05b9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,9 +93,10 @@ endif() add_custom_target(${PROJECT_NAME}_rust ALL ${CARGO_EXECUTABLE} "rustc" "--manifest-path" "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml" "--package" "hdds-c" "${HDDS_CARGO_RELEASE_BUILD_FLAG}" - "--crate-type" $,"cdylib","staticlib"> + "--crate-type" $,cdylib,staticlib> "--target-dir" "${CMAKE_CURRENT_BINARY_DIR}" DEPENDS ${HDDS_C_HEADERS} # CMake will re-run the command whenever the files change + VERBATIM ) # Generate the imported library for HDDS and link it to the custom target to ensure the custom command to be called From 8249553014a5964120f559de49fe20ae2ec6c695 Mon Sep 17 00:00:00 2001 From: Davide-1998 Date: Fri, 31 Jul 2026 17:23:56 +0200 Subject: [PATCH 15/15] fix (CMake): added `BYPRODUCT` option to add_custom_target Signed-off-by: Davide Bertelli --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac05b9c..4df9ff8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ add_custom_target(${PROJECT_NAME}_rust ALL "--crate-type" $,cdylib,staticlib> "--target-dir" "${CMAKE_CURRENT_BINARY_DIR}" DEPENDS ${HDDS_C_HEADERS} # CMake will re-run the command whenever the files change + BYPRODUCTS ${HDDS_LIBRARY_OUTPUT} VERBATIM )