honor global spack flags (#33470)

This commit is contained in:
Chris White 2022-10-21 15:50:01 -07:00 committed by GitHub
parent 3fd097f1d5
commit 773de54cd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,6 +179,23 @@ def hostconfig(self):
cfg.write("# cpp compiler used by spack\n") cfg.write("# cpp compiler used by spack\n")
cfg.write(cmake_cache_entry("CMAKE_CXX_COMPILER", cpp_compiler)) cfg.write(cmake_cache_entry("CMAKE_CXX_COMPILER", cpp_compiler))
# use global spack compiler flags
cppflags = " ".join(spec.compiler_flags["cppflags"])
if cppflags:
# avoid always ending up with ' ' with no flags defined
cppflags += " "
cflags = cppflags + " ".join(spec.compiler_flags["cflags"])
if cflags:
cfg.write(cmake_cache_entry("CMAKE_C_FLAGS", cflags))
cxxflags = cppflags + " ".join(spec.compiler_flags["cxxflags"])
if cxxflags:
cfg.write(cmake_cache_entry("CMAKE_CXX_FLAGS", cxxflags))
fflags = " ".join(spec.compiler_flags["fflags"])
if self.spec.satisfies("%cce"):
fflags += " -ef"
if fflags:
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
# shared vs static libs # shared vs static libs
if "+shared" in spec: if "+shared" in spec:
cfg.write(cmake_cache_entry("BUILD_SHARED_LIBS", "ON")) cfg.write(cmake_cache_entry("BUILD_SHARED_LIBS", "ON"))