libjpeg-turbo: set compiler flags with CMake args (#11938)
Later versions of libjpeg-turbo build with CMake; to build with user-specified cflags, the user must supply these to CMake as -DCMAKE_C_FLAGS (Spack's typical approach of injecting these flags into the compiler wrapper invocation is insufficient in this case). Currently libjpeg-turbo cannot be implemented as a CMakePackage (and thereby take advantage of the flag_handler implementation it provides) because not all versions of libjpeg-turbo use CMake, so this adds a custom implementation of flag_handler and flags_to_build_system_args to libjpeg-turbo.
This commit is contained in:
parent
7f3048c8af
commit
1269256e25
@ -38,6 +38,22 @@ class LibjpegTurbo(Package):
|
|||||||
def libs(self):
|
def libs(self):
|
||||||
return find_libraries("libjpeg*", root=self.prefix, recursive=True)
|
return find_libraries("libjpeg*", root=self.prefix, recursive=True)
|
||||||
|
|
||||||
|
def flag_handler(self, name, flags):
|
||||||
|
if self.spec.satisfies('@1.5.90:'):
|
||||||
|
return (None, None, flags)
|
||||||
|
else:
|
||||||
|
# compiler flags for earlier version are injected into the
|
||||||
|
# spack compiler wrapper
|
||||||
|
return (flags, None, None)
|
||||||
|
|
||||||
|
def flags_to_build_system_args(self, flags):
|
||||||
|
# This only handles cflags, other flags are discarded
|
||||||
|
cmake_flag_args = []
|
||||||
|
if 'cflags' in flags and flags['cflags']:
|
||||||
|
cmake_flag_args.append('-DCMAKE_C_FLAGS={0}'.format(
|
||||||
|
' '.join(flags['cflags'])))
|
||||||
|
self.cmake_flag_args = cmake_flag_args
|
||||||
|
|
||||||
@when('@1.3.1:1.5.3')
|
@when('@1.3.1:1.5.3')
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
autoreconf('-ifv')
|
autoreconf('-ifv')
|
||||||
@ -48,6 +64,8 @@ def install(self, spec, prefix):
|
|||||||
@when('@1.5.90:')
|
@when('@1.5.90:')
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
cmake_args = ['-GUnix Makefiles']
|
cmake_args = ['-GUnix Makefiles']
|
||||||
|
if hasattr(self, 'cmake_flag_args'):
|
||||||
|
cmake_args.extend(self.cmake_flag_args)
|
||||||
cmake_args.extend(std_cmake_args)
|
cmake_args.extend(std_cmake_args)
|
||||||
with working_dir('spack-build', create=True):
|
with working_dir('spack-build', create=True):
|
||||||
cmake('..', *cmake_args)
|
cmake('..', *cmake_args)
|
||||||
|
Loading…
Reference in New Issue
Block a user