[CMake] CMake 3.13 Interprocedural Optimization for Visual C++: Whole Program Optimization (LTCG)
Niels Dekker
niels_dekker_address_until_2024 at xs4all.nl
Thu Nov 22 08:12:00 EST 2018
I'm very pleased that CMake 3.13 (just released) includes the "IPO for
VS" feature that I implemented, with help from Brad Kind: it allows
enabling Whole Program Optimization (Link Time Code Generation) on a
Visual C++ project, by means of CMake flag INTERPROCEDURAL_OPTIMIZATION.
Visual Studio offers this option (LTCG) for more than a decade already,
within the IDE. I'm glad that it's now also directly available to
VS/CMake users.
In general, I would suggest to enable this option only for a Release
build. As follows:
project(MyProject)
add_executable(MyProject MyMain.cpp MySource.cpp)
set_property(TARGET MyProject PROPERTY
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
I'm interested to hear from other VS/CMake users if they find this new
option helpful. And specifically whether they experience a significant
performance gain from their application, after enabling IPO.
Note that my request to enable IPO "by default" for Release
configurations has been rejected, at least for the time being:
https://gitlab.kitware.com/cmake/cmake/issues/17720 So for now, users
have to explicitly switch on this option.
Kind regards, Niels
--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center
More information about the CMake
mailing list