Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

Commit 6a30e2b

Browse files
committed
add: 添加Conan
1 parent 5445912 commit 6a30e2b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ target_coverage
3232
!*.c
3333
!Makefile
3434
!Doxyfile
35+
!conanfile.py
3536

3637
cmake-build-debug/
3738
.idea/

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ if (NOT WIN32)
135135
target_link_options(${DYLIB_TARGET_NAME} PRIVATE ${DYLIB_LINK_FLAGS})
136136
endif()
137137

138+
install(TARGETS mtfmt)
139+
138140
# 测试
139141
# enable_testing()
140142

conanfile.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from conan import ConanFile
2+
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
3+
4+
5+
class mtfmtRecipe(ConanFile):
6+
name = "mtfmt"
7+
version = "0.1.0"
8+
9+
# Optional metadata
10+
license = "GPLv3"
11+
author = "XiangYyang ", "HalfSweet [email protected]"
12+
url = "https://github.com/MtFmT-Lib/mtfmt"
13+
description = ""
14+
topics = ("")
15+
16+
# Binary configuration
17+
settings = "os", "compiler", "build_type", "arch"
18+
options = {"shared": [True, False], "fPIC": [True, False]}
19+
default_options = {"shared": True, "fPIC": True}
20+
21+
# Sources are located in the same place as this recipe, copy them to the recipe
22+
exports_sources = "CMakeLists.txt", "src/*", "inc/*"
23+
24+
def config_options(self):
25+
if self.settings.os == "Windows":
26+
self.options.rm_safe("fPIC")
27+
28+
def configure(self):
29+
del self.settings.compiler.cppstd
30+
31+
if(self.settings.compiler != "msvc"):
32+
del self.settings.compiler.libcxx
33+
34+
if self.options.shared:
35+
self.options.rm_safe("fPIC")
36+
37+
38+
def layout(self):
39+
cmake_layout(self)
40+
41+
def generate(self):
42+
deps = CMakeDeps(self)
43+
deps.generate()
44+
tc = CMakeToolchain(self)
45+
tc.generate()
46+
47+
def build(self):
48+
cmake = CMake(self)
49+
cmake.configure()
50+
cmake.build()
51+
52+
def package(self):
53+
cmake = CMake(self)
54+
cmake.install()
55+
56+
def package_info(self):
57+
self.cpp_info.libs = ["mtfmt"]
58+
59+
60+
61+
62+

0 commit comments

Comments
 (0)