How to build x86 and/or x64 on Windows from command line with CMAKE?

One way to get cmake to build x86 on Windows with Visual Studio is like so:

  • Start Visual Studio Command prompt for x86
  • Run cmake: cmake -G "NMake Makefiles" path_to_source
  • nmake
  • One way to get cmake to build x64 on Windows with Visual Studio is like so:

  • Start Visual Studio Command prompt for x64
  • Run cmake: cmake -G "NMake Makefiles" path_to_source
  • nmake
  • Using Cmake, how do I compile either or both architectures? (like how Visual Studio does it from in the IDE)


    This cannot be done with CMake. You have to generate two separate build folders. One for the x86 NMake build and one for the x64 NMake build. You cannot generate a single Visual Studio project covering both architectures with CMake either.

    To build Visual Studio projects from the command line for both 32-bit and 64-bit without starting a Visual Studio command prompt, use the regular Visual Studio generators:

    mkdir build32 & pushd build32
    cmake -G "Visual Studio 12 2013" path_to_source
    popd
    mkdir build64 & pushd build64
    cmake -G "Visual Studio 12 2013 Win64" path_to_source
    popd
    cmake --build build32 --config Release
    cmake --build build64 --config Release
    

    CMake generated projects that use one of the Visual Studio generators can be built from the command line with using the option --build followed by the build directory. The --config options specifies the build configuration.

    链接地址: http://www.djcxy.com/p/66310.html

    上一篇: x86和x64上pow的不同结果

    下一篇: 如何使用CMAKE从命令行在Windows上构建x86和/或x64?