v0.15.0
Loading...
Searching...
No Matches
package.py
Go to the documentation of this file.
1# Copyright (c) 2022 [Authors](http://mofem.eng.gla.ac.uk/mofem/html/authors.html)
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in all
11# copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20#
21# [MIT License](https://opensource.org/licenses/MIT)#
22
23from spack import *
24
26 """mofem basic finite elements extension"""
27
28 homepage = "http://mofem.eng.gla.ac.uk"
29 git = "https://bitbucket.org/mofem/basic_finite_elements.git"
30
31 maintainers = ['likask','CallumRuncie']
32
33 # Development versions
34 version('main', branch='main')
35 version('develop', branch='develop')
36 version('lukasz', branch='lukasz/develop')
37 # Versions
38 version('0.15.0', branch='Version0.15.0')
39
40 variant('copy_user_modules', default=True,
41 description='Copy user modules directory instead linking')
42
43 extends('mofem-cephas')
44
45 depends_on('mofem-cephas@main', when='@main')
46 depends_on('mofem-cephas@develop', when='@develop')
47 depends_on('mofem-cephas@lukasz', when='@lukasz')
48
50 env.set('CTEST_OUTPUT_ON_FAILURE', '1')
51
52 # The CMakeLists.txt installed with mofem-cephas package set cmake
53 # environment to install extension from extension repository. It searches
54 # for modules in user provides paths, for example in Spack source path.Also
55 # it finds all cmake exported targets installed in lib directory, which are
56 # built with dependent extensions, f.e.mofem - users - modules or others if
57 # needed.
58 @property
60 """The relative path to the directory containing CMakeLists.txt
61
62 This path is relative to the root of the extracted tarball,
63 not to the ``build_directory``. Defaults to the current directory.
64
65 :return: directory containing CMakeLists.txt
66 """
67 spec = self.spec
68 return spec['mofem-cephas'].prefix.include.cmake.users_modules
69
70 @property
71 def build_directory(self):
72 spec = self.spec
73 build_type = spec.variants['build_type'].value
74 build_dir = 'users_modules/eshelbian_plasticity'
75 return join_path(self.stage.path, build_dir)
76
77 def cmake_args(self):
78 spec = self.spec
79 from_variant = self.define_from_variant
80
81 options = []
82
83 # obligatory options
84 options.extend([
85 '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
86 '-DMPI_RUN_FLAGS=--allow-run-as-root',
87 '-DWITH_SPACK=YES'])
88 options.append(self.define(
89 'MOFEM_DIR', spec['mofem-cephas'].prefix))
90 options.append(self.define(
91 'EXTERNAL_MODULE_SOURCE_DIRS', self.stage.source_path))
92
93 # build tests
94 options.append(self.define('MOFEM_UM_BUILD_TESTS', self.run_tests))
95
96 return options
97
98 # This function is not needed to run code installed by extension, nor in
99 # the install process. However, for users like to have access to source
100 # code to play, change and make it. Having source code at hand one can
101 # compile in own build directory it in package view when the extension is
102 # activated.
103 @run_after('install')
105 source = self.stage.source_path
106 prefix = self.prefix
107 install_tree(source, prefix.ext_users_modules.mixed_fracture_module)
108
109 def check(self):
110 """Searches the CMake-generated Makefile for the target ``test``
111 and runs it if found.
112 """
113 with working_dir(self.build_directorybuild_directory):
114 ctest('-L', 'short', '--output-on-failure', parallel=False)