In CLion, how can I set the Visual Studio build architecture in the CMakeLists.txt file ?
According to cmake.org, one can set host=x64 in the CMAKE_GENERATOR_TOOLSET option.
The Visual Studio Generators for VS 2013 and above support using either the 32-bit or 64-bit host toolchains by specifying a host=x86 or host=x64 value in the CMAKE_GENERATOR_TOOLSET option. CMake provides the selected toolchain architecture preference in this variable (x86, x64, or empty).
But whatever I do, it has no effect when I click on run in CLion.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(native_data_types)
set(CMAKE_CXX_STANDARD 14)
# http://www.saoe.net/blog/generating-64-bit-projects-for-visual-studio-with-cmake/
# https://cmake.org/cmake/help/latest/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.html
# How to set this ?
# set(host "x64")
# set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
# set(CMAKE_GENERATOR_TOOLSET "host=x64")
# set (native_data_types_ARCHITECTURE "x64")
# set(BUILD_ARCH "-m64")
# set(BUILD_ARCH "-m32")
# set(CMAKE_C_FLAGS -m32)
# set(CMAKE_CXX_FLAGS -m32)
# set(CMAKE_C_FLAGS -m64)
# set(CMAKE_CXX_FLAGS -m64)
add_executable(native_data_types main.cpp)
What I can do is set an additional toolchain in the CLion settings, and set the desired toolchain as the default toolchain, but the encompassing slowness is absolutely horrid and not what I want.
I want to set the executable architecture in the CMakeLists.txt file, so I can quickly switch, in a second.
For example, on Linux, where I use gcc, I can just set either
set(CMAKE_C_FLAGS -m32)
or
set(CMAKE_CXX_FLAGS -m32)
But unfortunately, the Visual-Studio-Compiler seems to not have such an option...
x64
(insteadamd64
) but I typed it manually and worked fine. – Hutton