diff --git a/packages/cable/package.py b/packages/cable/package.py new file mode 100644 index 0000000..4d34a65 --- /dev/null +++ b/packages/cable/package.py @@ -0,0 +1,55 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# Copyright 2022 ACCESS-NRI +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + +# See https://spack.readthedocs.io/en/latest/packaging_guide.html for a guide +# on how this file works. + + +class Cable(CMakePackage): + """The CSIRO Atmosphere Biosphere Land Exchange (CABLE) model.""" + + homepage = "https://github.com/CABLE-LSM/CABLE.git" + git = "git@github.com:CABLE-LSM/CABLE.git" + + maintainers("SeanBryan51") + + variant( + "mpi", + default=False, + description="Build MPI executable.", + ) + variant( + "build_type", + default="Release", + description="CMake build type", + values=("Debug", "Release"), + ) + + depends_on("netcdf-fortran") + depends_on("mpi", when="+mpi") + + def cmake_args(self): + args = [] + if self.spec.satisfies("+mpi"): + args += [ + self.define_from_variant("CABLE_MPI", "mpi"), + # TODO(Sean): we should let CMake find the MPI compiler instead + # of specifying it explicitly. However, this requires adding + # find_package(MPI) to the CMakeLists.txt file. This was not + # done in https://github.com/CABLE-LSM/CABLE/pull/200 so that + # we can demonstrate binary equivalence in the executables when + # transitioning from a Makefile based to a CMake based build + # system. Once find_package(MPI) is added, this file should be + # updated. + self.define( + "CMAKE_Fortran_COMPILER", + self.spec["mpi"].mpifc, + ), + ] + return args