diff options
author | Thomas Madlener <thomas.madlener@desy.de> | 2022-03-21 16:50:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 15:50:42 +0000 |
commit | 06a9496a39ee915be9aa59f046f6b3ac5a793c68 (patch) | |
tree | 82b1026a053e33d32931177cc0681c2d3902f1d7 | |
parent | 8fcfde62df398f7675f20cba0dbcf6f6081e4b6b (diff) | |
download | spack-06a9496a39ee915be9aa59f046f6b3ac5a793c68.tar.gz spack-06a9496a39ee915be9aa59f046f6b3ac5a793c68.tar.bz2 spack-06a9496a39ee915be9aa59f046f6b3ac5a793c68.tar.xz spack-06a9496a39ee915be9aa59f046f6b3ac5a793c68.zip |
geant4: Add external find support (#29642)
* geant4: Add external find support (partial)
* Fix style
* Fix style another time
-rw-r--r-- | var/spack/repos/builtin/packages/geant4/package.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/geant4/package.py b/var/spack/repos/builtin/packages/geant4/package.py index c3d0164218..b822ae0c52 100644 --- a/var/spack/repos/builtin/packages/geant4/package.py +++ b/var/spack/repos/builtin/packages/geant4/package.py @@ -18,6 +18,8 @@ class Geant4(CMakePackage): tags = ['hep'] + executables = ['^geant4-config$'] + maintainers = ['drbenmorgan'] version('11.0.1', sha256='fa76d0774346b7347b1fb1424e1c1e0502264a83e185995f3c462372994f84fa') @@ -131,6 +133,53 @@ class Geant4(CMakePackage): patch('geant4-10.4.3-cxx17-removed-features.patch', level=1, when='@10.4.3 cxxstd=17') + @classmethod + def determine_version(cls, exe): + output = Executable(exe)('--version', output=str, error=str) + # We already get the correct format + return output.strip() + + @classmethod + def determine_variants(cls, exes, version_str): + variants = [] + cxxstd = Executable(exes[0])('--cxxstd', output=str, error=str) + # output will be something like c++17, we only want the number + variants.append('cxxstd={}'.format(cxxstd[-3:])) + + def _has_feature(feature): + res = Executable(exes[0])('--has-feature', feature, output=str, error=str) + return res.strip() == 'yes' + + def _add_variant(feature, variant): + """Helper to determine whether a given feature is present and append the + corresponding variant to the list""" + if _has_feature(feature): + variants.append('+{}'.format(variant)) + else: + variants.append('~{}'.format(variant)) + + _add_variant('qt', 'qt') + _add_variant('motif', 'motif') + _add_variant('multithreading', 'threads') + _add_variant('usolids', 'vecgeom') + + if _has_feature('opengl-x11'): + variants.append('+opengl') + variants.append('+x11') + else: + variants.append('~opengl') + # raytracer-x11 could still lead to the activation of the x11 + # variant without +opengl + _add_variant('raytracer-x11', 'x11') + + # TODO: The following variants cannot be determined from geant4-config. + # - python + # - tbb + # - vtk + # Should we have a (version dependent) warning message for these? + + return ' '.join(variants) + def cmake_args(self): spec = self.spec |