|
| 1 | +from conans import ConanFile, CMake, tools |
| 2 | +import os |
| 3 | + |
| 4 | + |
| 5 | +class EstringConan(ConanFile): |
| 6 | + name = "estring" |
| 7 | + version = "1.0" |
| 8 | + license = "MIT" |
| 9 | + url = "<Package recipe repository url here, for issues about the package>" |
| 10 | + settings = "os", "compiler", "build_type", "arch" |
| 11 | + options = {"shared": [True, False]} |
| 12 | + default_options = "shared=False" |
| 13 | + generators = "cmake" |
| 14 | + |
| 15 | + def source(self): |
| 16 | + self.run("git clone https://github.com/memsharded/hello.git") |
| 17 | + self.run("cd hello && git checkout static_shared") |
| 18 | + # This small hack might be useful to guarantee proper /MT /MD linkage in MSVC |
| 19 | + # if the packaged project doesn't have variables to set it properly |
| 20 | + tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(MyHello)", '''PROJECT(MyHello) |
| 21 | +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) |
| 22 | +conan_basic_setup()''') |
| 23 | + |
| 24 | + def build(self): |
| 25 | + cmake = CMake(self.settings) |
| 26 | + shared = "-DBUILD_SHARED_LIBS=ON" if self.options.shared else "" |
| 27 | + self.run('cmake hello %s %s' % (cmake.command_line, shared)) |
| 28 | + self.run("cmake --build . %s" % cmake.build_config) |
| 29 | + |
| 30 | + def package(self): |
| 31 | + self.copy("*.h", dst="include", src="hello") |
| 32 | + self.copy("*hello.lib", dst="lib", keep_path=False) |
| 33 | + self.copy("*.dll", dst="bin", keep_path=False) |
| 34 | + self.copy("*.so", dst="lib", keep_path=False) |
| 35 | + self.copy("*.a", dst="lib", keep_path=False) |
| 36 | + |
| 37 | + def package_info(self): |
| 38 | + self.cpp_info.libs = ["hello"] |
0 commit comments