2

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?

1 Answer 1

2

Use INTERPROCEDURAL_OPTIMIZATION_<CONFIG> instead. Note that these are directory and target properties not global. So you'll have to enable it for the configurations that do use it or you may be able set it to false to deactivate it if enabled.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Additional, for future reference, it is possible to set(_CMAKE_LTO_THIN TRUE) if one wants to use ThinLTO.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.