SEACAS: further refactor (#33673)

* SEACAS: Update package.py to handle new SEACAS project name

The base project name for the SEACAS project has changed from
"SEACASProj" to "SEACAS" as of @2022-10-14, so the package
needed to be updated to use the new project name when needed.

The refactor also changes several:
    "-DSome_CMAKE_Option:BOOL=ON"
to
   define("Some_CMAKE_Option", True)

* SEACAS: Additional refactorings

* Replaced all cmake "-Dsomething=other" lines with either `define`
or `define_from_variant` functions.

Consolidated the application (fortran, legacy, all) enabling lines
into loops over the code names.  Easier to see categorization of
applications and also to add/move/remove an application

Reordered some lines; general cleanup and restructuring.

* Address flake8 issues

* Remove trailing whitespace

* Reformat using black
This commit is contained in:
Greg Sjaardema 2022-11-03 09:42:25 -06:00 committed by GitHub
parent 9925f3b779
commit 16acd25053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,24 +129,31 @@ class Seacas(CMakePackage):
variant("x11", default=True, description="Compile with X11") variant("x11", default=True, description="Compile with X11")
# ###################### Dependencies ########################## # ###################### Dependencies ##########################
depends_on("cmake@3.17:", type="build")
depends_on("mpi", when="+mpi")
# Always depends on netcdf-c
depends_on("netcdf-c@4.8.0:+mpi+parallel-netcdf", when="+mpi") depends_on("netcdf-c@4.8.0:+mpi+parallel-netcdf", when="+mpi")
depends_on("netcdf-c@4.8.0:~mpi", when="~mpi") depends_on("netcdf-c@4.8.0:~mpi", when="~mpi")
depends_on("hdf5+hl~mpi", when="~mpi") depends_on("hdf5+hl~mpi", when="~mpi")
depends_on("cgns@4.2.0:+mpi+scoping", when="+cgns +mpi")
depends_on("cgns@4.2.0:~mpi+scoping", when="+cgns ~mpi")
depends_on("fmt@8.1.0:", when="@2022-03-04:2022-05-16") depends_on("fmt@8.1.0:", when="@2022-03-04:2022-05-16")
depends_on("fmt@9.1.0:", when="@2022-10-14") depends_on("fmt@9.1.0:", when="@2022-10-14")
depends_on("matio", when="+matio")
depends_on("libx11", when="+x11")
with when("+cgns"):
depends_on("cgns@4.2.0:+mpi+scoping", when="+mpi")
depends_on("cgns@4.2.0:~mpi+scoping", when="~mpi")
with when("+adios2"): with when("+adios2"):
depends_on("adios2@master") depends_on("adios2@master")
depends_on("adios2~mpi", when="~mpi") depends_on("adios2~mpi", when="~mpi")
depends_on("adios2+mpi", when="+mpi") depends_on("adios2+mpi", when="+mpi")
depends_on("matio", when="+matio")
with when("+metis"): with when("+metis"):
depends_on("metis+int64+real64") depends_on("metis+int64+real64")
depends_on("parmetis+int64", when="+mpi") depends_on("parmetis+int64", when="+mpi")
depends_on("libx11", when="+x11")
# The Faodel TPL is only supported in seacas@2021-04-05: # The Faodel TPL is only supported in seacas@2021-04-05:
depends_on("faodel@1.2108.1:+mpi", when="+faodel +mpi") depends_on("faodel@1.2108.1:+mpi", when="+faodel +mpi")
@ -157,11 +164,6 @@ class Seacas(CMakePackage):
msg="The Faodel TPL is only compatible with @2021-04-05 and later.", msg="The Faodel TPL is only compatible with @2021-04-05 and later.",
) )
# MPI related dependencies
depends_on("mpi", when="+mpi")
depends_on("cmake@3.1:", type="build")
def setup_run_environment(self, env): def setup_run_environment(self, env):
env.prepend_path("PYTHONPATH", self.prefix.lib) env.prepend_path("PYTHONPATH", self.prefix.lib)
@ -181,41 +183,30 @@ def cmake_args(self):
options.extend( options.extend(
[ [
define(project_name_base + "_ENABLE_TESTS", True),
define(project_name_base + "_ENABLE_CXX11", True),
define(project_name_base + "_ENABLE_Kokkos", False),
define(project_name_base + "_HIDE_DEPRECATED_CODE", False),
from_variant("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "shared"), from_variant("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "shared"),
from_variant("BUILD_SHARED_LIBS", "shared"), from_variant("BUILD_SHARED_LIBS", "shared"),
from_variant("SEACASExodus_ENABLE_THREADSAFE", "thread_safe"), from_variant("SEACASExodus_ENABLE_THREADSAFE", "thread_safe"),
from_variant("SEACASIoss_ENABLE_THREADSAFE", "thread_safe"), from_variant("SEACASIoss_ENABLE_THREADSAFE", "thread_safe"),
from_variant("TPL_ENABLE_X11", "x11"), from_variant("TPL_ENABLE_X11", "x11"),
]
)
if "+mpi" in spec:
options.extend(
[
"-DCMAKE_C_COMPILER=%s" % spec["mpi"].mpicc,
"-DCMAKE_CXX_COMPILER=%s" % spec["mpi"].mpicxx,
"-DCMAKE_Fortran_COMPILER=%s" % spec["mpi"].mpifc,
define("TPL_ENABLE_MPI", True),
"-DMPI_BASE_DIR:PATH=%s" % spec["mpi"].prefix,
]
)
else:
options.extend(
[
define("TPL_ENABLE_MPI", False),
]
)
options.extend(
[
define(project_name_base + "_ENABLE_TESTS", True),
define(project_name_base + "_ENABLE_CXX11", True),
define(project_name_base + "_ENABLE_Kokkos", False),
define(project_name_base + "_HIDE_DEPRECATED_CODE", False),
from_variant(project_name_base + "_ENABLE_Fortran", "fortran"), from_variant(project_name_base + "_ENABLE_Fortran", "fortran"),
] ]
) )
options.append(from_variant("TPL_ENABLE_MPI", "mpi"))
if "+mpi" in spec:
options.extend(
[
define("CMAKE_C_COMPILER", spec["mpi"].mpicc),
define("CMAKE_CXX_COMPILER", spec["mpi"].mpicxx),
define("CMAKE_Fortran_COMPILER", spec["mpi"].mpifc),
define("MPI_BASE_DIR", spec["mpi"].prefix),
]
)
# ########## What applications should be built ############# # ########## What applications should be built #############
# Check whether they want everything; if so, do the easy way... # Check whether they want everything; if so, do the easy way...
if "+applications" in spec and "+legacy" in spec: if "+applications" in spec and "+legacy" in spec:
@ -242,56 +233,62 @@ def cmake_args(self):
) )
if "+applications" in spec: if "+applications" in spec:
options.extend( # C / C++ applications
[ for app in (
define(project_name_base + "_ENABLE_SEACASAprepro", True), "Aprepro",
define(project_name_base + "_ENABLE_SEACASAprepro_lib", True), "Aprepro_lib",
define(project_name_base + "_ENABLE_SEACASConjoin", True), "Conjoin",
define(project_name_base + "_ENABLE_SEACASCpup", True), "Cpup",
define(project_name_base + "_ENABLE_SEACASEjoin", True), "Ejoin",
define(project_name_base + "_ENABLE_SEACASEpu", True), "Epu",
define(project_name_base + "_ENABLE_SEACASExo2mat", True), "Exo2mat",
define(project_name_base + "_ENABLE_SEACASExo_format", True), "Exo_format",
define(project_name_base + "_ENABLE_SEACASExodiff", True), "Exodiff",
from_variant(project_name_base + "_ENABLE_SEACASExplore", "fortran"), "Mat2exo",
from_variant(project_name_base + "_ENABLE_SEACASGrepos", "fortran"), "Nas2exo",
define(project_name_base + "_ENABLE_SEACASMat2exo", True), "Nemslice",
define(project_name_base + "_ENABLE_SEACASNas2exo", True), "Nemspread",
define(project_name_base + "_ENABLE_SEACASNemslice", True), "Slice",
define(project_name_base + "_ENABLE_SEACASNemspread", True), "Zellij",
define(project_name_base + "_ENABLE_SEACASSlice", True), ):
define(project_name_base + "_ENABLE_SEACASZellij", True), options.append(define(project_name_base + "_ENABLE_SEACAS" + app, True))
] # Fortran-based applications
) for app in ("Explore", "Grepos"):
options.append(
from_variant(project_name_base + "_ENABLE_SEACAS" + app, "fortran")
)
if "+legacy" in spec: if "+legacy" in spec:
options.extend( # Legacy applications -- all are fortran-based except Nemesis
[ options.append(define(project_name_base + "_ENABLE_SEACASNemesis", True))
define(project_name_base + "_ENABLE_SEACASNemesis", True),
from_variant(project_name_base + "_ENABLE_SEACASAlgebra", "fortran"), for app in (
from_variant(project_name_base + "_ENABLE_SEACASBlot", "fortran"), "Algebra",
from_variant(project_name_base + "_ENABLE_SEACASEx1ex2v2", "fortran"), "Blot",
from_variant(project_name_base + "_ENABLE_SEACASEx2ex1v2", "fortran"), "Ex1ex2v2",
from_variant(project_name_base + "_ENABLE_SEACASExomatlab", "fortran"), "Ex2ex1v2",
from_variant(project_name_base + "_ENABLE_SEACASExotec2", "fortran"), "Exomatlab",
from_variant(project_name_base + "_ENABLE_SEACASExotxt", "fortran"), "Exotec2",
from_variant(project_name_base + "_ENABLE_SEACASFastq", "fortran"), "Exotxt",
from_variant(project_name_base + "_ENABLE_SEACASGen3D", "fortran"), "Fastq",
from_variant(project_name_base + "_ENABLE_SEACASGenshell", "fortran"), "Gen3D",
from_variant(project_name_base + "_ENABLE_SEACASGjoin", "fortran"), "Genshell",
from_variant(project_name_base + "_ENABLE_SEACASMapvar", "fortran"), "Gjoin",
from_variant(project_name_base + "_ENABLE_SEACASMapvar-kd", "fortran"), "Mapvar",
from_variant(project_name_base + "_ENABLE_SEACASNumbers", "fortran"), "Mapvar-kd",
from_variant(project_name_base + "_ENABLE_SEACASTxtexo", "fortran"), "Numbers",
] "Txtexo",
) ):
options.append(
from_variant(project_name_base + "_ENABLE_SEACAS" + app, "fortran")
)
# ##################### Dependencies ########################## # ##################### Dependencies ##########################
# Always need NetCDF-C # Always need NetCDF-C
options.extend( options.extend(
[ [
define("TPL_ENABLE_Netcdf", True), define("TPL_ENABLE_Netcdf", True),
"-DNetCDF_ROOT:PATH=%s" % spec["netcdf-c"].prefix, define("NetCDF_ROOT", spec["netcdf-c"].prefix),
] ]
) )
@ -299,24 +296,28 @@ def cmake_args(self):
options.extend( options.extend(
[ [
define("TPL_ENABLE_METIS", True), define("TPL_ENABLE_METIS", True),
"-DMETIS_LIBRARY_DIRS=%s" % spec["metis"].prefix.lib, define("METIS_LIBRARY_DIRS", spec["metis"].prefix.lib),
"-DMETIS_LIBRARY_NAMES=metis", define("METIS_LIBRARY_NAMES", "metis"),
"-DTPL_METIS_INCLUDE_DIRS=%s" % spec["metis"].prefix.include, define("TPL_METIS_INCLUDE_DIRS", spec["metis"].prefix.include),
define("TPL_ENABLE_ParMETIS", True), define("TPL_ENABLE_ParMETIS", True),
"-DParMETIS_LIBRARY_DIRS=%s;%s" define(
% (spec["parmetis"].prefix.lib, spec["metis"].prefix.lib), "ParMETIS_LIBRARY_DIRS",
"-DParMETIS_LIBRARY_NAMES=parmetis;metis", [spec["parmetis"].prefix.lib, spec["metis"].prefix.lib],
"-DTPL_ParMETIS_INCLUDE_DIRS=%s;%s" ),
% (spec["parmetis"].prefix.include, spec["metis"].prefix.include), define("ParMETIS_LIBRARY_NAMES", ["parmetis", "metis"]),
define(
"TPL_ParMETIS_INCLUDE_DIRS",
[spec["parmetis"].prefix.include, spec["metis"].prefix.include],
),
] ]
) )
elif "+metis" in spec: elif "+metis" in spec:
options.extend( options.extend(
[ [
define("TPL_ENABLE_METIS", True), define("TPL_ENABLE_METIS", True),
"-DMETIS_LIBRARY_DIRS=%s" % spec["metis"].prefix.lib, define("METIS_LIBRARY_DIRS", spec["metis"].prefix.lib),
"-DMETIS_LIBRARY_NAMES=metis", define("METIS_LIBRARY_NAMES", "metis"),
"-DTPL_METIS_INCLUDE_DIRS=%s" % spec["metis"].prefix.include, define("TPL_METIS_INCLUDE_DIRS", spec["metis"].prefix.include),
define("TPL_ENABLE_ParMETIS", False), define("TPL_ENABLE_ParMETIS", False),
] ]
) )
@ -328,59 +329,28 @@ def cmake_args(self):
] ]
) )
options.append(from_variant("TPL_ENABLE_Matio", "matio"))
if "+matio" in spec: if "+matio" in spec:
options.extend( options.append(define("Matio_ROOT", spec["matio"].prefix))
[
define("TPL_ENABLE_Matio", True),
"-DMatio_ROOT:PATH=%s" % spec["matio"].prefix,
]
)
else:
options.extend(
[
define("TPL_ENABLE_Matio", False),
]
)
options.append(from_variant("TPL_ENABLE_CGNS", "cgns"))
if "+cgns" in spec: if "+cgns" in spec:
options.extend( options.append(define("CGNS_ROOT", spec["cgns"].prefix))
[
define("TPL_ENABLE_CGNS", True),
"-DCGNS_ROOT:PATH=%s" % spec["cgns"].prefix,
]
)
else:
options.extend(
[
define("TPL_ENABLE_CGNS", False),
]
)
options.append(from_variant("TPL_ENABLE_Faodel", "faodel")) options.append(from_variant("TPL_ENABLE_Faodel", "faodel"))
for pkg in ("Faodel", "BOOST"): for pkg in ("Faodel", "BOOST"):
if pkg.lower() in spec: if pkg.lower() in spec:
options.append(define(pkg + "_ROOT", spec[pkg.lower()].prefix)) options.append(define(pkg + "_ROOT", spec[pkg.lower()].prefix))
options.append(from_variant("TPL_ENABLE_ADIOS2", "adios2"))
if "+adios2" in spec: if "+adios2" in spec:
options.extend( options.append(define("ADIOS2_ROOT", spec["adios2"].prefix))
[
define("TPL_ENABLE_ADIOS2", True),
"-DADIOS2_ROOT:PATH=%s" % spec["adios2"].prefix,
]
)
else:
options.extend(
[
define("TPL_ENABLE_ADIOS2", False),
]
)
# ################# RPath Handling ###################### # ################# RPath Handling ######################
if sys.platform == "darwin" and macos_version() >= Version("10.12"): if sys.platform == "darwin" and macos_version() >= Version("10.12"):
# use @rpath on Sierra due to limit of dynamic loader # use @rpath on Sierra due to limit of dynamic loader
options.append("-DCMAKE_MACOSX_RPATH:BOOL=ON") options.append(define("CMAKE_MACOSX_RPATH", True))
else: else:
options.append("-DCMAKE_INSTALL_NAME_DIR:PATH=%s" % self.prefix.lib) options.append(define("CMAKE_INSTALL_NAME_DIR", self.prefix.lib))
return options return options