openradioss: add DEXEC_NAME to cmake variable and change style of cmake_args (#43365)

This commit is contained in:
kjrstory 2024-03-29 18:45:54 +09:00 committed by GitHub
parent 3bdebeba3c
commit 5932ee901c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 58 deletions

View File

@ -54,59 +54,52 @@ class OpenradiossEngine(CMakePackage):
@property
def compiler_name(self):
compiler_mapping = {
"aocc": "64_AOCC",
"intel": "64_intel",
"oneapi": "64_intel",
"gcc": "64_gf",
"arm": "a64_gf",
"aocc": "linux64_AOCC",
"intel": "linux64_intel",
"oneapi": "linux64_intel",
"gcc": "linux64_gf",
"arm": "linuxa64",
}
compiler_name = compiler_mapping[self.spec.compiler.name]
return compiler_name
def cmake_args(self):
args = [
"-Dmpi_os=0",
"-DCMAKE_Fortran_COMPILER={0}".format(spack_fc),
"-DCMAKE_C_COMPILER={0}".format(spack_cc),
"-DCMAKE_CPP_COMPILER={0}".format(spack_cxx),
"-DCMAKE_CXX_COMPILER={0}".format(spack_cxx),
"-Dsanitize=0",
self.define("mpi_os", False),
self.define("CMAKE_Fortran_COMPILER", spack_fc),
self.define("CMAKE_C_COMPILER", spack_cc),
self.define("CMAKE_CPP_COMPILER", spack_cxx),
self.define("CMAKE_CXX_COMPILER", spack_cxx),
self.define("sanitize", False),
self.define("arch", self.compiler_name),
self.define_from_variant("debug", "debug"),
self.define_from_variant("static_link", "static_link"),
]
args.append("-Drach=linux" + self.compiler_name)
if "+sp" in self.spec:
args.append("-Dprecision=sp")
args.append(self.define("precision", "sp"))
else:
args.append("-Dprecision=dp")
args.append(self.define("precision", "dp"))
if "+mpi" in self.spec:
args.append("-DMPI=ompi")
args.append("-Dmpi_root=" + self.spec["mpi"].prefix)
args.append("-Dmpi_incdir=" + self.spec["mpi"].prefix.include)
args.append("-Dmpi_libdir=" + self.spec["mpi"].prefix.lib)
args.append(self.define("MPI", "ompi"))
args.append(self.define("mpi_root", self.spec["mpi"].prefix))
args.append(self.define("mpi_incdir", self.spec["mpi"].prefix.include))
args.append(self.define("mpi_libdir", self.spec["mpi"].prefix.lib))
else:
args.append("-DMPI=smp")
args.append(self.define("MPI", "smp"))
if "+debug" in self.spec:
args.append("-Ddebug=1")
else:
args.append("-Ddebug=0")
if "+static_link" in self.spec:
args.append("-Dstatic_link=1")
else:
args.append("-Dstatic_link=0")
exec_file = f"engine_{self.compiler_name}"
exec_file += "_ompi" if "+mpi" in self.spec else ""
args.append(self.define("EXEC_NAME", exec_file))
return args
def install(self, spec, prefix):
mkdirp(join_path(prefix, "exec"))
if "+mpi" in spec:
exec_file = "engine_linux" + self.compiler_name + "_ompi"
else:
exec_file = "engine_linux" + self.compiler_name
exec_file = f"engine_{self.compiler_name}"
exec_file += "_ompi" if "+mpi" in self.spec else ""
install(
join_path(self.stage.source_path, "engine", exec_file),

View File

@ -53,47 +53,39 @@ class OpenradiossStarter(CMakePackage):
@property
def compiler_name(self):
compiler_mapping = {
"aocc": "64_AOCC",
"intel": "64_intel",
"oneapi": "64_intel",
"gcc": "64_gf",
"arm": "a64_gf",
"aocc": "linux64_AOCC",
"intel": "linux64_intel",
"oneapi": "linux64_intel",
"gcc": "linux64_gf",
"arm": "linuxa64",
}
compiler_name = compiler_mapping[self.spec.compiler.name]
return compiler_name
def cmake_args(self):
args = [
"-DCMAKE_Fortran_COMPILER={0}".format(spack_fc),
"-DCMAKE_C_COMPILER={0}".format(spack_cc),
"-DCMAKE_CPP_COMPILER={0}".format(spack_cxx),
"-DCMAKE_CXX_COMPILER={0}".format(spack_cxx),
"-Dsanitize=0",
self.define("CMAKE_Fortran_COMPILER", spack_fc),
self.define("CMAKE_C_COMPILER", spack_cc),
self.define("CMAKE_CPP_COMPILER", spack_cxx),
self.define("CMAKE_CXX_COMPILER", spack_cxx),
self.define("santize", False),
self.define("arch", self.compiler_name),
self.define("EXEC_NAME", f"starter_{self.compiler_name}"),
self.define_from_variant("debug", "debug"),
self.define_from_variant("static_link", "static_link"),
]
args.append("-Darch=linux" + self.compiler_name)
if "+sp" in self.spec:
args.append("-Dprecision=sp")
args.append(self.define("precision", "sp"))
else:
args.append("-Dprecision=dp")
if "+debug" in self.spec:
args.append("-Ddebug=1")
else:
args.append("-Ddebug=0")
if "+static_link" in self.spec:
args.append("-Dstatic_link=1")
else:
args.append("-Dstatic_link=0")
args.append(self.define("precision", "dp"))
return args
def install(self, spec, prefix):
mkdirp(join_path(prefix, "exec"))
exec_file = "starter_linux" + self.compiler_name
exec_file = f"starter_{self.compiler_name}"
install(
join_path(self.stage.source_path, "starter", exec_file),