Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#10727) Add recipe for cuda-api-wrappers/0.5.1 #10728

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/cuda-api-wrappers/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.5.1":
url: "https://github.com/eyalroz/cuda-api-wrappers/archive/refs/tags/v0.5.1.tar.gz"
sha256: "3a6d49f3da411c3da825b3781115c09e3420b49d53e83a3982cf4e222e223e4e"
34 changes: 34 additions & 0 deletions recipes/cuda-api-wrappers/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from conans.errors import ConanInvalidConfiguration

Checks from the linter will be mandatory in the near future, so better to start fixing them. Thanks!

import os

required_conan_version = ">=1.33.0"

class CudaKatConan(ConanFile):
name = "cuda-api-wrappers"
homepage = "https://github.com/eyalroz/cuda-api-wrappers"
description = "Thin C++-flavored wrappers for the CUDA APIs"
topics = ("gpgpu", "cuda", "cuda-api", "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()

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-api-wrappers"
self.cpp_info.names["cmake_find_package_multi"] = "cuda-api-wrappers"
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.cpp_info.names["cmake_find_package"] = "cuda-api-wrappers"
self.cpp_info.names["cmake_find_package_multi"] = "cuda-api-wrappers"
# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "cuda-api-wrappers"
self.cpp_info.names["cmake_find_package_multi"] = "cuda-api-wrappers"
self.cpp_info.set_property("cmake_file_name", "cuda-api-wrappers")
self.cpp_info.set_property("cmake_target_name", "cuda-api-wrapers::cuda-api-wrappers")

Better compatibility with Conan 2.0

Copy link
Contributor

@SpaceIm SpaceIm May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SpaceIm Thank you!

Copy link
Contributor Author

@aborzunov aborzunov May 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, how to declare 3 imported targets?

   def package_info(self):
       self.cpp_info.names["cmake_find_package"] = "cuda-api-wrappres"
       self.cpp_info.names["cmake_find_package_multi"] = "cuda-api-wrappers"

       self.cpp_info.components["runtime-and-driver"].names["cmake_find_package"] = "runtime-and-driver"
       self.cpp_info.components["runtime-and-driver"].system_libs = ["libcudart", "libcuda"]

       self.cpp_info.components["nvrtc"].names["cmake_find_package"] = "nvrtc"
       self.cpp_info.components["nvrtc"].system_libs = ["libnvrtc", "libcudart", "libcuda"]

       self.cpp_info.components["nvtx"].names["cmake_find_package"] = "nvtx"
       self.cpp_info.components["nvtx"].requires = ["runtime-and-driver"]
       self.cpp_info.components["nvtx"].system_libs = ["libnvToolsExt", "libthreads",
                                                       "libcudart", "libcuda"]

Can you provide any example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with Conan the only way to provide several targets is to create several components

11 changes: 11 additions & 0 deletions recipes/cuda-api-wrappers/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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-api-wrappers REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} cuda-api-wrappers::cuda-api-wrappers)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/cuda-api-wrappers/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions recipes/cuda-api-wrappers/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>
#include <cuda/undefine_specifiers.hpp>


int main() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try consuming something from header. You could generate a version, for instance: https://github.com/eyalroz/cuda-api-wrappers/blob/master/src/cuda/api/versions.hpp#L115

Copy link
Contributor

@SpaceIm SpaceIm May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not possible, there is a dependency to CUDA. This recipe shouldn't be merged until we have some cuda recipe, even a placeholder. #4844

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this recipe requires cuda it should declare it as requirement, even if this is a header-only package. Of course, we need first that recipe (placeholder, mock,...)

return 0;
}

3 changes: 3 additions & 0 deletions recipes/cuda-api-wrappers/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.5.1":
folder: all