CheckIPOSupported¶
Added in version 3.9.
Check whether the compiler supports an interprocedural optimization (IPO/LTO).
Use this before enabling the INTERPROCEDURAL_OPTIMIZATION
target
property.
- check_ipo_supported¶
check_ipo_supported([RESULT <result>] [OUTPUT <output>] [LANGUAGES <lang>...])
Options are:
RESULT <result>
Set
<result>
variable toYES
if IPO is supported by the compiler andNO
otherwise. If this option is not given then the command will issue a fatal error if IPO is not supported.OUTPUT <output>
Set
<output>
variable with details about any error.LANGUAGES <lang>...
Specify languages whose compilers to check.
The following languages are supported:
C
CXX
CUDA
Added in version 3.25.
Fortran
If this option is not given, the default languages are picked from the current
ENABLED_LANGUAGES
global property.
Note
To use check_ipo_supported()
, policy CMP0069
must be set to
NEW
; otherwise, a fatal error will occur.
Added in version 3.13: Support for Visual Studio generators.
Added in version 3.24: The check uses the caller's CMAKE_<LANG>_FLAGS
and CMAKE_<LANG>_FLAGS_<CONFIG>
values.
See policy CMP0138
.
Examples¶
check_ipo_supported() # fatal error if IPO is not supported
set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
# Optional IPO. Do not use IPO if it's not supported by compiler.
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${output}")
endif()