summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/build_systems/cmake.py18
1 files changed, 17 insertions, 1 deletions
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))