From ec6c46e1677f2d505588ac3141234751621d4ca1 Mon Sep 17 00:00:00 2001 From: Christophe Prud'homme Date: Sat, 14 Sep 2024 09:39:15 +0200 Subject: [PATCH] Add Feelpp package feelpp/spack#1 --- .../repos/builtin/packages/feelpp/package.py | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 var/spack/repos/builtin/packages/feelpp/package.py diff --git a/var/spack/repos/builtin/packages/feelpp/package.py b/var/spack/repos/builtin/packages/feelpp/package.py new file mode 100644 index 00000000000000..d7349c0eae580f --- /dev/null +++ b/var/spack/repos/builtin/packages/feelpp/package.py @@ -0,0 +1,103 @@ +from spack.package import * + +class Feelpp(CMakePackage): + """Feel++ is a C++ library for partial differential equations (PDEs) solving.""" + + homepage = "https://www.feelpp.org" + url = "https://github.com/feelpp/feelpp/archive/v1.0.0.tar.gz" + git = "https://github.com/feelpp/feelpp.git" + + license("LGPL-3.0-or-later AND GPL-3.0-or-later") + maintainers( "prudhomm", "vincentchabannes" ) + + version('develop', branch='develop') + version('preset', branch='2284-add-spack-environment-to-the-main-ci') + + # Define variants + variant('toolboxes', default=False, description="Enable the Feel++ toolboxes") + variant('mor', default=False, description="Enable Model Order Reduction (MOR)") + variant('python', default=False, description="Enable Python wrappers") + + # Add variants for C++ standards + variant('cpp17', default=False, description="Use C++17 standard") + variant('cpp20', default=True, description="Use C++20 standard") + variant('cpp23', default=False, description="Use C++23 standard") + + # Define conflicts between the C++ standard variants + conflicts('+cpp17', when='+cpp20', msg="Cannot enable both C++17 and C++20") + conflicts('+cpp17', when='+cpp23', msg="Cannot enable both C++17 and C++23") + conflicts('+cpp20', when='+cpp23', msg="Cannot enable both C++20 and C++23") + + + # Specify dependencies with the required versions + depends_on('cmake@3.21:', type='build') # Require CMake > 3.21 + depends_on('boost@1.74:') + depends_on('petsc@3.20') + depends_on('slepc') + depends_on('mpi') + depends_on('hdf5') + depends_on('fftw') + depends_on('libzip') + depends_on('llvm@18:') # Require LLVM (Clang) version 18 or higher + depends_on('bison') + depends_on('flex') + + # Python dependencies if +python variant is enabled + depends_on('py-pybind11', when='+python') + depends_on('python@3.7:', when='+python', type=('build', 'run')) + + def get_cpp_version(self): + """Helper function to determine the C++ standard preset.""" + if '+cpp17' in self.spec: + return 'cpp17' + elif '+cpp20' in self.spec: + return 'cpp20' + elif '+cpp23' in self.spec: + return 'cpp17' + else: + return 'cpp17' # default + + def get_preset_name(self): + cpp_version = self.get_cpp_version() + preset_name = f'feelpp-clang-{cpp_version}-default-release' + return preset_name + + def cmake_args(self): + """Define the CMake preset and CMake options based on variants""" + + args = [f'--preset={self.get_preset_name()}'] + + # Add options based on the variants + if '+toolboxes' in self.spec: + args.append('-DFEELPP_ENABLE_TOOLBOXES=ON') + else: + args.append('-DFEELPP_ENABLE_TOOLBOXES=OFF') + + if '+mor' in self.spec: + args.append('-DFEELPP_ENABLE_MOR=ON') + else: + args.append('-DFEELPP_ENABLE_MOR=OFF') + + if '+python' in self.spec: + args.append('-DFEELPP_ENABLE_FEELPP_PYTHON=ON') + else: + args.append('-DFEELPP_ENABLE_FEELPP_PYTHON=OFF') + + return args + + def build(self, spec, prefix): + """Override the default build command to use CMake presets.""" + cmake = which('cmake') + + cmake('--build', '--preset', self.get_preset_name()) + + + def install(self, spec, prefix): + """Override the default install command to use CMake presets.""" + cmake = which('cmake') + cmake('--build', '--preset', self.get_preset_name(), '-t', 'install') + + def test(self, spec, prefix): + """Override the default test command to use CMake presets.""" + ctest = which('ctest') + ctest('--preset', self.get_preset_name(), '-R', 'qs_laplacian')