In my project the cmake generate step takes 5 seconds with the makefile generator on Ubuntu while the same project takes 33 seconds on Windows with the Visual Studio generator. The 5 seconds are so much nicer when working on cmake code. So just out of curiousity I wonder what makes running cmake on Linux so much faster?
The VS generator (and Xcode for that matter) are multi-config generators, so the generation step takes 4x longer by default. You can remove unwanted configurations from
CMAKE_CONFIGURATION_TYPES to reduce the time. Configure time may be affected as
try_compile and friends end up configuring and generating subprojects too. Anything else should just be filesystem access differences.
CMake 3.18 added profiler output that might lend clues to the differences.
cmake -B build --profiling-output=perf.json --profiling-format=google-trace
then type in Chrome or Edge address bar
about:tracing and Load perf.json.
In general across programming languages it seems one possible difference is the longer time it can take Windows to launch processes. So for example configure steps that invoke the compiler to test symbols or features can cumulatively consume more time on Windows.
When I researched this topic years ago the time to launch processes was the time killer on Windows. There just isn’t much you can do about it. Looking at our own dashboards at https://my.cdash.org/index.php?project=DREAM3D the machines “Utah” and “Cobalt” are both Dell workstations. The only difference is Cobalt has a 12 core Xeon and runs Windows 10 and Utah has a 10 Core Xeon and runs Ubuntu 18.04. Both use Ninja. The Windows machine takes about 30 seconds to configure and the Linux machine takes 7 (This is also true for macOS machines, about 7 seconds). If I find that I have a bunch of work to do on the CMake side of things I move over to a Linux/macOS machine for the bulk of the work and then just verify everything works on the Windows side of things. That and the NT file system is also “slow” compared to others like EXT4 and APFS.
thanks Mike. The factors you’re mentioning are also impacting Meson build system (which is pure Python) in the same way on Windows vs. *nix