From 562ee6abc4423cd89fea31ee05c065fa1676a4f3 Mon Sep 17 00:00:00 2001 From: Aleksey Timin Date: Wed, 9 Mar 2022 23:12:25 +0100 Subject: [PATCH] [#2] Add conan recipe (#12) * add conanfile.py * update CHANGELOG --- CHANGELOG.md | 1 + cmake/InstallDependencies.cmake | 2 +- conanfile.py | 45 +++++++++++++++++++++++++++++++++ conanfile.txt | 8 ------ 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e7392..c718e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ **Features**: * Support Reduct Storage API v0.2.0, [PR-9](https://github.com/reduct-storage/reduct-cpp/pull/9) +* Add conan recipe, [PR-12](https://github.com/reduct-storage/reduct-cpp/pull/12) **Documentation**: diff --git a/cmake/InstallDependencies.cmake b/cmake/InstallDependencies.cmake index b5742a0..c37508e 100644 --- a/cmake/InstallDependencies.cmake +++ b/cmake/InstallDependencies.cmake @@ -11,7 +11,7 @@ include(${CMAKE_BINARY_DIR}/conan.cmake) find_program(CONAN_CMD conan) if (CONAN_CMD) conan_cmake_autodetect(settings) - conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR}/conanfile.txt + conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR}/conanfile.py BUILD missing SETTINGS ${settings}) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..8e1346c --- /dev/null +++ b/conanfile.py @@ -0,0 +1,45 @@ +import re + +from conans import ConanFile, CMake + + +class DriftFrameworkConan(ConanFile): + name = "reduct-cpp" + version = "0.1.0" + license = "MIT" + author = "Alexey Timin" + url = "https://github.com/reduct-storage/reduct-cpp" + description = "Reduct Storage Client SDK for C++" + topics = ("reduct-storage", "http-client", "http-api") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + generators = "cmake" + + requires = ("fmt/8.1.1", + "cpp-httplib/0.10.1", + "nlohmann_json/3.10.5", + "catch2/2.13.8") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + self.run(f'git clone --branch v{self.version} https://github.com/reduct-storage/reduct-cpp.git') + + def build(self): + cmake = CMake(self) + cmake.configure(source_dir='reduct-cpp') + cmake.build() + + def package(self): + self.copy("*.h", dst="include/reduct", src=f"{self.source_folder}/reduct-cpp/src/reduct") + self.copy("*reductcpp.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 = ["reductcpp"] diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index a819d0c..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,8 +0,0 @@ -[requires] -fmt/8.1.1 -cpp-httplib/0.10.1 -nlohmann_json/3.10.5 -catch2/2.13.8 - -[generators] -cmake \ No newline at end of file