Repository: conan-io/conan-center-index

Issue:
[request] ignition-tools/1.0.0 and ignition-tools/1.4.0
## Package Details
* Package Name/Version: **ignition-tools**
    Website: N/A
    Source code: [https://github.com/ignitionrobotics/ign-tools](https://github.com/ignitionrobotics/ign-tools)

## Description Of The Library / Tool

   *  For the latest release of [classic-gazebo](http://gazebosim.org/) (fortress), ignition-utils forms a part of one of the downstream dependencies. 
  * Quoting directly from github repo of ignition-tools:
      "Ignition tools provide the ign command line tool that accepts multiple subcommands. Each subcommand is implemented in a plugin that belongs to a specific Ignition project. For example, all the commands that start with ign topic ... will be implemented by the Ignition Transport library."


Discussion:

Resolving patch:
diff --git a/recipes/ignition-tools/all/conanfile.py b/recipes/ignition-tools/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/ignition-tools/all/conanfile.py
@@ -0,0 +1,105 @@
+import os
+from conans import CMake, ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+
+required_conan_version = ">=1.29.1"
+
+
+class IgnitionToolsConan(ConanFile):
+    name = "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
+
+    @property
+    def _minimum_cpp_standard(self):
+        return 17
+
+    @property
+    def _minimum_compilers_version(self):
+        return {
+            "Visual Studio": "16",
+            "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 configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+
+    def validate(self):
+        if self.settings.compiler.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++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 _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 build(self):
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            tools.patch(**patch)
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
+        cmake = self._configure_cmake()
+        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"))
+
+        # 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)
+
+    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)


Test patch:
diff --git a/recipes/ignition-tools/all/test_package/CMakeLists.txt b/recipes/ignition-tools/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/ignition-tools/all/test_package/CMakeLists.txt
@@ -0,0 +1,21 @@
+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
new file mode 100644
--- /dev/null
+++ b/recipes/ignition-tools/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package_multi"
+
+    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 test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/ignition-tools/all/test_package/test_package.cpp b/recipes/ignition-tools/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/ignition-tools/all/test_package/test_package.cpp
@@ -0,0 +1,7 @@
+#include <iostream>
+
+
+int main(int argc, char **argv)
+{
+  std::cout << "Hello from ignition-tools test_package\n";
+}