Skip to content

Commit

Permalink
Add Feelpp package #1
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm committed Sep 14, 2024
1 parent 3e01e08 commit ec6c46e
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions var/spack/repos/builtin/packages/feelpp/package.py
Original file line number Diff line number Diff line change
@@ -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('[email protected]:', type='build') # Require CMake > 3.21
depends_on('[email protected]:')
depends_on('[email protected]')
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('[email protected]:', 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')

0 comments on commit ec6c46e

Please sign in to comment.