From e7ac6d4d1661c177a62de8f83656d58a925185ed Mon Sep 17 00:00:00 2001 From: Keane Dixon Wong Date: Thu, 25 Sep 2025 01:41:41 -0700 Subject: [PATCH] Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207) * Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files. * [#23543] Added cmake option and default suffix for platforms Signed-off-by: danipiza * [#23543] Added cmake option for Python test and examples Signed-off-by: danipiza * [#23543] Default value for Windows OS Signed-off-by: danipiza * [#23543] Review changes Signed-off-by: danipiza * Refs #23543. Regenerate code with Fast DDS Gen from related PR. Signed-off-by: Miguel Company --------- Signed-off-by: danipiza Signed-off-by: Miguel Company Co-authored-by: Keane Wong Co-authored-by: danipiza Co-authored-by: Miguel Company (cherry picked from commit 57a5541adddf9af6d4338872bba559d8f760e111) --- fastdds_python/CMakeLists.txt | 7 +++++++ fastdds_python/test/types/CMakeLists.txt | 21 +++++++++++++++++++ fastdds_python/test/types/test_complete.i | 15 +++++++++++++ fastdds_python/test/types/test_modules.i | 15 +++++++++++++ .../generated_code/CMakeLists.txt | 7 +++++++ .../RPCExample/generated_code/CMakeLists.txt | 7 +++++++ 6 files changed, 72 insertions(+) diff --git a/fastdds_python/CMakeLists.txt b/fastdds_python/CMakeLists.txt index 1e80c783..a73faa6d 100644 --- a/fastdds_python/CMakeLists.txt +++ b/fastdds_python/CMakeLists.txt @@ -26,6 +26,13 @@ endif() project(fastdds_python VERSION 2.3.0) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + # Set BUILD_TESTING to OFF by default. if(NOT BUILD_TESTING) message(STATUS "Tests not compiled by default") diff --git a/fastdds_python/test/types/CMakeLists.txt b/fastdds_python/test/types/CMakeLists.txt index 3809a1be..12ad5204 100644 --- a/fastdds_python/test/types/CMakeLists.txt +++ b/fastdds_python/test/types/CMakeLists.txt @@ -41,6 +41,13 @@ find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_included_modulesTypeObjectSupport.cxx @@ -146,6 +153,13 @@ find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_modulesTypeObjectSupport.cxx @@ -251,6 +265,13 @@ find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_completeTypeObjectSupport.cxx diff --git a/fastdds_python/test/types/test_complete.i b/fastdds_python/test/types/test_complete.i index accb8723..80daaa60 100644 --- a/fastdds_python/test/types/test_complete.i +++ b/fastdds_python/test/types/test_complete.i @@ -233,6 +233,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } @@ -444,6 +449,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } @@ -1699,6 +1709,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } diff --git a/fastdds_python/test/types/test_modules.i b/fastdds_python/test/types/test_modules.i index 5b4c32a0..ce8a42ad 100644 --- a/fastdds_python/test/types/test_modules.i +++ b/fastdds_python/test/types/test_modules.i @@ -232,6 +232,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } @@ -432,6 +437,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } @@ -1687,6 +1697,11 @@ namespace swig { eprosima::fastcdr::fixed_string<16> tmp(value); $self->fixed_string_field(tmp); } + + std::string fixed_string_field_str() const + { + return std::string($self->fixed_string_field(), strnlen($self->fixed_string_field(), 16)); + } } diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt b/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt index ead5e629..1e857efb 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt +++ b/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt @@ -41,6 +41,13 @@ find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED HelloWorldTypeObjectSupport.cxx diff --git a/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt b/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt index 79382f18..d00b75e0 100644 --- a/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt +++ b/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt @@ -41,6 +41,13 @@ find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED calculatorTypeObjectSupport.cxx