CMakePackage: Set policy CMP0042 NEW on macos (#46114)

so linking to shared libraries works well at runtime on darwin for all packages with cmake_minimum_required < 3.
This commit is contained in:
Chris Marsh 2024-08-29 12:49:53 -06:00 committed by GitHub
parent c5766aa757
commit cade66d842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,6 +108,11 @@ def _conditional_cmake_defaults(pkg: spack.package_base.PackageBase, args: List[
if _supports_compilation_databases(pkg):
args.append(CMakeBuilder.define("CMAKE_EXPORT_COMPILE_COMMANDS", True))
# Enable MACOSX_RPATH by default when cmake_minimum_required < 3
# https://cmake.org/cmake/help/latest/policy/CMP0042.html
if pkg.spec.satisfies("platform=darwin") and cmake.satisfies("@3:"):
args.append(CMakeBuilder.define("CMAKE_POLICY_DEFAULT_CMP0042", "NEW"))
def generator(*names: str, default: Optional[str] = None):
"""The build system generator to use.