Repository: conan-io/conan-center-index

Issue:
[request] cuda-kat/0.2
### Package Details
  * Package Name/Version: **cuda-kat/0.2**
  * Source code: **https://github.com/eyalroz/cuda-kat**


### Description Of The Library / Tool

An install-less, header-only library which is a loosely-coupled collection of utility functions and classes for writing device-side CUDA code (kernels and non-kernel functions).


Discussion:
looking forward to see a PR!

Resolving patch:
diff --git a/recipes/cuda-kat/all/conanfile.py b/recipes/cuda-kat/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/cuda-kat/all/conanfile.py
@@ -0,0 +1,54 @@
+from conans import ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+import os
+
+required_conan_version = ">=1.33.0"
+
+class CudaKatConan(ConanFile):
+    name = "cuda-kat"
+    homepage = "https://github.com/eyalroz/cuda-kat"
+    description = "CUDA kernel author's tools"
+    topics = ("gpgpu", "cuda", "cuda-kat", "header-only")
+    url = "https://github.com/conan-io/conan-center-index"
+    no_copy_source = True
+    license = "BSD-3-Clause"
+
+    settings = "os", "arch", "compiler", "build_type"
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def package_id(self):
+        self.info.header_only()
+
+    @property
+    def _compilers_minimum_version(self):
+        return {
+            "gcc": "7",
+            "Visual Studio": "15",
+            "clang": "5",
+            "apple-clang": "10",
+            }
+
+    def validate(self):
+        if self.settings.os == "Windows":
+            raise ConanInvalidConfiguration("CUDA-kat library are not compatible on Windows")
+        if self.settings.compiler.get_safe("cppstd"):
+            tools.check_min_cppstd(self, 17)
+        minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
+        if not minimum_version:
+            self.output.warn(f"{self.name} requires C++17. Your compiler is unknown. Assuming it supports C++17.")
+        elif tools.Version(self.settings.compiler.version) < minimum_version:
+            raise ConanInvalidConfiguration(f"{self.name} requires a compiler that supports at least C++17")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)
+
+    def package(self):
+        self.copy(pattern="LICENSE*", src=self._source_subfolder, dst="licenses")
+        self.copy("*", src=os.path.join(self._source_subfolder, "src"), dst="include")
+
+    def package_info(self):
+        self.cpp_info.names["cmake_find_package"] = "cuda-kat"
+        self.cpp_info.names["cmake_find_package_multi"] = "cuda-kat"


Test patch:
diff --git a/recipes/cuda-kat/all/test_package/CMakeLists.txt b/recipes/cuda-kat/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/cuda-kat/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(cuda-kat REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} cuda-kat::cuda-kat)
+set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
diff --git a/recipes/cuda-kat/all/test_package/conanfile.py b/recipes/cuda-kat/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/cuda-kat/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.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/cuda-kat/all/test_package/test_package.cpp b/recipes/cuda-kat/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/cuda-kat/all/test_package/test_package.cpp
@@ -0,0 +1,13 @@
+#include <iostream>
+#include <kat/tuple.hpp>
+
+
+int main() {
+    auto t = kat::tuple<int>{1};
+    static_assert(kat::tuple_size<kat::tuple<int>>::value == 1, "tuple_size<tuple<T>> test failed.");
+    if ( kat::get<0>(t) != 1 )
+        { throw std::logic_error{""}; }
+
+    return 0;
+}
+