Skip to content

Always set CMP0069 to new to enforce LTO use if requested

Benjamin Morgan requested to merge bmorgan/atlasexternals:support-lto into main

CMake 3.9 introduced support for link time optimization, but the AtlasFunctions module sets cmake_minimum_required to 3.6. This disables LTO even in CMake versions above 3.9 and means the CMAKE_INTERPROCEDURAL_OPTIMIZATION flag and associated target property cannot be used to enable LTO either locally or globally.

Retain CMake minimum version to avoid surprises, set the LTO related policy CMP0069 available from CMake 3.9 to enforce use of LTO if requested.

There should be no side effects to setting this policy. Its primary benefit is to allow projects using AtlasFunctions like Athena/AthSimulation to configure with cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON ..., or to set the INTERPROCEDURAL_OPTIMIZATION property on individual targets. CMake will then ensure the flags appropriate for the compiler are added to the build/link commands as needed, if CMake knows them.

The need for this feature comes from ATLASSIM-6058 on using LTO to further optimization the AtlasGeant4 "big" library.

Edited by Benjamin Morgan

Merge request reports