Open Semphriss opened 3 months ago
I had to change a few more things in the code for the builds to pass. I changed it to the best of my abilities, but some involve design choices, so it might be good to review them. The diff will show all the changes, but I bumped the minimum CMake version from 3.1 to 3.9 to support policy CMP0069 (needs 3.6) and list(FILTER ...)
(requires 3.9). Let me know if you'd like to change something.
I tested this a couple days ago. Seems to be working fine.
This sounds like enabling pre-compiled headers has only advantages and no disadvantage. If a developer edits a single header file and recompiles the program, is the recompilation faster or slower with pre-compiled headers enabled?
@HybridDog It's something I've been thinking about, whether or not to enable them by default. They're not really relevant during development, only when making releases, which is IMO the preferred place for lesser-known non-default options to live.
I haven't tried actively developing with those options enabled, but I would presume, especially with LTO, that it substantially slows down development compiling. I'm not sure how large the impact is, and active developers would be better placed to report their experience with that.
If they are only relevant for release builds, maybe they can be enabled if and only if the build type is Release or RelWithDebInfo (-DRELEASE).
PCH and IPO are now only enabled on Release|RelWithDebInfo builds.
This adds CMake code to enable pre-compiled headers (PCH) and interprocedural optimisation (IPO, or LTO for link-time optimisation).
PCH
PCH makes builds 50% to 66% faster. A simple
time make -j$(nproc)
on my 12-core CPU shows:real
is the total time spent, from start to finish, as perceived by the developer.user
is the sum of the time spent by each thread, which gives a better idea of what would happen on a single-threaded system. DetailsIPO
IPO makes Release builds 15% smaller. I have not tested the runtime performance.
Notes
cmake_policy(SET CMP0069 NEW)
requires CMake >=3.9, but I did not updatecmake_minimum_required
to discuss whether or not to keep the policy.