From 1147220b9bd5c925e30fb57e5296e8f89aa1da91 Mon Sep 17 00:00:00 2001 From: Omri Mor Date: Wed, 21 Oct 2020 02:09:45 -0700 Subject: CMakePackage: added 'ipo' variant (#18374) +ipo sets CMAKE_INTERPROCEDURAL_OPTIMIZATION=ON The option is not supported for CMake < 3.9 --- lib/spack/spack/build_systems/cmake.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index 2f5fd05405..4b679b358a 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -12,7 +12,7 @@ import re import spack.build_environment from llnl.util.filesystem import working_dir from spack.util.environment import filter_system_paths -from spack.directives import depends_on, variant +from spack.directives import depends_on, variant, conflicts from spack.package import PackageBase, InstallError, run_after # Regex to extract the primary generator from the CMake generator @@ -94,6 +94,13 @@ class CMakePackage(PackageBase): description='CMake build type', values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel')) + # https://cmake.org/cmake/help/latest/variable/CMAKE_INTERPROCEDURAL_OPTIMIZATION.html + variant('ipo', default=False, + description='CMake interprocedural optimization') + # CMAKE_INTERPROCEDURAL_OPTIMIZATION only exists for CMake >= 3.9 + conflicts('+ipo', when='^cmake@:3.8', + msg='+ipo is not supported by CMake < 3.9') + depends_on('cmake', type='build') @property @@ -147,6 +154,11 @@ class CMakePackage(PackageBase): except KeyError: build_type = 'RelWithDebInfo' + try: + ipo = pkg.spec.variants['ipo'].value + except KeyError: + ipo = False + define = CMakePackage.define args = [ '-G', generator, @@ -154,6 +166,10 @@ class CMakePackage(PackageBase): define('CMAKE_BUILD_TYPE', build_type), ] + # CMAKE_INTERPROCEDURAL_OPTIMIZATION only exists for CMake >= 3.9 + if pkg.spec.satisfies('^cmake@3.9:'): + args.append(define('CMAKE_INTERPROCEDURAL_OPTIMIZATION', ipo)) + if primary_generator == 'Unix Makefiles': args.append(define('CMAKE_VERBOSE_MAKEFILE', True)) -- cgit v1.2.3-60-g2f50