Setting default compiler in CMake

CMake 3.15 or later supports overriding the default generator by setting the environment variable CMAKE_GENERATOR.

E.g., using PowerShell, set the environment variable in the following way to make MinGW the default generator:

$Env:CMAKE_GENERATOR = 'MinGW Makefiles'

For older CMake versions (< 3.15), CMake uses the newest Visual Studio installation as default generator, unless the generator is explicitly specified upon invoking CMake. This behavior is hard coded and cannot be changed.

As a work-around you can use a batch wrapper script titled cmake.cmd with the following contents:

@cmake.exe -G "MinGW Makefiles" %*

The script should be placed in a directory on the system PATH and should take precedence over the CMake executable cmake.exe.

The script invokes cmake.exe with MinGW as a generator and forwards all other parameters to it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)