set_targetdir for ajs in xmake
[liba.git] / conanfile.py
blobb4bdddbd4aaff7d5218d80e60b1e6120b20650ea
1 from conan import ConanFile
2 from conan.tools.cmake import CMakeToolchain, CMake
5 class Conan(ConanFile):
6 name = "liba"
7 version = "0.1.12"
8 license = "MPL-2.0"
9 topics = ["algorithm"]
10 author = "tqfx tqfx@tqfx.org"
11 homepage = url = "https://github.com/tqfx/liba"
12 description = "An algorithm library based on C/C++"
13 settings = "os", "compiler", "build_type", "arch"
14 options = {
15 "pkgconfig": [0, 1],
16 "symlink": [0, 1],
17 "shared": [0, 1],
18 "float": [4, 8],
19 "ipo": [0, 1],
21 default_options = {
22 "pkgconfig": 1,
23 "symlink": 0,
24 "shared": 0,
25 "float": 8,
26 "ipo": 0,
28 exports_sources = [
29 "include/a.cmake.h.in",
30 "include/a/*.h*",
31 "CMakeLists.txt",
32 "cmake/*.cmake",
33 "src/*.[ch]*",
34 "LICENSE.txt",
35 "README.md",
38 def generate(self):
39 cmake = CMakeToolchain(self)
40 cmake.variables["BUILD_TESTING"] = 0
41 if self.options.shared:
42 cmake.variables["LIBA_INSTALL"] = "shared"
43 else:
44 cmake.variables["LIBA_INSTALL"] = "static"
45 if self.options.float != 8:
46 cmake.variables["LIBA_FLOAT"] = self.options.float
47 cmake.variables["LIBA_SYMLINK"] = self.options.symlink
48 cmake.variables["LIBA_PKGCONFIG"] = self.options.pkgconfig
49 if self.settings.build_type != "Debug":
50 cmake.variables["LIBA_IPO"] = self.options.ipo
51 else:
52 cmake.variables["LIBA_IPO"] = 0
53 cmake.generate()
55 def build(self):
56 cmake = CMake(self)
57 cmake.configure()
58 cmake.build()
60 def package(self):
61 cmake = CMake(self)
62 cmake.install()
64 def package_info(self):
65 self.cpp_info.libs = ["a"]
66 if self.settings.os != "Windows":
67 self.cpp_info.system_libs = ["m"]
68 if self.options.shared:
69 if self.settings.os == "Windows":
70 self.cpp_info.libs = ["liba"]
71 self.cpp_info.defines = ["A_IMPORTS"]
72 self.cpp_info.set_property("cmake_target_name", "liba")
73 else:
74 self.cpp_info.set_property("cmake_target_name", "alib")
75 if self.options.pkgconfig:
76 self.cpp_info.set_property("pkg_config_name", "liba")