Skip to content

Commit

Permalink
add: 添加Conan
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfSweet committed Jun 5, 2023
1 parent 5445912 commit 6a30e2b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_coverage
!*.c
!Makefile
!Doxyfile
!conanfile.py

cmake-build-debug/
.idea/
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ if (NOT WIN32)
target_link_options(${DYLIB_TARGET_NAME} PRIVATE ${DYLIB_LINK_FLAGS})
endif()

install(TARGETS mtfmt)

# 测试
# enable_testing()

Expand Down
62 changes: 62 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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 [email protected]"
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"]





0 comments on commit 6a30e2b

Please sign in to comment.