From d02a0a854dccab00b83ba4d3291534e149949cf8 Mon Sep 17 00:00:00 2001 From: iamashwin99 Date: Fri, 10 May 2024 22:37:13 +0200 Subject: [PATCH 1/4] Add simple spack package with cmake support --- spack/package.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/spack/package.py b/spack/package.py index 4abe82b..bfc2f90 100644 --- a/spack/package.py +++ b/spack/package.py @@ -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.""" @@ -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") @@ -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("cmake@3.26:", type="build") + depends_on("ninja", type="build") + generator("ninja") depends_on("blas") depends_on("gsl@1.9:") @@ -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") @@ -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): @@ -411,3 +431,4 @@ def smoke_tests(self): purpose=purpose, skip_missing=False, ) + From 482cd3ab8c890dbea46c5e4bd35bd9070e5e3c96 Mon Sep 17 00:00:00 2001 From: iamashwin99 Date: Fri, 10 May 2024 22:44:22 +0200 Subject: [PATCH 2/4] Add ci for cmake build system --- Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Dockerfile b/Dockerfile index 88aa08f..bdd4100 100644 --- a/Dockerfile +++ b/Dockerfile @@ -106,6 +106,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 From b41b05f3f6e8d5db004d391897d3631e0204a45a Mon Sep 17 00:00:00 2001 From: iamashwin99 Date: Fri, 10 May 2024 22:55:07 +0200 Subject: [PATCH 3/4] fix style --- spack/package.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spack/package.py b/spack/package.py index bfc2f90..1be9055 100644 --- a/spack/package.py +++ b/spack/package.py @@ -324,14 +324,14 @@ def configure_args(self): return args - def cmake_args(self): + 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") @@ -431,4 +431,3 @@ def smoke_tests(self): purpose=purpose, skip_missing=False, ) - From c5398d1a90b8b8f91930cdbd319da096a8fd8d72 Mon Sep 17 00:00:00 2001 From: iamashwin99 Date: Sat, 11 May 2024 07:47:26 +0200 Subject: [PATCH 4/4] add pkgconfig to the list of system packages --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bdd4100..498045e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \