From 6a30e2be4d1bceb270d73a80721fabff8b6f57c6 Mon Sep 17 00:00:00 2001 From: HalfSweet Date: Mon, 5 Jun 2023 14:45:53 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=B7=BB=E5=8A=A0Conan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + CMakeLists.txt | 2 ++ conanfile.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 conanfile.py diff --git a/.gitignore b/.gitignore index 2124d61..cbaf672 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ target_coverage !*.c !Makefile !Doxyfile +!conanfile.py cmake-build-debug/ .idea/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e19e47b..9e61874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,8 @@ if (NOT WIN32) target_link_options(${DYLIB_TARGET_NAME} PRIVATE ${DYLIB_LINK_FLAGS}) endif() +install(TARGETS mtfmt) + # 测试 # enable_testing() diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..dfd6f85 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,62 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + + +class mtfmtRecipe(ConanFile): + name = "mtfmt" + version = "0.1.0" + + # Optional metadata + license = "GPLv3" + author = "XiangYyang ", "HalfSweet HalfSweet@HalfSweet.cn" + url = "https://github.com/MtFmT-Lib/mtfmt" + description = "" + topics = ("") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": True, "fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "src/*", "inc/*" + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + del self.settings.compiler.cppstd + + if(self.settings.compiler != "msvc"): + del self.settings.compiler.libcxx + + if self.options.shared: + self.options.rm_safe("fPIC") + + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["mtfmt"] + + + + +