Skip to content

How to use conan-2 to package an existing library( ITK ) #17447

Open
@986247404

Description

@986247404

What is your question?

Hi!
I want to package the compiled ITK library. The conan command is " conan export-pkg . -s build_type=Release". But I can't use this recipe in a cmake project through find_package(). What should i do ? Looking forward to your reply.
My conanfile.py like this:

from conan import ConanFile
from conan.tools.files import copy, collect_libs
import os

class ITKConan(ConanFile):
name = "itk"
version = "5.1.0"
settings = "os", "compiler", "build_type", "arch"
package_type = "shared-library"

def layout(self):
    self.folders.build = "."
    self.folders.source = self.folders.build
    self.cpp.source.includedirs = ["include"]
    self.cpp.build.libdirs = ["lib"]
    self.cpp.build.bindirs = ["bin"]

def package(self):
    local_include_folder = os.path.join(self.source_folder, self.cpp.source.includedirs[0])
    local_lib_folder = os.path.join(self.build_folder, self.cpp.build.libdirs[0])
    local_bin_folder = os.path.join(self.build_folder, self.cpp.build.bindirs[0])
    copy(self, "*", local_include_folder, os.path.join(self.package_folder, "include")
         , keep_path=True)
    copy(self, "*", src=local_lib_folder,
         dst=os.path.join(self.package_folder, "lib"), keep_path=True)
    copy(self, "*", src=local_bin_folder,
         dst=os.path.join(self.package_folder, "bin"), keep_path=True)

def package_info(self):
    self.cpp_info.libs = collect_libs(self, folder=os.path.join(
        self.package_folder, "lib"))

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions