Skip to content
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

iceoryx: modernize for conan v2 #19330

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions recipes/iceoryx/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(cmake_wrapper)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder/iceoryx_meta")
find_package(acl)
if(acl_FOUND)
link_libraries(acl::acl)
endif()
add_subdirectory("iceoryx_meta")
40 changes: 9 additions & 31 deletions recipes/iceoryx/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,17 @@ sources:
"2.0.2":
url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.2.tar.gz"
sha256: "99871BCAA8DA4361D1BAAE9CF1507683058DE8572AC3080EDC41E590FFBA06C0"
"2.0.1":
url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.1.tar.gz"
sha256: "A6750992EA668786F267E4EDA5588DE4D7585F30E59DCF8512620AF509D6690F"
"2.0.0":
url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.0.tar.gz"
sha256: "C598DD0630F535D61EA9F8BDE5FE7DA3EF4C595419ECFBCD2384CA6FB4CA804F"
"1.0.1":
url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v1.0.1.tar.gz"
sha256: "c47f2e1e6cb7660a2d1c2666fa3b640a2f57275d2e524d0c80160a51a781e0dc"
"1.0.0":
url: "https://github.com/eclipse-iceoryx/iceoryx/archive/refs/tags/v1.0.0.tar.gz"
sha256: "3D7BABCF92974F6D22E8A497E31198DE1D88DF8B20C942992DBBEC5DFB06C4BB"
patches:
"2.0.2":
- base_path: "source_subfolder"
patch_file: "patches/2.0.X-0001-fix-find-toml.patch"
"2.0.1":
- base_path: "source_subfolder"
patch_file: "patches/2.0.X-0001-fix-find-toml.patch"
"2.0.0":
- base_path: "source_subfolder"
patch_file: "patches/2.0.X-0001-fix-find-toml.patch"
"1.0.1":
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0001-fix-find-toml.patch"
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0002-fix-install-bundle.patch"
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0003-no-hardcoded-libcxx.patch"
"1.0.0":
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0001-fix-find-toml.patch"
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0002-fix-install-bundle.patch"
- base_path: "source_subfolder"
patch_file: "patches/1.0.0-0003-no-hardcoded-libcxx.patch"
- patch_file: "patches/1.0.0-0001-fix-find-toml.patch"
patch_description: "Remove local cpptoml add_subdirectory call"
patch_type: "conan"
- patch_file: "patches/1.0.0-0002-fix-install-bundle.patch"
patch_description: "Add bundle destination for installation"
patch_type: "portability"
- patch_file: "patches/1.0.0-0003-no-hardcoded-libcxx.patch"
patch_description: "Remove libcxx link target"
patch_type: "portability"
115 changes: 58 additions & 57 deletions recipes/iceoryx/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd, stdcpp_library
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, replace_in_file, get, rmdir, mkdir, rename, save
from conan.tools.scm import Version
import os
import textwrap

required_conan_version = ">=1.43.0"
required_conan_version = ">=1.53.0"


class IceoryxConan(ConanFile):
Expand All @@ -12,7 +16,7 @@ class IceoryxConan(ConanFile):
homepage = "https://iceoryx.io/"
url = "https://github.com/conan-io/conan-center-index"
description = "Eclipse iceoryx - true zero-copy inter-process-communication"
topics = ("Shared Memory", "IPC", "ROS", "Middleware")
topics = ("shared-memory", "ipc", "ros2", "middleware")

settings = "os", "arch", "compiler", "build_type"
options = {
Expand All @@ -26,45 +30,40 @@ class IceoryxConan(ConanFile):
"toml_config": True,
}

generators = ["cmake", "cmake_find_package"]
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"
def layout(self):
cmake_layout(self,src_folder="src")

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

def requirements(self):
if self.options.toml_config:
self.requires("cpptoml/0.1.1")
self.requires("cpptoml/0.1.1", transitive_headers=True)
if self.settings.os == "Linux":
self.requires("acl/2.3.1")
self.requires("acl/2.3.1", transitive_headers=True)

def build_requirements(self):
if tools.Version(self.version) >= "2.0.0":
self.tool_requires("cmake/3.16.2")
if Version(self.version) >= "2.0.0":
self.tool_requires("cmake/[>=3.16.2 <4.0.0]")

def validate(self):
compiler = self.settings.compiler
version = tools.Version(self.settings.compiler.version)
version = Version(self.settings.compiler.version)

if compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 14)
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 14)

if compiler == "Visual Studio":
if version < "16":
if compiler == "msvc":
if version < "192":
raise ConanInvalidConfiguration("Iceoryx is just supported for Visual Studio 2019 and higher.")
if self.options.shared:
raise ConanInvalidConfiguration(
Expand All @@ -85,56 +84,57 @@ def validate(self):
raise ConanInvalidConfiguration("shared Debug with clang 7.0 and libc++ not supported")

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
copy(self, "CMakeLists.txt", self.export_sources_folder, self.source_folder)
apply_conandata_patches(self)
# Honor fPIC option
iceoryx_utils = "iceoryx_hoofs" if tools.Version(self.version) >= "2.0.0" else "iceoryx_utils"
iceoryx_utils = "iceoryx_hoofs" if Version(self.version) >= "2.0.0" else "iceoryx_utils"
for cmake_file in [
os.path.join("iceoryx_binding_c", "CMakeLists.txt"),
os.path.join("iceoryx_posh", "CMakeLists.txt"),
os.path.join(iceoryx_utils, "CMakeLists.txt")
]:
tools.replace_in_file(os.path.join(self._source_subfolder, cmake_file), "POSITION_INDEPENDENT_CODE ON", "")

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["TOML_CONFIG"] = self.options.toml_config
if tools.Version(self.version) >= "2.0.0":
self._cmake.definitions["DOWNLOAD_TOML_LIB"] = False
self._cmake.configure()
return self._cmake
replace_in_file(self, os.path.join(self.source_folder, cmake_file), "POSITION_INDEPENDENT_CODE ON", "")

def generate(self):
tc = CMakeToolchain(self)
tc.variables["TOML_CONFIG"] = self.options.toml_config
tc.variables["DOWNLOAD_TOML_LIB"] = False
tc.generate()

cd = CMakeDeps(self)
cd.generate()

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
if self.options.toml_config:
tools.mkdir(os.path.join(self.package_folder, "res"))
tools.rename(os.path.join(self.package_folder, "etc", "roudi_config_example.toml"),
os.path.join(self.package_folder, "res", "roudi_config.toml"))
tools.rmdir(os.path.join(self.package_folder, "etc"))
mkdir(self, os.path.join(self.package_folder, "res"))
rename(self, src=os.path.join(self.package_folder, "etc", "roudi_config_example.toml"),
dst=os.path.join(self.package_folder, "res", "roudi_config.toml"))
rmdir(self, os.path.join(self.package_folder, "etc"))
# bring to default package structure
if (tools.Version(self.version) >= "2.0.0"):
if (Version(self.version) >= "2.0.0"):
include_paths = ["iceoryx_binding_c", "iceoryx_hoofs", "iceoryx_posh", "iceoryx_versions.hpp"]
for include_path in include_paths:
tools.rename(
os.path.join(self.package_folder, "include", "iceoryx", "v{}".format(self.version), include_path),
os.path.join(self.package_folder, "include", include_path))
rename(self,
src=os.path.join(self.package_folder, "include", "iceoryx", "v{}".format(self.version), include_path),
dst=os.path.join(self.package_folder, "include", include_path))

# TODO: to remove in conan v2 once cmake_find_package* generators removed
if (tools.Version(self.version) >= "2.0.0"):
if (Version(self.version) >= "2.0.0"):
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._module_file_rel_path),
{v["target"]: "iceoryx::{}".format(k)
Expand Down Expand Up @@ -164,7 +164,7 @@ def cpptoml():
return ["cpptoml::cpptoml"] if self.options.toml_config else []

def libcxx():
libcxx = tools.stdcpp_library(self)
libcxx = stdcpp_library(self)
return [libcxx] if libcxx and not self.options.shared else []

return {
Expand Down Expand Up @@ -251,8 +251,7 @@ def libcxx():
}
}

@staticmethod
def _create_cmake_module_alias_targets(module_file, targets):
def _create_cmake_module_alias_targets(self, module_file, targets):
content = ""
for alias, aliased in targets.items():
content += textwrap.dedent("""\
Expand All @@ -261,7 +260,7 @@ def _create_cmake_module_alias_targets(module_file, targets):
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
endif()
""".format(alias=alias, aliased=aliased))
tools.save(module_file, content)
save(self, module_file, content)

@property
def _module_file_rel_path(self):
Expand All @@ -288,11 +287,13 @@ def _register_components(components):
self._module_file_rel_path
]

if tools.Version(self.version) >= "2.0.0":
if Version(self.version) >= "2.0.0":
_register_components(self._iceoryx_components["2.0.0"])
else:
_register_components(self._iceoryx_components["1.0.X"])

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(bin_path)
self.buildenv_info.append_path("PATH", bin_path)
self.runenv_info.append_path("PATH", bin_path)
12 changes: 2 additions & 10 deletions recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ index 6df5429b..e7dedbc4 100644
+++ b/iceoryx_posh/CMakeLists.txt
@@ -27,8 +27,6 @@ option(TOML_CONFIG "TOML support for RouDi with dynamic configuration" ON)
option(ONE_TO_MANY_ONLY "Restricts communication to 1:n pattern" OFF)

if(TOML_CONFIG)
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpptoml/ ${CMAKE_BINARY_DIR}/dependencies/posh/cpptoml/prebuild)
-
find_package(cpptoml REQUIRED)
endif()

@@ -325,7 +323,6 @@ if(TOML_CONFIG)
iceoryx_posh::iceoryx_posh
iceoryx_utils::iceoryx_utils
iceoryx_posh::iceoryx_posh_roudi
- cpptoml
${ICEORYX_SANITIZER_FLAGS}
)


7 changes: 2 additions & 5 deletions recipes/iceoryx/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

if (${MSVC})
if (MSVC)
set(CMAKE_CXX_STANDARD 17)
else()
else()
set(CMAKE_CXX_STANDARD 14)
endif()

Expand Down
18 changes: 14 additions & 4 deletions recipes/iceoryx/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import os
from conans import ConanFile, CMake
import os.path
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

Check warning on line 5 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused can_run imported from conan.tools.build

Check warning on line 5 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused can_run imported from conan.tools.build

class IceoryxTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = ["cmake", "cmake_find_package_multi"]
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
Expand All @@ -17,5 +27,5 @@
# a bad idea (checked on 3 different linux devices
# always ok - but in container get
# "fatal SIGBUS signal appeared caused by memset")
path, dirs, files = next(os.walk("bin"))
print("All %d example files are present" % (len(files)))
path, dirs, files = next(os.walk(self.cpp.build.bindir))

Check warning on line 30 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused variable 'path'

Check warning on line 30 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused variable 'dirs'

Check warning on line 30 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused variable 'path'

Check warning on line 30 in recipes/iceoryx/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused variable 'dirs'
print(f"All {len(files)} example files are present")
8 changes: 8 additions & 0 deletions recipes/iceoryx/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
22 changes: 22 additions & 0 deletions recipes/iceoryx/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import os.path
from conans import ConanFile, CMake

class IceoryxTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = ["cmake", "cmake_find_package_multi"]

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
# ToDo : add an executable which can be
# executed in container.
# currently seems shared memory in container is
# a bad idea (checked on 3 different linux devices
# always ok - but in container get
# "fatal SIGBUS signal appeared caused by memset")
path, dirs, files = next(os.walk("bin"))
print("All %d example files are present" % (len(files)))
6 changes: 0 additions & 6 deletions recipes/iceoryx/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
versions:
"2.0.2":
folder: all
"2.0.1":
folder: all
"2.0.0":
folder: all
"1.0.1":
folder: all
"1.0.0":
folder: all