CMP0069¶
Added in version 3.9.
INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
CMake 3.9 and newer prefer to add IPO flags whenever theINTERPROCEDURAL_OPTIMIZATION target property is enabled andproduce an error if flags are not known to CMake for the current compiler.Since a given compiler may not support IPO flags in all environments in whichit is used, it is now the project's responsibility to use theCheckIPOSupported module to check for support before enabling theINTERPROCEDURAL_OPTIMIZATION target property. This approachallows a project to conditionally activate IPO when supported. It alsoallows an end user to set theCMAKE_INTERPROCEDURAL_OPTIMIZATIONvariable in an environment known to support IPO even if the project doesnot enable the property.
Since CMake 3.8 and lower only honoredINTERPROCEDURAL_OPTIMIZATIONfor the Intel compiler on Linux, some projects may unconditionally enable thetarget property. PolicyCMP0069 provides compatibility with such projects.
This policy takes effect whenever the IPO property is enabled. TheOLDbehavior for this policy is to add IPO flags only for Intel compiler on Linux.TheNEW behavior for this policy is to add IPO flags for the currentcompiler or produce an error if CMake does not know the flags.
This policy was introduced in CMake version 3.9.It may be set bycmake_policy() orcmake_minimum_required().If it is not set, CMake warns, and usesOLD behavior.
Note
TheOLD behavior of a policy isdeprecatedbydefinitionand may be removed in a future version of CMake.
Examples¶
Behave like CMake 3.8 and do not apply any IPO flags except for Intel compileron Linux:
cmake_minimum_required(VERSION3.8)project(foo)# ...set_property(TARGET...PROPERTYINTERPROCEDURAL_OPTIMIZATIONTRUE)
Use theCheckIPOSupported module to detect whether IPO issupported by the current compiler, environment, and CMake version.Produce a fatal error if support is not available:
cmake_minimum_required(VERSION3.9)# CMP0069 NEWproject(foo)include(CheckIPOSupported)check_ipo_supported()# ...set_property(TARGET...PROPERTYINTERPROCEDURAL_OPTIMIZATIONTRUE)
Apply IPO flags only if compiler supports it:
cmake_minimum_required(VERSION3.9)# CMP0069 NEWproject(foo)include(CheckIPOSupported)# ...check_ipo_supported(RESULTresult)if(result)set_property(TARGET...PROPERTYINTERPROCEDURAL_OPTIMIZATIONTRUE)endif()
Apply IPO flags without any checks. This may lead to build errors if IPOis not supported by the compiler in the current environment. Produce anerror if CMake does not know IPO flags for the current compiler:
cmake_minimum_required(VERSION3.9)# CMP0069 NEWproject(foo)# ...set_property(TARGET...PROPERTYINTERPROCEDURAL_OPTIMIZATIONTRUE)
