From a7b2e9b7712a12e7fc407484bd337d8dc12befce Mon Sep 17 00:00:00 2001 From: Keane Dixon Wong Date: Thu, 25 Sep 2025 01:41:41 -0700 Subject: [PATCH 1/3] 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) # Conflicts: # fastdds_python/test/types/test_complete.i # fastdds_python/test/types/test_modules.i # fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt --- fastdds_python/CMakeLists.txt | 7 + fastdds_python/test/types/CMakeLists.txt | 21 +++ fastdds_python/test/types/test_complete.i | 87 +++++++++++ fastdds_python/test/types/test_modules.i | 87 +++++++++++ .../HelloWorldExample/CMakeLists.txt | 7 + .../RPCExample/generated_code/CMakeLists.txt | 141 ++++++++++++++++++ 6 files changed, 350 insertions(+) create mode 100644 fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt diff --git a/fastdds_python/CMakeLists.txt b/fastdds_python/CMakeLists.txt index a622261a..d3575d8f 100644 --- a/fastdds_python/CMakeLists.txt +++ b/fastdds_python/CMakeLists.txt @@ -26,6 +26,13 @@ endif() project(fastdds_python VERSION 1.4.3) +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 b718edb0..9520faf8 100644 --- a/fastdds_python/test/types/CMakeLists.txt +++ b/fastdds_python/test/types/CMakeLists.txt @@ -27,6 +27,13 @@ find_package(fastrtps 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_modules.cxx @@ -135,6 +142,13 @@ find_package(fastrtps 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_modules.cxx @@ -243,6 +257,13 @@ find_package(fastrtps 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_complete.cxx diff --git a/fastdds_python/test/types/test_complete.i b/fastdds_python/test/types/test_complete.i index 629d3567..0228f089 100644 --- a/fastdds_python/test/types/test_complete.i +++ b/fastdds_python/test/types/test_complete.i @@ -212,6 +212,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore StructType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore StructType::fixed_string_field(); +%rename("%s") StructType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend StructType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore StructType::enum_field(Color&&); @@ -410,6 +439,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore CompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore CompleteTestType::fixed_string_field(); +%rename("%s") CompleteTestType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend CompleteTestType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore CompleteTestType::enum_field(Color&&); @@ -1708,6 +1766,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore KeyedCompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore KeyedCompleteTestType::fixed_string_field(); +%rename("%s") KeyedCompleteTestType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend KeyedCompleteTestType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore KeyedCompleteTestType::enum_field(Color&&); diff --git a/fastdds_python/test/types/test_modules.i b/fastdds_python/test/types/test_modules.i index b26a9895..41b5a9f7 100644 --- a/fastdds_python/test/types/test_modules.i +++ b/fastdds_python/test/types/test_modules.i @@ -211,6 +211,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore eprosima::test::StructType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore eprosima::test::StructType::fixed_string_field(); +%rename("%s") eprosima::test::StructType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend eprosima::test::StructType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::StructType::enum_field(eprosima::test::Color&&); @@ -398,6 +427,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore eprosima::test::CompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore eprosima::test::CompleteTestType::fixed_string_field(); +%rename("%s") eprosima::test::CompleteTestType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend eprosima::test::CompleteTestType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::CompleteTestType::enum_field(eprosima::test::Color&&); @@ -1696,6 +1754,35 @@ namespace swig { +<<<<<<< HEAD +======= +%ignore eprosima::test::KeyedCompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); + + +// Overloaded getter methods shadow each other and are equivalent in python +// Const accesors produced constant enums instead of arrays/dictionaries when used +// We ignore them to prevent this +%ignore eprosima::test::KeyedCompleteTestType::fixed_string_field(); +%rename("%s") eprosima::test::KeyedCompleteTestType::fixed_string_field() const; + +%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; +%extend eprosima::test::KeyedCompleteTestType +{ + void fixed_string_field(const std::string& value) + { + 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)); + } +} + + + +>>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::KeyedCompleteTestType::enum_field(eprosima::test::Color&&); diff --git a/fastdds_python_examples/HelloWorldExample/CMakeLists.txt b/fastdds_python_examples/HelloWorldExample/CMakeLists.txt index 75aa5e75..afde1f68 100644 --- a/fastdds_python_examples/HelloWorldExample/CMakeLists.txt +++ b/fastdds_python_examples/HelloWorldExample/CMakeLists.txt @@ -27,6 +27,13 @@ find_package(fastrtps 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 HelloWorld.cxx diff --git a/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt b/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt new file mode 100644 index 00000000..d00b75e0 --- /dev/null +++ b/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt @@ -0,0 +1,141 @@ + +# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.20) + +# SWIG: use standard target name. +if(POLICY CMP0078) + cmake_policy(SET CMP0078 NEW) +endif() + +# SWIG: use SWIG_MODULE_NAME property. +if(POLICY CMP0086) + cmake_policy(SET CMP0086 NEW) +endif() + +############################################################################### +# Library for types defined in calculator IDL +############################################################################### + +message(STATUS "Configuring python wrapper for types in calculator...") + +############################################################################### +# Type library on C++ + +project(calculator) + +find_package(fastcdr REQUIRED) +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 + calculatorPubSubTypes.cxx + calculatorClient.cxx + calculatorServer.cxx + ) +if(WIN32) + target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) +endif(WIN32) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_include_directories(${PROJECT_NAME} PUBLIC + ${PROJECT_SOURCE_DIR} + ) +target_link_libraries(${PROJECT_NAME} + PUBLIC + fastcdr + fastdds + ) + +############################################################################### +# Python bindings for type + +find_package(SWIG) +if (NOT SWIG_FOUND) + # Trick to find swig4.1 in Ubuntu noble. + find_program(SWIG_EXECUTABLE NAMES swig4.1 swig) + find_package(SWIG REQUIRED) +endif() +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_FLAGS "") + +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS}) +set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) + +include_directories(${PYTHON_INCLUDE_PATH}) + +set(${PROJECT_NAME}_MODULE + calculatorWrapper + ) + +set(${PROJECT_NAME}_MODULE_FILES + calculator.i + ) + +SET_SOURCE_FILES_PROPERTIES( + ${${PROJECT_NAME}_MODULE_FILES} + PROPERTIES CPLUSPLUS ON + USE_TARGET_INCLUDE_DIRECTORIES TRUE + ) + +SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} + TYPE SHARED + LANGUAGE python + SOURCES ${${PROJECT_NAME}_MODULE_FILES}) + +set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11) +if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) + set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) +endif() + +target_link_libraries(${${PROJECT_NAME}_MODULE} + Python3::Module + fastdds + ${PROJECT_NAME} + ) + +# Find the installation path +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) +file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) +SET (PYTHON_MODULE_PATH + ${_REL_PYTHON_MODULE_PATH}/${PROJECT_NAME} + ) + +# Install +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin/ + LIBRARY DESTINATION lib/ + ARCHIVE DESTINATION lib/ + ) +install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}) +get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES) +install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH} RENAME __init__.py) + From 6af54bc14531fe2904e121263d4c6adba44bb6cf Mon Sep 17 00:00:00 2001 From: Emilio Cuesta Date: Mon, 2 Mar 2026 10:51:31 +0100 Subject: [PATCH 2/3] Fix conflicts Signed-off-by: Emilio Cuesta --- fastdds_python/test/types/test_complete.i | 87 ----------------------- fastdds_python/test/types/test_modules.i | 87 ----------------------- 2 files changed, 174 deletions(-) diff --git a/fastdds_python/test/types/test_complete.i b/fastdds_python/test/types/test_complete.i index 0228f089..629d3567 100644 --- a/fastdds_python/test/types/test_complete.i +++ b/fastdds_python/test/types/test_complete.i @@ -212,35 +212,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore StructType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore StructType::fixed_string_field(); -%rename("%s") StructType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend StructType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore StructType::enum_field(Color&&); @@ -439,35 +410,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore CompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore CompleteTestType::fixed_string_field(); -%rename("%s") CompleteTestType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend CompleteTestType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore CompleteTestType::enum_field(Color&&); @@ -1766,35 +1708,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore KeyedCompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore KeyedCompleteTestType::fixed_string_field(); -%rename("%s") KeyedCompleteTestType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend KeyedCompleteTestType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore KeyedCompleteTestType::enum_field(Color&&); diff --git a/fastdds_python/test/types/test_modules.i b/fastdds_python/test/types/test_modules.i index 41b5a9f7..b26a9895 100644 --- a/fastdds_python/test/types/test_modules.i +++ b/fastdds_python/test/types/test_modules.i @@ -211,35 +211,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore eprosima::test::StructType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore eprosima::test::StructType::fixed_string_field(); -%rename("%s") eprosima::test::StructType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend eprosima::test::StructType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::StructType::enum_field(eprosima::test::Color&&); @@ -427,35 +398,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore eprosima::test::CompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore eprosima::test::CompleteTestType::fixed_string_field(); -%rename("%s") eprosima::test::CompleteTestType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend eprosima::test::CompleteTestType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::CompleteTestType::enum_field(eprosima::test::Color&&); @@ -1754,35 +1696,6 @@ namespace swig { -<<<<<<< HEAD -======= -%ignore eprosima::test::KeyedCompleteTestType::fixed_string_field(eprosima::fastcdr::fixed_string<16>&&); - - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore eprosima::test::KeyedCompleteTestType::fixed_string_field(); -%rename("%s") eprosima::test::KeyedCompleteTestType::fixed_string_field() const; - -%template(fixed_string_16) eprosima::fastcdr::fixed_string<16>; -%extend eprosima::test::KeyedCompleteTestType -{ - void fixed_string_field(const std::string& value) - { - 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)); - } -} - - - ->>>>>>> 57a5541 (Set CMAKE_SHARED_LIBRARY_SUFFIX to always create .so files (#207)) %ignore eprosima::test::KeyedCompleteTestType::enum_field(eprosima::test::Color&&); From 8e69359b34192f451dce8077780685a66b6977fa Mon Sep 17 00:00:00 2001 From: Emilio Cuesta Fernandez Date: Mon, 2 Mar 2026 11:37:18 +0100 Subject: [PATCH 3/3] Remove unwanted file for RPC examples Signed-off-by: Emilio Cuesta Fernandez --- .../RPCExample/generated_code/CMakeLists.txt | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100644 fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt diff --git a/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt b/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt deleted file mode 100644 index d00b75e0..00000000 --- a/fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ - -# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 3.20) - -# SWIG: use standard target name. -if(POLICY CMP0078) - cmake_policy(SET CMP0078 NEW) -endif() - -# SWIG: use SWIG_MODULE_NAME property. -if(POLICY CMP0086) - cmake_policy(SET CMP0086 NEW) -endif() - -############################################################################### -# Library for types defined in calculator IDL -############################################################################### - -message(STATUS "Configuring python wrapper for types in calculator...") - -############################################################################### -# Type library on C++ - -project(calculator) - -find_package(fastcdr REQUIRED) -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 - calculatorPubSubTypes.cxx - calculatorClient.cxx - calculatorServer.cxx - ) -if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) -endif(WIN32) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -target_include_directories(${PROJECT_NAME} PUBLIC - ${PROJECT_SOURCE_DIR} - ) -target_link_libraries(${PROJECT_NAME} - PUBLIC - fastcdr - fastdds - ) - -############################################################################### -# Python bindings for type - -find_package(SWIG) -if (NOT SWIG_FOUND) - # Trick to find swig4.1 in Ubuntu noble. - find_program(SWIG_EXECUTABLE NAMES swig4.1 swig) - find_package(SWIG REQUIRED) -endif() -include(${SWIG_USE_FILE}) -set(CMAKE_SWIG_FLAGS "") - -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) -set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS}) -set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) -set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) - -include_directories(${PYTHON_INCLUDE_PATH}) - -set(${PROJECT_NAME}_MODULE - calculatorWrapper - ) - -set(${PROJECT_NAME}_MODULE_FILES - calculator.i - ) - -SET_SOURCE_FILES_PROPERTIES( - ${${PROJECT_NAME}_MODULE_FILES} - PROPERTIES CPLUSPLUS ON - USE_TARGET_INCLUDE_DIRECTORIES TRUE - ) - -SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} - TYPE SHARED - LANGUAGE python - SOURCES ${${PROJECT_NAME}_MODULE_FILES}) - -set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11) -if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) - set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) -endif() - -target_link_libraries(${${PROJECT_NAME}_MODULE} - Python3::Module - fastdds - ${PROJECT_NAME} - ) - -# Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - -get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) -file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) -SET (PYTHON_MODULE_PATH - ${_REL_PYTHON_MODULE_PATH}/${PROJECT_NAME} - ) - -# Install -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin/ - LIBRARY DESTINATION lib/ - ARCHIVE DESTINATION lib/ - ) -install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}) -get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES) -install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH} RENAME __init__.py) -