-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
142 lines (123 loc) · 6.03 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import shutil
import os
class LibnameConan(ConanFile):
name = "vcl"
version = "20190515"
commit_id = "0f20b65aad7ac5b667c18a0d80489cbaa5508f06"
description = "Visual Computing Library (VCL)"
topics = ("Visual Computing")
url = "https://github.com/bfierz/vcl"
homepage = "https://github.com/bfierz/vcl"
author = "Basil Fierz <basil.fierz@hotmail.com>"
license = "MIT"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {
"vectorization": ["AVX", "AVX 2", "SSE 4.2" ],
"fPIC": [True, False]
}
default_options = {
"vectorization": "AVX",
"fPIC": True
}
# Custom attributes for Bincrafters recipe conventions
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
requires = (
"abseil/20180600@bincrafters/stable",
"eigen/3.3.7@conan/stable",
"fmt/4.1.0@bincrafters/stable",
"glew/2.1.0@bincrafters/stable"
)
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
else:
self.options["abseil"].fPIC = self.options.fPIC
self.options["glew"].fPIC = self.options.fPIC
# Support multi-package configuration
#if self.settings.compiler == "Visual Studio":
# del self.settings.build_type
# del self.settings.compiler["Visual Studio"].runtime
def source(self):
self.run("git clone " + self.url + ".git " + self._source_subfolder)
self.run("git checkout " + self.commit_id, cwd=self._source_subfolder)
self.run("git submodule update --init --recursive", cwd=self._source_subfolder)
shutil.rmtree(self._source_subfolder + "/src/externals/json/test")
#source_url = "https://github.com/bfierz/vcl"
#tools.get("{0}/archive/{1}.tar.gz".format(source_url, self.commit_id))
#extracted_dir = self.name + "-" + self.commit_id
#os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
# Configure which parts to build
cmake.definitions["VCL_BUILD_BENCHMARKS"] = False
cmake.definitions["VCL_BUILD_TESTS"] = False
cmake.definitions["VCL_BUILD_TOOLS"] = False
cmake.definitions["VCL_BUILD_EXAMPLES"] = False
# Support multi-package configuration
if not hasattr(self.settings, "build_type"):
cmake.definitions["CMAKE_DEBUG_POSTFIX"] = "_d"
# Configure features
cmake.definitions["VCL_VECTORIZE"] = str(self.options.vectorization)
cmake.definitions["VCL_OPENGL_SUPPORT"] = True
if self.settings.os != "Windows":
cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.fPIC
# Configure external targets
cmake.definitions["vcl_ext_absl"] = "CONAN_PKG::abseil"
cmake.definitions["vcl_ext_eigen"] = "CONAN_PKG::eigen"
cmake.definitions["vcl_ext_fmt"] = "CONAN_PKG::fmt"
cmake.definitions["vcl_ext_glew"] = "CONAN_PKG::glew"
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.configure(build_folder=self._build_subfolder)
if not hasattr(self.settings, "build_type"):
if cmake.is_multi_configuration:
cmake.build(target="vcl_core", args=["--config","Debug"])
cmake.build(target="vcl_geometry", args=["--config","Debug"])
cmake.build(target="vcl_graphics", args=["--config","Debug"])
cmake.build(target="vcl_math", args=["--config","Debug"])
cmake.build(target="vcl_core", args=["--config","Release"])
cmake.build(target="vcl_geometry", args=["--config","Release"])
cmake.build(target="vcl_graphics", args=["--config","Release"])
cmake.build(target="vcl_math", args=["--config","Release"])
else:
for config in ("Debug", "Release"):
self.output.info("Building %s" % config)
cmake.definitions["CMAKE_BUILD_TYPE"] = config
cmake.configure(build_folder=self._build_subfolder)
shutil.rmtree("CMakeFiles")
os.remove("CMakeCache.txt")
else:
cmake.build(target="vcl_core")
cmake.build(target="vcl_geometry")
cmake.build(target="vcl_graphics")
cmake.build(target="vcl_math")
cmake.install()
def package(self):
bin_folder = os.path.join(self._build_subfolder, "bin")
lib_folder = os.path.join(self._build_subfolder, "lib")
inc_folder = os.path.join(self._source_subfolder, "include")
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy("*.dll", dst="bin", src=bin_folder)
self.copy("*.a", dst="lib", src=lib_folder)
self.copy("*.lib", dst="lib", src=lib_folder)
self.copy("*.h", dst="include", src=inc_folder)
self.copy("*.inl", dst="include", src=inc_folder)
def package_info(self):
self.cpp_info.defines = ['VCL_OPENGL_SUPPORT']
self.cpp_info.includedirs = ['include/vcl_core', 'include/vcl_math', 'include/vcl_graphics', 'include/vcl_geometry']
if self.settings.os == "Windows":
if not hasattr(self.settings, "build_type"):
self.cpp_info.debug.libs = ['vcl_core_d.lib', 'vcl_math_d.lib', 'vcl_geometry_d.lib', 'vcl_graphics_d.lib']
self.cpp_info.release.libs = ['vcl_core.lib', 'vcl_math.lib', 'vcl_geometry.lib', 'vcl_graphics.lib']
else:
self.cpp_info.libs = ['vcl_core.lib', 'vcl_math.lib', 'vcl_geometry.lib', 'vcl_graphics.lib']
else:
self.cpp_info.libs = ['libvcl_core.a', 'libvcl_math.a', 'libvcl_geometry.a', 'libvcl_graphics.a']
self.cpp_info.libdirs = [ "lib" ]