FetchContent has poor performance on Windows
Take this minimal example: https://github.com/iboB/cmake-fetch-content-perf/blob/master/CMakeLists.txt
On Ubuntu 20.04 (more precisely WSL) - CMake 3.16.3 - after the initial slow configure, each subsequent one takes about 200ms per fetch content item. This is not great (and I have a suggestion for improvement, which seems too much for now, in #21698 (closed)), but I guess I can live with 200ms per item.
On Windows - CMake 3.19.2 - however each item takes about 1.2 seconds (the exact same machine). I think this is too slow, and I can find no reason for the 5x slowdown. At first I thought it was because of FetchContent
relies on ExternalProject_Add
which in turn calls cmake --build
and this launches the heavy machinery of MSBuild with my default generator. However I tried it with MinGW Makefiles and saw no difference in performance. Still about 1.2 seconds per item.
Summarized personal measurements from this and below posts:
OS | CMake Ver | Generator | Machine | ~ ms per item |
---|---|---|---|---|
Ubuntu 20.04 | 3.16.3 | Unix Makefiles | ThreadRipper, SSD | 200 |
Windows 10 | 3.19.2 | Visual Studio 2019 | ThreadRipper, SSD | 1200 |
Windows 10 | 3.19.2 | MinGW Makefiles | ThreadRipper, SSD | 1200 |
Arch Linux | 3.19.2 | Unix Makefiles | 8 core @ 2.4 GHz, HDD | 800 |
Arch Linux | 3.19.2 | Unix Makefiles | 8 core @ 2.4 GHz, RAM | 700 |
Arch Linux | 3.16.3 | Unix Makefiles | 8 core @ 2.4 GHz, HDD | 350 |
Arch Linux | 3.16.3 | Unix Makefiles | 8 core @ 2.4 GHz, RAM | 300 |
Windows 10 | 3.16.3 | MinGW Makefiles | 6 core @ 3 GHz, SSD | 1500 |