what to write in cmakelists.txt to force build 64 bit exe

发布时间 2023-03-23 22:52:08作者: SpacetimeCoding

To force a 64-bit build in CMake, you can add the following lines to your CMakeLists.txt file:

set(CMAKE_GENERATOR_PLATFORM x64)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.01 /MACHINE:X64")

The first line sets the generator platform to x64, which tells CMake to generate 64-bit build files. The second line sets the linker flags for the executable, which sets the subsystem to windows and specifies the machine type as x64.