diff --git a/recipes/ignition-tools/all/CMakeLists.txt b/recipes/ignition-tools/all/CMakeLists.txt deleted file mode 100644 index f980aea13cc6d..0000000000000 --- a/recipes/ignition-tools/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.10.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -add_subdirectory(source_subfolder) diff --git a/recipes/ignition-tools/all/conandata.yml b/recipes/ignition-tools/all/conandata.yml index 8a58ba77dc143..369fb6e0f8b7f 100644 --- a/recipes/ignition-tools/all/conandata.yml +++ b/recipes/ignition-tools/all/conandata.yml @@ -1,8 +1,4 @@ sources: "1.4.0": url: "https://github.com/ignitionrobotics/ign-tools/archive/refs/tags/ignition-tools_1.4.0.tar.gz" - sha256: "fa3f7984ebb8f412133ea93368395adce426ae36c715a9f94f9509af7dac3b03" -patches: - "1.4.0": - - base_path: "source_subfolder" - patch_file: "patches/0003-ign-tools-1.4.0-cmake-fixes.patch" + sha256: "8ceebefcd1977dc2e26beede347a9c06d851b89ec0fd7d5c86126f43a49ac178" diff --git a/recipes/ignition-tools/all/conanfile.py b/recipes/ignition-tools/all/conanfile.py index ba8d22e6561de..1a952d068e8ed 100644 --- a/recipes/ignition-tools/all/conanfile.py +++ b/recipes/ignition-tools/all/conanfile.py @@ -1,23 +1,25 @@ import os -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.29.1" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rm, rmdir, replace_in_file, load, save +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class IgnitionToolsConan(ConanFile): name = "ignition-tools" + description = "Ignition entry point for using all the suite of ignition tools." license = "Apache-2.0" - homepage = "https://ignitionrobotics.org/libs/tools" url = "https://github.com/conan-io/conan-center-index" - description = "Provides general purpose classes and functions designed for robotic applications.." - topics = ("ignition", "robotics", "tools") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - generators = "cmake", "cmake_find_package_multi" - exports_sources = "CMakeLists.txt", "patches/**" - _cmake = None + homepage = "https://ignitionrobotics.org/libs/tools" + topics = ("ignition", "robotics", "tools", "gazebo") + + package_type = "application" + settings = "os", "arch", "compiler", "build_type" @property def _minimum_cpp_standard(self): @@ -27,79 +29,96 @@ def _minimum_cpp_standard(self): def _minimum_compilers_version(self): return { "Visual Studio": "16", + "msvc": "192", "gcc": "7", "clang": "5", "apple-clang": "10", } - @property - def _source_subfolder(self): - return "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") - def configure(self): - if self.options.shared: - del self.options.fPIC + def requirements(self): + self.requires("backward-cpp/1.6") def validate(self): if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, self._minimum_cpp_standard) + 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 - ) + if min_version and Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + f"{self.name} requires c++17 support. " + f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it." ) - else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration( - "{} requires c++17 support. The current compiler {} {} does not support it.".format( - self.name, - self.settings.compiler, - self.settings.compiler.version, - ) - ) - def source(self): - tools.get(**self.conan_data["sources"][self.version],destination=self._source_subfolder, strip_root=True) + def build_requirements(self): + # FIXME: Ruby is required as a transitive dependency for the `ign` Ruby script + # FIXME: The ign script has additional Ruby dependencies + # self.tool_requires("ruby/3.1.0") + pass - def _configure_cmake(self): - if self._cmake is not None: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["USE_SYSTEM_BACKWARDCPP"] = True + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["BUILD_TESTING"] = False + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + for cmakelists in self.source_path.rglob("CMakeLists.txt"): + replace_in_file(self, cmakelists, "${CMAKE_SOURCE_DIR}", "${PROJECT_SOURCE_DIR}", strict=False) + replace_in_file(self, cmakelists, "${CMAKE_BINARY_DIR}", "${PROJECT_BINARY_DIR}", strict=False) + # Generating ign.rb fails on Windows, do it outside of CMake in package() instead + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), + "# Two steps to create `ign`", "return() #") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() + @staticmethod + def _chmod_plus_x(filename): + if os.name == "posix": + os.chmod(filename, os.stat(filename).st_mode | 0o111) + def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + # Generate ign.rb + ign_rb_content = load(self, os.path.join(self.source_folder, "src", "ign.in")) + # FIXME: this is not relocatable + ign_rb_content = ign_rb_content.replace("@CMAKE_INSTALL_PREFIX@", self.package_folder.replace("\\", "/")) + ign_rb_content = ign_rb_content.replace("@ENV_PATH_DELIMITER@", os.pathsep) + suffix = ".rb" if self.settings.os == "Windows" else "" + ign_rb_path = os.path.join(self.package_folder, "bin", f"ign{suffix}") + save(self, ign_rb_path, ign_rb_content) + self._chmod_plus_x(ign_rb_path) + + 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")) # Remove MS runtime files for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), dll_pattern_to_remove) + rm(self, dll_pattern_to_remove, os.path.join(self.package_folder, "bin"), recursive=True) def package_info(self): - version_major = tools.Version(self.version).major - self.cpp_info.names["cmake_find_package"] = "ignition-tools{}".format(version_major) - self.cpp_info.names["cmake_find_package_multi"] = "ignition-tools{}".format(version_major) - - self.cpp_info.components["libignition-tools"].libs = ["ignition-tools-backward"] - self.cpp_info.components["libignition-tools"].includedirs.append("include/ignition/tools{}".format(version_major)) - self.cpp_info.components["libignition-tools"].names["cmake_find_package"] = "ignition-tools{}".format(version_major) - self.cpp_info.components["libignition-tools"].names["cmake_find_package_multi"] = "ignition-tools{}".format(version_major) - self.cpp_info.components["libignition-tools"].names["pkg_config"] = "ignition-tools{}".format(version_major) + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + + # The package builds an ignition-tools-backward wrapper library, + # but it's only meant to be used as a runtime dependency of the ign script + + # TODO: Legacy, to be removed on Conan 2.0 + bin_folder = os.path.join(self.package_folder, "bin") + self.env_info.PATH.append(bin_folder) diff --git a/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch deleted file mode 100644 index a02000ed7c157..0000000000000 --- a/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -251,7 +251,7 @@ else (build_errors) - ######################################## - # Make the package config files - configure_file( -- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in -+ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc - DESTINATION ${LIB_INSTALL_DIR}/pkgconfig - ---- doc/CMakeLists.txt -+++ doc/CMakeLists.txt -@@ -1,8 +1,8 @@ - find_package(Doxygen) - - if (DOXYGEN_FOUND) -- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in -- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) -+ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in -+ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) - - add_custom_target(doc - diff --git a/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch deleted file mode 100644 index 301608c99c533..0000000000000 --- a/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -257,7 +257,7 @@ else (build_errors) - "${CMAKE_INSTALL_PREFIX}" - ) - configure_file( -- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in -+ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc - DESTINATION ${PC_CONFIG_INSTALL_DIR} - ---- doc/CMakeLists.txt -+++ doc/CMakeLists.txt -@@ -1,8 +1,8 @@ - find_package(Doxygen) - - if (DOXYGEN_FOUND) -- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in -- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) -+ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in -+ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) - - add_custom_target(doc - diff --git a/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch deleted file mode 100644 index 3e856a0a90956..0000000000000 --- a/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -185,7 +185,7 @@ else (build_errors) - "${CMAKE_INSTALL_PREFIX}" - ) - configure_file( -- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in -+ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc - DESTINATION ${PC_CONFIG_INSTALL_DIR} - ---- doc/CMakeLists.txt -+++ doc/CMakeLists.txt -@@ -1,8 +1,8 @@ - find_package(Doxygen) - - if (DOXYGEN_FOUND) -- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in -- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) -+ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in -+ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) - - add_custom_target(doc - diff --git a/recipes/ignition-tools/all/test_package/CMakeLists.txt b/recipes/ignition-tools/all/test_package/CMakeLists.txt deleted file mode 100644 index 294e2c5ebc47c..0000000000000 --- a/recipes/ignition-tools/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -set(IGN_TOOLS_MAJOR_VER "" CACHE STRING "Version of igition-tools") - -if(NOT IGN_TOOLS_MAJOR_VER) - message(FATAL_ERROR "IGN_MAJOR_MAJOR_VER not set") -endif() - -find_package(ignition-tools${IGN_TOOLS_MAJOR_VER} REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ignition-tools${IGN_TOOLS_MAJOR_VER}::ignition-tools${IGN_TOOLS_MAJOR_VER}) -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS ON -) diff --git a/recipes/ignition-tools/all/test_package/conanfile.py b/recipes/ignition-tools/all/test_package/conanfile.py index ad00162038ccc..871b2e239dd5a 100644 --- a/recipes/ignition-tools/all/test_package/conanfile.py +++ b/recipes/ignition-tools/all/test_package/conanfile.py @@ -1,17 +1,21 @@ -from conans import ConanFile, CMake, tools -import os +from conan import ConanFile +from conan.tools.layout import basic_layout + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str, run=True) - def build(self): - cmake = CMake(self) - cmake.definitions["IGN_TOOLS_MAJOR_VER"] = tools.Version(self.deps_cpp_info["ignition-tools"].version).major - cmake.configure() - cmake.build() + def layout(self): + basic_layout(self) 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) + # FIXME: Can't actually run this since Ruby and required Ruby gems are not set up + if self.settings.os == "Windows": + self.run("where ign", scope="conanrun") + else: + self.run("which ign", scope="conanrun") diff --git a/recipes/ignition-tools/all/test_package/test_package.cpp b/recipes/ignition-tools/all/test_package/test_package.cpp deleted file mode 100644 index 262e67cc01fba..0000000000000 --- a/recipes/ignition-tools/all/test_package/test_package.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - - -int main(int argc, char **argv) -{ - std::cout << "Hello from ignition-tools test_package\n"; -}