diff options
author | Chris White <white238@llnl.gov> | 2022-08-11 14:55:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-11 14:55:43 -0700 |
commit | 8c23545a3abd7ea69d73d4a36397df07a44d1959 (patch) | |
tree | 776ce3cba015144ece1a7cd27e6f9d185f965758 /lib | |
parent | 6ab6058ab4ff046115f71d501c8ef20b9bc05ae3 (diff) | |
download | spack-8c23545a3abd7ea69d73d4a36397df07a44d1959.tar.gz spack-8c23545a3abd7ea69d73d4a36397df07a44d1959.tar.bz2 spack-8c23545a3abd7ea69d73d4a36397df07a44d1959.tar.xz spack-8c23545a3abd7ea69d73d4a36397df07a44d1959.zip |
CachedCMakePackage: Port over logic from CMake build system for ldlibs and ldflags (#31750)
* port over logic from cmake build system for ldlibs and ldflags
* follow new style standards
* escape quotes
* escape quotes
* nevermind going back
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/cached_cmake.py | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index 52e3d82411..9ffd2a82ab 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -87,21 +87,42 @@ class CachedCMakePackage(CMakePackage): "endif()\n", ] + flags = spec.compiler_flags + # use global spack compiler flags - cppflags = " ".join(spec.compiler_flags["cppflags"]) + cppflags = " ".join(flags["cppflags"]) if cppflags: - # avoid always ending up with ' ' with no flags defined + # avoid always ending up with " " with no flags defined cppflags += " " - cflags = cppflags + " ".join(spec.compiler_flags["cflags"]) + cflags = cppflags + " ".join(flags["cflags"]) if cflags: entries.append(cmake_cache_string("CMAKE_C_FLAGS", cflags)) - cxxflags = cppflags + " ".join(spec.compiler_flags["cxxflags"]) + cxxflags = cppflags + " ".join(flags["cxxflags"]) if cxxflags: entries.append(cmake_cache_string("CMAKE_CXX_FLAGS", cxxflags)) - fflags = " ".join(spec.compiler_flags["fflags"]) + fflags = " ".join(flags["fflags"]) if fflags: entries.append(cmake_cache_string("CMAKE_Fortran_FLAGS", fflags)) + # Cmake has different linker arguments for different build types. + # We specify for each of them. + if flags["ldflags"]: + ld_flags = " ".join(flags["ldflags"]) + ld_format_string = "CMAKE_{0}_LINKER_FLAGS" + # CMake has separate linker arguments for types of builds. + for ld_type in ["EXE", "MODULE", "SHARED", "STATIC"]: + ld_string = ld_format_string.format(ld_type) + entries.append(cmake_cache_string(ld_string, ld_flags)) + + # CMake has libs options separated by language. Apply ours to each. + if flags["ldlibs"]: + libs_flags = " ".join(flags["ldlibs"]) + libs_format_string = "CMAKE_{0}_STANDARD_LIBRARIES" + langs = ["C", "CXX", "Fortran"] + for lang in langs: + libs_string = libs_format_string.format(lang) + entries.append(cmake_cache_string(libs_string, libs_flags)) + return entries def initconfig_mpi_entries(self): |