diff --git a/recipes/iceoryx/all/CMakeLists.txt b/recipes/iceoryx/all/CMakeLists.txt index ae4d7a261b19e..9445649028085 100644 --- a/recipes/iceoryx/all/CMakeLists.txt +++ b/recipes/iceoryx/all/CMakeLists.txt @@ -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") diff --git a/recipes/iceoryx/all/conandata.yml b/recipes/iceoryx/all/conandata.yml index 638b5224b83e0..3083339c1d447 100644 --- a/recipes/iceoryx/all/conandata.yml +++ b/recipes/iceoryx/all/conandata.yml @@ -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" diff --git a/recipes/iceoryx/all/conanfile.py b/recipes/iceoryx/all/conanfile.py index c14f7ee13f243..f554feb668ec2 100644 --- a/recipes/iceoryx/all/conanfile.py +++ b/recipes/iceoryx/all/conanfile.py @@ -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): @@ -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 = { @@ -26,17 +30,12 @@ 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": @@ -44,27 +43,27 @@ def config_options(self): 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( @@ -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) @@ -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 { @@ -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("""\ @@ -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): @@ -288,7 +287,7 @@ 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"]) @@ -296,3 +295,5 @@ def _register_components(components): 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) diff --git a/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch b/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch index 062232389f69a..785756fba4145 100644 --- a/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch +++ b/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch @@ -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} - ) - + diff --git a/recipes/iceoryx/all/test_package/CMakeLists.txt b/recipes/iceoryx/all/test_package/CMakeLists.txt index 4d89e84377074..bc3d5a8af8754 100644 --- a/recipes/iceoryx/all/test_package/CMakeLists.txt +++ b/recipes/iceoryx/all/test_package/CMakeLists.txt @@ -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() diff --git a/recipes/iceoryx/all/test_package/conanfile.py b/recipes/iceoryx/all/test_package/conanfile.py index 50e21d11f1ebd..608a8ae053a7b 100644 --- a/recipes/iceoryx/all/test_package/conanfile.py +++ b/recipes/iceoryx/all/test_package/conanfile.py @@ -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 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) @@ -17,5 +27,5 @@ def test(self): # 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)) + print(f"All {len(files)} example files are present") diff --git a/recipes/iceoryx/all/test_v1_package/CMakeLists.txt b/recipes/iceoryx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/iceoryx/all/test_v1_package/CMakeLists.txt @@ -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) diff --git a/recipes/iceoryx/all/test_v1_package/conanfile.py b/recipes/iceoryx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..950ffe1ef4fd1 --- /dev/null +++ b/recipes/iceoryx/all/test_v1_package/conanfile.py @@ -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))) diff --git a/recipes/iceoryx/config.yml b/recipes/iceoryx/config.yml index bb084f4416dd3..b7e2d4a8d4264 100644 --- a/recipes/iceoryx/config.yml +++ b/recipes/iceoryx/config.yml @@ -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