-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
44 lines (38 loc) · 1.89 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from conans import ConanFile, CMake, tools
from conans.tools import cpu_count
import os, sys, platform
import shutil
class TextcsvConan(ConanFile):
name = "qtcsv"
version = "1.3.1"
sourceDir = "qtcsv"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "buildTests" : [False, True]}
default_options = "shared=False", "buildTests=False"
url = "https://github.com/iamantony/qtcsv"
description = "Small easy-to-use library for reading and writing csv-files in Qt."
license = "The MIT License (MIT)"
def source(self):
self.run("git clone " + self.url + " " + self.sourceDir)
#TODO: checkout tagged version, if cmake handling is on master
# self.run("cd %s && git checkout %s" % (self.sourceDir, self.version))
self.run("cd %s && git checkout dev" % (self.sourceDir))
def build(self):
os.chdir(self.sourceDir)
self.run("mkdir -p build")
os.chdir("build")
cmake = CMake(self.settings)
shared = "-DSTATIC_LIB=OFF" if self.options.shared else "-DSTATIC_LIB=ON"
tests = "-DBUILD_TESTS=ON" if self.options.buildTests else "-DBUILD_TESTS=ON"
installPrefix = "-DCMAKE_INSTALL_PREFIX=" + str(self.package_folder) #install into the package folder
cmakeOptions = shared + " " + tests + " " + installPrefix
self.run('cmake .. %s %s' % (cmake.command_line, cmakeOptions))
self.run("cmake --build . %s -- -j%s" % (cmake.build_config, str(cpu_count())))
def package(self):
os.chdir(os.sep.join([self.sourceDir, "build"]))
self.run("cmake --build . --target install ")
if self.options.buildTests: # deploy tests, if they are build --> useful for package test
self.copy(pattern="qtcsv_tests", dst="bin/tests", src=self.sourceDir, keep_path=True)
self.copy(pattern="*", dst="bin/tests/data", src=self.sourceDir+"/build/tests/data", keep_path=True)
def package_info(self):
self.cpp_info.libs = ["qtcsv"]