0

I would like to get CMake generate Visual Studio projects in a way that PreferredToolArchitecture is set to x64, so that when building in Visual Studio, x64 compiler and linker are used. The VS project file PropertyGroup for a configuration should have the PreferredToolArchitecture XML element according to this answer, e.g. as below

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <CharacterSet>MultiByte</CharacterSet>
    <PlatformToolset>v140</PlatformToolset>
    <PreferredToolArchitecture>x64</PreferredToolArchitecture>
  </PropertyGroup>

CMake doc indicate that passing -Tv140,host=x64 to the cmake command line should choose the x64 compiler.

However I do not see the PreferredToolArchitecture XML element in the generated project files.

Paul
  • 2,474
  • 7
  • 33
  • 48
  • Have you tried [CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE](https://cmake.org/cmake/help/latest/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.html) variable instead? According to the docs, it is somewhat about preference. – Tsyvarev Oct 18 '21 at 12:56
  • I understand that is a readonly variable. – Paul Oct 18 '21 at 13:10

0 Answers0