Repository: conan-io/conan-center-index

Issue:
[request] libipt/v2.0.5
### Package Details
  * Package Name/Version: **libipt/v2.0.5**
  * Website: **https://github.com/intel/libipt**
  * Source code: **https://github.com/intel/libipt**


### Description Of The Library / Tool
Intel(R) Processor Trace Decoder Library
========================================

The Intel Processor Trace (Intel PT) Decoder Library is Intel's reference
implementation for decoding Intel PT.  It can be used as a standalone library or
it can be partially or fully integrated into your tool.

The library comes with a set of sample tools built on top of it and a test
system built on top of the sample tools.  The samples demonstrate how to use the
library and

PR follows


Discussion:

Resolving patch:
diff --git a/recipes/libipt/all/conanfile.py b/recipes/libipt/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/libipt/all/conanfile.py
@@ -0,0 +1,74 @@
+from conans import ConanFile, CMake, tools
+
+required_conan_version = ">=1.33.0"
+
+class LibIptConan(ConanFile):
+    name = "libipt"
+    license = "BSD-3-Clause"
+    homepage = "https://github.com/intel/libipt"
+    url = "https://github.com/conan-io/conan-center-index"
+    description = "Intel(R) Processor Trace Decoder Library"
+    topics = ("profiling", "tracing")
+    settings = "os", "compiler", "build_type", "arch"
+    options = {
+            "shared": [True, False],
+            "fPIC": [True, False],
+    }
+    default_options = {
+            "shared": False,
+            "fPIC": True,
+    }
+
+    generators = "cmake"
+    _cmake = None
+
+    @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):
+        pass
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version],
+               strip_root=True, destination=self._source_subfolder)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.configure()
+        return self._cmake
+
+    def export_sources(self):
+        self.copy("CMakeLists.txt")
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            self.copy(patch["patch_file"])
+
+    def _patch_sources(self):
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            tools.patch(**patch)
+
+    def build(self):
+        self._patch_sources()
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
+        cmake = self._configure_cmake()
+        cmake.install()
+
+    def package_info(self):
+        self.cpp_info.libs = ["libipt"] if self.settings.os == "Windows" else ["ipt"]
+        self.cpp_info.set_property("cmake_file_name", "libipt")
+        self.cpp_info.set_property("cmake_target_name", "libipt::libipt")
+


Test patch:
diff --git a/recipes/libipt/all/test_package/CMakeLists.txt b/recipes/libipt/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/libipt/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.8)
+project(test_package CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(libipt REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_compile_features(test_package PRIVATE cxx_std_11 cxx_constexpr)
+target_link_libraries(${PROJECT_NAME} libipt::libipt)
diff --git a/recipes/libipt/all/test_package/conanfile.py b/recipes/libipt/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/libipt/all/test_package/conanfile.py
@@ -0,0 +1,18 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "arch", "compiler", "build_type"
+    generators = "cmake", "cmake_find_package_multi"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/libipt/all/test_package/test_package.cpp b/recipes/libipt/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/libipt/all/test_package/test_package.cpp
@@ -0,0 +1,9 @@
+#include <intel-pt.h>
+
+int main(int argc, char **argv)
+{
+    pt_config cfg;
+    pt_config_init(&cfg);
+
+    return 0;
+}