-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Fast dds #5968
Add Fast dds #5968
Changes from all commits
0b0fd98
025a4ab
0617129
fb23447
76921b4
53c0bba
aef792d
d7e7088
2e2faf4
75e8e40
2857abd
84a3525
cab9911
8116fdf
7a01e15
59ec565
ea11a79
a161e6a
1dfdaa6
768f742
b9fb19e
a3af699
97b7997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(cmake_wrapper) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sources: | ||
"2.3.2": | ||
url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" | ||
sha256: "4D8183CF4D37C3DE9E6FD28D2850DD08023A9079001C4880B23C95F0D8C0B5CE" | ||
patches: | ||
"2.3.2": | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
from conans.errors import ConanInvalidConfiguration | ||
import textwrap | ||
|
||
class FastDDSConan(ConanFile): | ||
|
||
name = "fast-dds" | ||
license = "Apache-2.0" | ||
homepage = "https://fast-dds.docs.eprosima.com/" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
description = "The most complete OSS DDS implementation for embedded systems." | ||
topics = ("DDS", "Middleware", "IPC") | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_ssl": [True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_ssl": False | ||
} | ||
generators = "cmake", "cmake_find_package" | ||
_cmake = None | ||
exports_sources = ["patches/**", "CMakeLists.txt"] | ||
|
||
@property | ||
def _pkg_share(self): | ||
return os.path.join( | ||
self.package_folder, | ||
"share" | ||
) | ||
|
||
@property | ||
def _pkg_tools(self): | ||
return os.path.join( | ||
self.package_folder, | ||
"tools" | ||
) | ||
|
||
@property | ||
def _pkg_bin(self): | ||
return os.path.join( | ||
self.package_folder, | ||
"bin" | ||
) | ||
|
||
@property | ||
def _module_subfolder(self): | ||
return os.path.join( | ||
"lib", | ||
"cmake" | ||
) | ||
|
||
@property | ||
def _module_file_rel_path(self): | ||
return os.path.join( | ||
self._module_subfolder, | ||
"conan-target-properties.cmake" | ||
) | ||
|
||
@property | ||
def _minimum_cpp_standard(self): | ||
return 11 | ||
|
||
@property | ||
def _minimum_compilers_version(self): | ||
return { | ||
"Visual Studio": "16", | ||
"gcc": "5", | ||
"clang": "3.9", | ||
"apple-clang": "8", | ||
} | ||
|
||
@staticmethod | ||
def _create_cmake_module_alias_targets(module_file, targets): | ||
content = "" | ||
for alias, aliased in targets.items(): | ||
content += textwrap.dedent("""\ | ||
if(TARGET {aliased} AND NOT TARGET {alias}) | ||
add_library({alias} INTERFACE IMPORTED) | ||
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) | ||
endif() | ||
""".format(alias=alias, aliased=aliased)) | ||
tools.save(module_file, content) | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def _patch_sources(self): | ||
for patch in self.conan_data["patches"][self.version]: | ||
tools.patch(**patch) | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def _configure_cmake(self): | ||
if not self._cmake: | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False | ||
self._cmake.definitions["NO_TLS"] = not self.options.with_ssl | ||
self._cmake.definitions["SECURITY"] = self.options.with_ssl | ||
self._cmake.definitions["EPROSIMA_INSTALLER_MINION"] = False | ||
self._cmake.configure() | ||
return self._cmake | ||
|
||
def requirements(self): | ||
self.requires("tinyxml2/7.1.0") | ||
self.requires("asio/1.18.2") | ||
self.requires("fast-cdr/1.0.21") | ||
self.requires("foonathan-memory/0.7.0") | ||
self.requires("boost/1.73.0") | ||
if self.options.with_ssl: | ||
self.requires("openssl/1.1.1k") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], strip_root=True, | ||
destination=self._source_subfolder) | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, self._minimum_cpp_standard) | ||
min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) | ||
if not min_version: | ||
self.output.warn("{} recipe lacks information about the {} compiler support.".format( | ||
self.name, self.settings.compiler)) | ||
else: | ||
if tools.Version(self.settings.compiler.version) < min_version: | ||
raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( | ||
self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) | ||
if self.settings.os == "Windows": | ||
if ("MT" in self.settings.compiler.runtime and self.options.shared): | ||
# This combination leads to an fast-dds error when linking | ||
# linking dynamic '*.dll' and static MT runtime | ||
raise ConanInvalidConfiguration("Mixing a dll {} library with a static runtime is a bad idea".format(self.name)) | ||
|
||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(self._pkg_share) | ||
self.copy("LICENSE", src=self._source_subfolder, dst="licenses") | ||
tools.rename( | ||
src=self._pkg_tools, | ||
dst=os.path.join(self._pkg_bin, "tools") | ||
) | ||
tools.remove_files_by_mask( | ||
directory=os.path.join(self.package_folder, "lib"), | ||
pattern="*.pdb" | ||
) | ||
tools.remove_files_by_mask( | ||
directory=os.path.join(self.package_folder, "bin"), | ||
pattern="*.pdb" | ||
) | ||
self._create_cmake_module_alias_targets( | ||
os.path.join(self.package_folder, self._module_file_rel_path), | ||
{"fastrtps": "fastdds::fastrtps"} | ||
) | ||
|
||
def package_info(self): | ||
self.cpp_info.names["cmake_find_package"] = "fastdds" | ||
self.cpp_info.names["cmake_find_multi_package"] = "fastdds" | ||
# component fastrtps | ||
self.cpp_info.components["fastrtps"].name = "fastrtps" | ||
self.cpp_info.components["fastrtps"].libs = tools.collect_libs(self) | ||
self.cpp_info.components["fastrtps"].requires = [ | ||
"fast-cdr::fast-cdr", | ||
"asio::asio", | ||
"tinyxml2::tinyxml2", | ||
"foonathan-memory::foonathan-memory", | ||
"boost::boost" | ||
] | ||
if self.settings.os in ["Linux", "Macos", "Neutrino"]: | ||
self.cpp_info.components["fastrtps"].system_libs.append("pthread") | ||
if self.settings.os == "Linux": | ||
self.cpp_info.components["fastrtps"].system_libs.extend(["rt", "dl", "atomic"]) | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.components["fastrtps"].system_libs.extend(["iphlpapi","shlwapi"]) | ||
if self.options.shared: | ||
self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") | ||
if self.options.with_ssl: | ||
self.cpp_info.components["fastrtps"].requires.append("openssl::openssl") | ||
self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) | ||
self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] | ||
self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] | ||
# component fast-discovery | ||
self.cpp_info.components["fast-discovery"].name = "fast-discovery" | ||
self.cpp_info.components["fast-discovery"].bindirs = ["bin"] | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH env var for fast-dds::fast-discovery with : {}".format(bin_path)), | ||
self.env_info.PATH.append(bin_path) | ||
# component tools | ||
self.cpp_info.components["tools"].name = "tools" | ||
self.cpp_info.components["tools"].bindirs = [os.path.join("bin","tools")] | ||
Comment on lines
+206
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As usual, too generic for a conan component name where pkg_config name is not overriden. Anyway this component doesn't exist upstream (there are tools, but their targets are not exported). I advice also to be explicit on the type of "names" (names["cmake_find_package"] etc, this library doesn't provide official pkgconfig files for example). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will be resolved in #6429 |
||
bin_path = os.path.join(self._pkg_bin, "tools") | ||
self.output.info("Appending PATH env var for fast-dds::tools with : {}".format(bin_path)), | ||
self.env_info.PATH.append(bin_path) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 8a9cb0209..400c681e7 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -225,8 +225,8 @@ if(NOT BUILD_SHARED_LIBS) | ||
endif() | ||
|
||
eprosima_find_package(fastcdr REQUIRED) | ||
-eprosima_find_thirdparty(Asio asio VERSION 1.10.8) | ||
-eprosima_find_thirdparty(TinyXML2 tinyxml2) | ||
+eprosima_find_thirdparty(asio REQUIRED) | ||
+eprosima_find_thirdparty(tinyxml2 REQUIRED) | ||
|
||
find_package(foonathan_memory REQUIRED) | ||
message(STATUS "Found foonathan_memory: ${foonathan_memory_DIR}") | ||
diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt | ||
index 04d313bf2..c7d64f04d 100644 | ||
--- a/src/cpp/CMakeLists.txt | ||
+++ b/src/cpp/CMakeLists.txt | ||
@@ -455,7 +455,7 @@ elseif(NOT EPROSIMA_INSTALLER) | ||
# Link library to external libraries. | ||
target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory | ||
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} | ||
- ${TINYXML2_LIBRARY} | ||
+ tinyxml2::tinyxml2 | ||
$<$<BOOL:${LINK_SSL}>:OpenSSL::SSL$<SEMICOLON>OpenSSL::Crypto> | ||
$<$<BOOL:${WIN32}>:iphlpapi$<SEMICOLON>Shlwapi> | ||
${THIRDPARTY_BOOST_LINK_LIBS} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
find_package(fastdds REQUIRED) | ||
|
||
add_executable(test_package | ||
test_package.cpp | ||
msg/HelloWorld.cxx | ||
msg/HelloWorldPubSubTypes.cxx | ||
) | ||
|
||
set_property(TARGET test_package PROPERTY CXX_STANDARD 11) | ||
|
||
target_link_libraries(test_package | ||
fastrtps | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's
fast-discovery-server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh Jesus.... Damn.... I would rise an issue and assign it to myself. And in a separate PR resolve the issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be resolved in #6429