summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort-karatsu <49965247+t-karatsu@users.noreply.github.com>2019-07-18 07:37:18 +0900
committerPeter Scheibel <scheibel1@llnl.gov>2019-07-17 15:37:18 -0700
commit1269256e25700912bb0a450d2a41cc09d0cc9cff (patch)
tree8102ee22d0c277035e602068ffb5d1c6020d46cf
parent7f3048c8af43f8bf119a88f56391360ab42a957d (diff)
downloadspack-1269256e25700912bb0a450d2a41cc09d0cc9cff.tar.gz
spack-1269256e25700912bb0a450d2a41cc09d0cc9cff.tar.bz2
spack-1269256e25700912bb0a450d2a41cc09d0cc9cff.tar.xz
spack-1269256e25700912bb0a450d2a41cc09d0cc9cff.zip
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.
-rw-r--r--var/spack/repos/builtin/packages/libjpeg-turbo/package.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/libjpeg-turbo/package.py b/var/spack/repos/builtin/packages/libjpeg-turbo/package.py
index 3d80762e75..039b77052b 100644
--- a/var/spack/repos/builtin/packages/libjpeg-turbo/package.py
+++ b/var/spack/repos/builtin/packages/libjpeg-turbo/package.py
@@ -38,6 +38,22 @@ class LibjpegTurbo(Package):
def libs(self):
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')
def install(self, spec, prefix):
autoreconf('-ifv')
@@ -48,6 +64,8 @@ class LibjpegTurbo(Package):
@when('@1.5.90:')
def install(self, spec, prefix):
cmake_args = ['-GUnix Makefiles']
+ if hasattr(self, 'cmake_flag_args'):
+ cmake_args.extend(self.cmake_flag_args)
cmake_args.extend(std_cmake_args)
with working_dir('spack-build', create=True):
cmake('..', *cmake_args)