diff --git a/.gitignore b/.gitignore index 770dfcd..59bf44b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,10 @@ cmake-build-debug !*.toml !Makefile !Doxyfile -!*_resource.rc +!conanfile.py +cmake-build-debug/ +.idea/ +!*_resource.rc */internal/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d4ffcd..08c7c01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,8 @@ install(EXPORT mtfmt-targets NAMESPACE mtfmt:: DESTINATION mtfmt/lib/cmake/mtfmt) +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"] + + + + +