forked from Chrismarsh/CHM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
117 lines (90 loc) · 3.46 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
from conans import ConanFile, CMake, tools
import os
class CHMConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
name = "CHM"
version = "1.1"
license = "https://github.com/Chrismarsh/CHM/blob/master/LICENSE"
author = "Chris Marsh"
url = "https://github.com/Chrismarsh/CHM"
description = "Canadian hydrological model"
generators = "cmake_find_package"
options = {
"verbose_cmake":[True,False],
"build_tests":[True,False],
"with_mpi": [True, False],
"with_omp": [True,False]
}
default_options = {
"verbose_cmake":False,
"build_tests":True,
#default without openmp or mpi
"with_omp": False,
"with_mpi": False,
#dependency options
"gdal:libcurl": True,
"gdal:netcdf": True
# "gperftools:heapprof":True
}
def source(self):
branch = None #master default
try:
branch = os.environ["CI_SHA"]
except KeyError as e:
try:
if os.environ["CI"]:
self.output.error('When running under CI, $CI_SHA should be available.')
except KeyError as e:
pass
git = tools.Git()
git.clone("https://github.com/Chrismarsh/CHM.git")
if branch is not None:
git.run(f'checkout {branch}')
git.run("submodule update --init --recursive")
def requirements(self):
self.requires( "cgal/[>=5.2]@CHM/stable" )
self.requires( "boost/[>=1.75]@CHM/stable" )
self.requires( "vtk/8.2.0@CHM/stable" )
self.requires( "netcdf-cxx/[>=4.3]@CHM/stable" )
self.requires( "proj/[>=7.2.1]@CHM/stable" )
self.requires( "gdal/[>=3.2.1]@CHM/stable" )
self.requires( "sparsehash/[>=2.0.3]@CHM/stable" )
self.requires( "gperftools/[>=2.7]@CHM/stable" )
self.requires( "gsl/[>=2.6]@CHM/stable" )
self.requires( "armadillo/[>=10.2.0]@CHM/stable" )
self.requires( "tbb/[>=2020.3]@CHM/stable" )
self.requires( "eigen3/[>=3.3.9]@CHM/stable" )
self.requires( "meteoio/2.8.0@CHM/stable")
self.requires( "func/0.1@CHM/stable")
self.requires( "trilinos/12.18.1@CHM/stable")
def _configure_cmake(self):
cmake = CMake(self)
if self.options['with_mpi']:
#default to no MPI
self.options["boost:without_mpi"] = False
self.options["trilinos:with_mpi"] = True
if self.options["with_omp"]:
# trilinos does not support omp on macos
if not tools.os_info.is_macos:
self.options["trilinos:with_openmp"] = True
if self.options.build_tests:
cmake.definitions["BUILD_TESTS"] = True
if self.options.verbose_cmake:
cmake.verbose = True
cmake.definitions["CMAKE_FIND_DEBUG_MODE"]=1
if self.options["with_omp"]:
cmake.definitions["USE_OMP"] = True
if self.options["with_mpi"]:
cmake.definitions["USE_MPI"] = True
cmake.configure(source_folder=self.source_folder)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
cmake.test(target="check")
def package(self):
cmake = self._configure_cmake()
cmake.install()
def imports(self):
self.copy("*.so*", dst="lib", src="lib") # From bin to bin
self.copy("*.dylib*", dst="lib", src="lib") # From lib to bin