使用 msbuild 构建 32 位 fmt

Build 32-bit fmt with msbuild

我正在尝试使用 cmake/msbuild 在 Windows Server 2019 上构建 32 位 fmt(我没有完整的 Visual Studio GUI,我只有命令行构建工具)。我收到此错误:

C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(408,5): error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|Win32.

它可以很好地构建为 64 位,但这不是我所需要的。我认为这是因为 fmt 生成的构建文件没有 32 位的配置 Windows(我认为 Debug 位不重要,它也不适用于 Release 配置)。

我在构建子目录中按照 fmt 说明执行此操作:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_GENERATOR_PLATFORM=x86 ..
cmake --build . --config Release
cmake --install . --prefix <fmtlib_target_dir> --config Release

有没有办法在 Windows 上将 fmt 构建为 32 位?

对于具有 CI 构建的项目,关于如何构建的最佳文档通常是 CI script/configuration 本身;来自 https://github.com/fmtlib/fmt/blob/master/support/appveyor-build.py :

if image == 'Visual Studio 2019':
    generator = 'Visual Studio 16 2019'
    if platform == 'x64':
        cmake_command.extend(['-A', 'x64'])
else:
    if image == 'Visual Studio 2015':
        generator = 'Visual Studio 14 2015'
    elif image == 'Visual Studio 2017':
        generator = 'Visual Studio 15 2017'
    if platform == 'x64':
        generator += ' Win64'
cmake_command.append('-G' + generator)

换句话说:为 32 位构建传递不同的 generator/option,例如 -G "Visual Studio 16 2019" -A Win32