From 7a4b479724baaca474403b8be11ced5918ef3f86 Mon Sep 17 00:00:00 2001 From: Victor Brunini Date: Wed, 11 Oct 2023 14:30:44 -0700 Subject: cmake: drop CMAKE_STATIC_LINKER_FLAGS (#40423) Because those end up being passed to ar which does not understand linker arguments. This was making ldflags largely unusuable for statically linked cmake packages. --- lib/spack/spack/build_systems/cmake.py | 6 +++--- lib/spack/spack/test/flag_handlers.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index e51dbf9220..1859e40fe5 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -142,10 +142,10 @@ class CMakePackage(spack.package_base.PackageBase): # We specify for each of them. if flags["ldflags"]: ldflags = " ".join(flags["ldflags"]) - ld_string = "-DCMAKE_{0}_LINKER_FLAGS={1}" # cmake has separate linker arguments for types of builds. - for type in ["EXE", "MODULE", "SHARED", "STATIC"]: - self.cmake_flag_args.append(ld_string.format(type, ldflags)) + self.cmake_flag_args.append(f"-DCMAKE_EXE_LINKER_FLAGS={ldflags}") + self.cmake_flag_args.append(f"-DCMAKE_MODULE_LINKER_FLAGS={ldflags}") + self.cmake_flag_args.append(f"-DCMAKE_SHARED_LINKER_FLAGS={ldflags}") # CMake has libs options separated by language. Apply ours to each. if flags["ldlibs"]: diff --git a/lib/spack/spack/test/flag_handlers.py b/lib/spack/spack/test/flag_handlers.py index ae83b05885..3e680c1ab7 100644 --- a/lib/spack/spack/test/flag_handlers.py +++ b/lib/spack/spack/test/flag_handlers.py @@ -121,7 +121,6 @@ class TestFlagHandlers: "-DCMAKE_EXE_LINKER_FLAGS=-mthreads", "-DCMAKE_MODULE_LINKER_FLAGS=-mthreads", "-DCMAKE_SHARED_LINKER_FLAGS=-mthreads", - "-DCMAKE_STATIC_LINKER_FLAGS=-mthreads", } def test_ld_libs_cmake(self, temp_env): -- cgit v1.2.3-60-g2f50