From 983422facf5c4c7af9ef3456ff7d7f43ffa13305 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Thu, 29 Feb 2024 21:12:27 -0600 Subject: [PATCH] libogg does not build a shared libary with cmake (#42877) * when built with cmake, libogg does not build with a shared libary by default. This resolves that * spack style fixes * Clean up imports * enforce +pic when +shared --- .../repos/builtin/packages/libogg/package.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/libogg/package.py b/var/spack/repos/builtin/packages/libogg/package.py index 45613a654c..d711e95483 100644 --- a/var/spack/repos/builtin/packages/libogg/package.py +++ b/var/spack/repos/builtin/packages/libogg/package.py @@ -5,7 +5,7 @@ import os -from spack.build_systems.generic import GenericBuilder +from spack.build_systems import cmake, generic from spack.package import * @@ -22,6 +22,16 @@ class Libogg(CMakePackage, AutotoolsPackage, Package): version("1.3.4", sha256="fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e") version("1.3.2", sha256="e19ee34711d7af328cb26287f4137e70630e7261b17cbe3cd41011d73a654692") + variant("shared", default=True, description="Build shared library", when="build_system=cmake") + variant( + "pic", + default=True, + description="Produce position-independent code (for shared libs)", + when="build_system=cmake", + ) + + requires("+pic", when="+shared") + # Backport a patch that fixes an unsigned typedef problem on macOS: # https://github.com/xiph/ogg/pull/64 patch( @@ -37,7 +47,17 @@ class Libogg(CMakePackage, AutotoolsPackage, Package): ) -class GenericBuilder(GenericBuilder): +class CMakeBuilder(cmake.CMakeBuilder): + def cmake_args(self): + base_cmake_args = [ + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), + self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), + ] + + return base_cmake_args + + +class GenericBuilder(generic.GenericBuilder): phases = ["build", "install"] def is_64bit(self):