conan-io / wishlist

This repo is to propose libraries, frameworks, and code in general that users would like to have in conan
MIT License
49 stars 5 forks source link

[request] LevelDB/1.22.0 #256

Closed osfd closed 4 years ago

osfd commented 4 years ago

Package Details

LevelDB Now in google i can find only old version. Recipe uses deplecated features from conan. I try create library with this file:

from conans import ConanFile, CMake, tools

class LeveldbConan(ConanFile):
    name = "leveldb"
    version = "1.22.0"
    license = "<Put the package license here>"
    author = "<Put your name here> <And your email here>"
    url = "https://github.com/google/leveldb"
    description = "<Description of Leveldb here>"
    topics = ("<Put some tag here>", "<here>", "<and here>")
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = {"shared": False}
    generators = "cmake"

    def source(self):
        self.run("git clone --recurse-submodules https://github.com/google/leveldb.git")
        # This small hack might be useful to guarantee proper /MT /MD linkage
        # in MSVC if the packaged project doesn't have variables to set it
        # properly
        #tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(HelloWorld)",
        #                      '''PROJECT(HelloWorld)
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
#conan_basic_setup()''')

    def build(self):
        cmake = CMake(self)
        cmake.configure(source_folder="leveldb")
        cmake.build()

        # Explicit way:
        # self.run('cmake %s/hello %s'
        #          % (self.source_folder, cmake.command_line))
        # self.run("cmake --build . %s" % cmake.build_config)

    def package(self):
        self.copy("*.h", dst="include", src="leveldb")
        self.copy("*.lib", dst="lib", keep_path=False)
        self.copy("*.dll", dst="bin", keep_path=False)
        self.copy("*.so", dst="lib", keep_path=False)
        self.copy("*.dylib", dst="lib", keep_path=False)
        self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["leveldb"]

But it's don't work

Croydon commented 4 years ago

Duplicate of #25

osfd commented 4 years ago

I'm fixed it. But i think possible change hardcoded path for copy, to an elegant command. If it's not interesting, I'm close issue on next week.

conanfile.py

from conans import ConanFile, CMake, tools

class LeveldbConan(ConanFile):
    name = "leveldb"
    version = "1.22.0"
    license = "<Put the package license here>"
    author = "<Put your name here> <And your email here>"
    url = "https://github.com/google/leveldb"
    description = "<Description of Leveldb here>"
    topics = ("<Put some tag here>", "<here>", "<and here>")
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = {"shared": False}
    generators = "cmake"

    def source(self):
        self.run("git clone --recurse-submodules https://github.com/google/leveldb.git")
        # This small hack might be useful to guarantee proper /MT /MD linkage
        # in MSVC if the packaged project doesn't have variables to set it
        # properly
        #tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(HelloWorld)",
        #                      '''PROJECT(HelloWorld)
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
#conan_basic_setup()''')

    def build(self):
        cmake = CMake(self)
        cmake.configure(source_folder="leveldb")
        cmake.build()
        cmake.install()
        # I think it's not good:
        self.run("cp ./CMakeFiles/Export/lib/cmake/leveldb/leveldbTargets.cmake ./cmake")

        # Explicit way:
        # self.run('cmake %s/hello %s'
        #          % (self.source_folder, cmake.command_line))
        # self.run("cmake --build . %s" % cmake.build_config)

    def package(self):
        self.copy("*.h", dst="include", src="leveldb")
        self.copy("*.lib", dst="lib", keep_path=False)
        self.copy("*.dll", dst="bin", keep_path=False)
        self.copy("*.so", dst="lib", keep_path=False)
        self.copy("*.dylib", dst="lib", keep_path=False)
        self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["leveldb"]
uilianries commented 4 years ago

Hi @osfd !

Could you open a PR to Conan Center Index with your recipe. It will be welcome.

Please, follow the instructions to open a pull request there.

Regards!