How to specify target platform for CMake? For instance x86, x64, amd64.
I've tried set TARGET_CPU=x64
but not sure does it works or not.
A CMake-based buildsystem is organized as a set of high-level logical targets. Each target corresponds to an executable or library, or is a custom target containing custom commands.
Use its -G option to specify the generator for a new build tree. The cmake-gui(1) offers interactive selection of a generator when creating a new build tree.
CMake needs a way to determine which compiler to use to invoke the linker. This is determined by the LANGUAGE property of source files of the target , and in the case of static libraries, the LANGUAGE of the dependent libraries.
Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.
When calling the cmake
command you can define a generator for instance Visual Studio 14 2015 Win64 which results in the target platform x64
cmake -G"Visual Studio 14 2015 Win64" -H%SOURCE_ROOT_DIR% -BC:\build\vs2015\x64\MyProject
If you like to build for x86 on Windows with VS2015 - you would go this way:
cmake -G"Visual Studio 14 2015" -H%SOURCE_ROOT_DIR% -BC:\build\vs2015\x64\MyProject
ARM:
cmake -G"Visual Studio 14 2015 ARM" -H%SOURCE_ROOT_DIR% -BC:\build\vs2015\x64\MyProject
Depending on your problem maybe a CMake toolchain file can help you.
A little update for Cmake 3.17 and Visual Studio 2019.
In this case, even if you specify genertator with -G, you have to use -A option with either Win32 or Win64.
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