-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconanfile.py
122 lines (107 loc) · 5.26 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
from conans import ConanFile, CMake, tools
import os
class smeltConan(ConanFile):
name = "smelt"
version = "1.2.0"
description = "Stochastic, Modular, and Extensible Library for Time histories"
license = "BSD 2-Clause"
author = "Michael Gardner [email protected]"
url = "https://github.com/NHERI-SimCenter/smelt"
settings = {"os": None, "build_type": None, "compiler": None, "arch": ["x86_64"]}
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "cmake"
build_policy = "missing"
requires = "eigen/3.3.7@conan/stable", \
"jsonformoderncpp/3.7.0@vthiery/stable", \
"clara/1.1.5", \
"catch2/3.5.2", \
"boost/1.71.0", \
"kissfft/131.1.0",
# Custom attributes for Bincrafters recipe conventions
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
# scm = {
# "type": "git", # Use "type": "svn", if local repo is managed using SVN
# "subfolder": _source_subfolder,
# "url": "auto",
# "revision": "auto"
# }
def source(self):
git = tools.Git(folder=self._source_subfolder)
git.clone("https://github.com/shellshocked2003/smelt.git", "stable/1.2.0")
def configure(self):
self.options["boost"].header_only = True
# def build_requirements(self):
# if self.options.shared:
# # self.build_requires("mkl-shared/2019.4@simcenter/stable")
# # self.build_requires("ipp-shared/2019.4@simcenter/stable")
# # self.default_options.update({"mkl-shared:single_lib": True})
# # self.default_options.update({"ipp-shared:signal_and_vector_math": True})
# # self.build_requires("intel-openmp/2019.4@simcenter/stable")
# else:
# # self.build_requires("mkl-static/2019.4@simcenter/stable")
# #self.build_requires("ipp-static/2019.4@simcenter/stable")
# # self.default_options.update({"mkl-static:threaded": False})
def configure_cmake(self):
cmake = CMake(self, msbuild_verbosity='detailed')
# put definitions here so that they are re-used in cmake between
# build() and package()
if self.options.shared == "True":
cmake.definitions["BUILD_SHARED_LIBS"] = "ON"
cmake.definitions["BUILD_STATIC_LIBS"] = "OFF"
else:
cmake.definitions["BUILD_SHARED_LIBS"] = "OFF"
cmake.definitions["BUILD_STATIC_LIBS"] = "ON"
cmake.configure(source_folder=self._source_subfolder)
return cmake
def build(self):
cmake = self.configure_cmake()
cmake.build()
if self.settings.os == "Macos":
if self.options.shared:
with tools.environment_append({"DYLD_LIBRARY_PATH": [os.getcwd() + "/lib"]}):
self.run("DYLD_LIBRARY_PATH=%s ctest --verbose" % os.environ['DYLD_LIBRARY_PATH'])
else:
self.run("ctest --verbose")
elif self.settings.os == "Windows":
if self.settings.build_type == "Release":
self.run("ctest -C Release --verbose")
else:
self.run("ctest -C Debug --verbose")
else:
self.run("ctest --verbose")
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy("*.h", dst="include", src=self._source_subfolder + "/include")
self.copy("*.tcc", dst="include", src=self._source_subfolder + "/include")
if self.settings.build_type == "Release":
if self.options.shared == "True":
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
else:
self.copy("*.a", dst="lib", keep_path=False)
self.copy("*.lib", dst="lib", keep_path=False)
else:
if self.options.shared == "True":
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
else:
self.copy("*.a", dst="lib", keep_path=False)
self.copy("*.lib", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.includedirs = ['include']
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
# Add to path so shared objects can be found
if self.options.shared:
self.env_info.PATH.append(os.path.join(self.package_folder, "lib"))
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.LD_LIBRARY_PATH.append(os.path.join(self.package_folder, "lib"))
self.env_info.DYLD_LIBRARY_PATH.append(os.path.join(self.package_folder, "lib"))
# C++ compilation flags
self.cpp_info.cxxflags = ["-m64"]