I am using CMake on Windows with Ninja generator
cmake -G Ninja ..
This uses the default Windows x86 toolchain. How to specify x64 using the Ninja generator?
PS: I know how to generate x64 with Visual Studio
cmake -G "Visual Studio 12 2013 Win64 ..
You have to set the compiler environment accordingly before calling Ninja
generation. If you have Visual Studio 2013 installed at the standard installation path you call:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 cmake.exe -G "Ninja" ..
Edit: Thanks for the hint from @Antwane: "Or simply run CMake command from a Microsoft Visual Studio Command Prompt (x64)
. A shortcut to this prompt is located in Start Menu".
The naming varies over the Visual Studio versions:
When I then look into the generated CMakeCache.txt
file I see:
... //CXX compiler CMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe ... //Flags used by the linker. CMAKE_EXE_LINKER_FLAGS:STRING= /machine:x64 ... //Path to a program. CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/link.exe ...
When I tried to run cmake on command line in Windows, trying to use Ninja and targetting the Visual Studio 14.0 compiler (2015), it kept picking up on other installed compilers (in my case gcc) instead.
The following command line worked:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=140 ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With