How to set the default MSVC compiler version when multiple versions exist for same toolset version - cmake

I have multiple versions of MSVC C++ build tools for the same toolset(v142) installed using Visual studio build tools. How can I set the default or preferred version of the MSVC compiler. Is there a registry or environment variable for setting this in Windows or with Cmake?
Cmake picks up the latest version and I want it to use older version for some builds. CMake does seem to have a -T parameter for toolset but in my case both versions are for toolset v142.
Please note that I do not have or intend to use Visual Studio IDE for this since I am dealing with command line builds for CI purposes.

You can pass the required version via CLI:
$ cmake ... -T v142,version=14.24
See also CMAKE_GENERATOR_TOOLSET variable.

Related

When using CMakePresets.json, what is the equivalent of remotePreGenerateCommand?

I am trying to switch from CMakeSettings.json to CMakePresets.json in a Visual Studio CMake project targetting Linux.
In my current CMakeSettings.json, I used to activate a Conda environment before generating the CMake cache on remote systems (including WSL) with:
{
...
"remotePreGenerateCommand": "conda activate foobar",
}
What would be the equivalent feature with CMakePresets.json? I could not find anything similar in the Visual Studio Remote Settings vendor map.

Eigen3 cannot find GLUT if I use freeglut 3.2.1?

Environment
Windows 10 version 1903, 64bit
Eigen 3.3.7
freeglut 3.2.1
Visual Studio 2015 Update 3
When I run the following cmake command to build Eigen3:
cmake -DCMAKE_CONFIGURATION_TYPES=Release -DPKG_CONFIG_EXECUTABLE=D:\3rd-parties\pkg-config.exe -DGLUT_glut_LIBRARY=D:\3rd-parties\freeglut-3.2.1\install\lib\freeglut.lib -G"Visual Studio 14 2015 Win64" ..
, Eigen3 always complains:
-- Could NOT find GLUT (missing: GLUT_glut_LIBRARY)
even though I have correctly set the GLUT_glut_LIBRARY variable. I'm sure freeglut 3.2.1 was correctly built under Release mode in VS2015 and the path is specified without any problem. So, how to have Eigen3 work with freeglut, or Eigen3 does not work with freeglut at all, but only with the old legacy GLUT? Besides, does Eigen use or depend on GLUT? If not, I may just safely ignore this error. Thank you.

cmake windows x64 builds

Is there a way to use the cmake gui to specify a x64 build, since by default cmake on windows creates a 32-bit Visual Studio solution.
From the command line, folks say to do this:
C:\projectx\build> cmake ..\make -G "Visual Studio 10 Win64"
but how do I get to the command line arguments from the cmake windows gui?
see:
http://www.saoe.net/blog/778/
How to build x86 and/or x64 on Windows from command line with CMAKE?
cmake -G Ninja on windows specify x64
The only way I have found to do this, is to wipe the output folder, and then it lets you select Visual Studio 10 Win64 when you first configure the cmake project. Make sure you choose the correct item in the dropdown.
You can specify it during the first configure process.
After that, if you want to change the machine type you need to delete the cache with the "Delete Cache" command in the "File" menu and start the configure process again.
This will happen if you run cmake in a x64 Native Tools Command Prompt for VS 2019 for the first time (otherwise delete build folder).

Using cmake with nmake x64

I use cmake to generate a NMake file, everything goes fine.
I use the x64 toolsets (without Visual Studio, only the SDK), so I type nmake, but it generate a x86 build and not a x64 build.
Do you know why ? and how to force nmake to target x64 ?
Thanks
Just to share, use the following to force the x64 platform. Use this command prompt command.
VsDevCmd.bat -host_arch=amd64 -arch=amd64
Both -host_arch and -arch are mandatory !

Generate universal windows platform solution and project files using CMake

I'm trying to generate solution and project files for a static library in universal windows platform using cmake. I gave parameters as specified in the other thread here
But it generated project files with incorrect configs (TargetPlatformVersion = 8.1 and WindowsStoreAppSupport=No). Instead the values should be like TargetPlatformVersion = 10.0.10586.0 or 10.0.10240.0 and WindowsStoreAppSupport = Yes.
I have given parameters as CMAKE_SYSTEM_NAME = WindowsStore and CMAKE_SYSTEM_VERSION = 10.0 and selected the generator to "Visual Studio 14 2015".
Is Universal Windows Platform supported by CMake? If yes, then how do I generate the project files supporting UWP?
Recent versions of CMake support the newer version of Visual Studio and Windows 10 SDK. If you get weird errors, try updating to the lasted CMake version.