I have a project which I build both as Debug, Release, and RelWithDebInfo. Starting in CMake 3.9.6 (I think?), the property INTERPROCEDURAL_OPTIMIZATION has been introduced, which includes -flto for the project. However, I don't want to have -flto enabled when compiling for Debug, as it slows down the compile time (and the debugger is less stable in my experience when this feature is enabled).
Currently what I do to enable -flto in CMake is the following:
include(CheckIPOSupported) check_ipo_supported(RESULT ipo_result OUTPUT ipo_err) if (ipo_result) message(STATUS "IPO is supported") set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) endif () I wonder whether there's an option to include this feature only when Release is enabled. Moreover, I'm using the Xcode generator with my project, so I wonder whether this rule (-flto for Debug configuration only) can be applied to the generated .xcodeproj as well?