Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake build system #111

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ RUN apt-get install -y --no-install-recommends \
coreutils \
curl \
environment-modules \
file \
file \
gfortran \
git \
openssh-server \
pkg-config \
python \
unzip \
vim \
Expand Down Expand Up @@ -106,6 +107,27 @@ RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
# deactivate the environment.
spack env deactivate

# CMake build system
RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
# create a new environment for the CMake version and activate it:
spack env create octopus-cmake && \
spack env activate octopus-cmake && \
# display specs of upcoming spack installation:
spack spec octopus@develop +mpi build_system=cmake && \
# run the spack installation (adding it to the environment):
spack add octopus@develop +mpi build_system=cmake && \
spack install && \
# run spack smoke tests for octopus. We get an error if any of the fails:
spack test run --alias test_cmake octopus && \
# display output from smoke tests (just for information):
spack test results -l test_cmake && \
# show which octopus version we use (for convenience):
spack load octopus && octopus --version && \
# deactivate the environment.
spack env deactivate



# Provide bash in case the image is meant to be used interactively
CMD /bin/bash -l

34 changes: 27 additions & 7 deletions spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from spack.package import *


class Octopus(AutotoolsPackage, CudaPackage):
class Octopus(AutotoolsPackage, CudaPackage, CMakePackage):
"""A real-space finite-difference (time-dependent) density-functional
theory code."""

Expand Down Expand Up @@ -43,7 +43,11 @@ class Octopus(AutotoolsPackage, CudaPackage):
version("5.0.1", sha256="3423049729e03f25512b1b315d9d62691cd0a6bd2722c7373a61d51bfbee14e0")

version("develop", branch="main")

build_system(
conditional("cmake", when="@14:"),
conditional("autotools", when="@:14"),
default="autotools",
)
variant("mpi", default=True, description="Build with MPI support")
variant("scalapack", default=False, when="+mpi", description="Compile with Scalapack")
variant("berkeleygw", default=False, description="Compile with BerkeleyGW")
Expand Down Expand Up @@ -81,11 +85,16 @@ class Octopus(AutotoolsPackage, CudaPackage):
)
variant("debug", default=False, description="Compile with debug flags")

depends_on("autoconf", type="build", when="@develop")
depends_on("automake", type="build", when="@develop")
depends_on("libtool", type="build", when="@develop")
depends_on("m4", type="build", when="@develop")
depends_on("mpi", when="+mpi")
with when("build_system=autotools"):
depends_on("autoconf", type="build", when="@develop")
depends_on("automake", type="build", when="@develop")
depends_on("libtool", type="build", when="@develop")
depends_on("m4", type="build", when="@develop")
depends_on("mpi", when="+mpi")
with when("build_system=cmake"):
depends_on("[email protected]:", type="build")
depends_on("ninja", type="build")
generator("ninja")

depends_on("blas")
depends_on("[email protected]:")
Expand Down Expand Up @@ -129,6 +138,7 @@ class Octopus(AutotoolsPackage, CudaPackage):
depends_on("py-numpy", when="+python")
depends_on("py-mpi4py", when="+python")
depends_on("metis@5:+int64", when="+metis")
depends_on("metis@5:+int64", when="build_system=cmake")
depends_on("parmetis+int64", when="+parmetis")
depends_on("scalapack", when="+scalapack")
depends_on("sparskit", when="+sparskit")
Expand Down Expand Up @@ -314,6 +324,16 @@ def configure_args(self):

return args

def cmake_args(self):
# CMake was introduced in octopus 14 onwards

args = [
self.define("OCTOPUS_OpenMP", True),
self.define_from_variant("OCTOPUS_MPI", "mpi"),
]

return args

@run_after("install")
@on_package_attributes(run_tests=True)
def smoke_tests_after_install(self):
Expand Down
Loading