Search code examples
msbuild32-bitfmt

Build 32-bit fmt with msbuild


I am trying to build a 32-bit fmt on Windows Server 2019 using cmake/msbuild (I don't have the full Visual Studio GUI, I only have the command line build tools). I get this error:

C:\Program Files (x86)\Microsoft Visual Studio\2019\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.

It builds fine as 64-bit, but that isn't what I need. I assume that's because the build files generated by fmt don't have a configuration for 32-bit Windows (I don't think the Debug bit matters, it doesn't work with Release configuration either).

I'm doing this in the build subdirectory, per the fmt instructions:

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

Is there a way to build fmt on Windows as 32-bit?


Solution

  • For projects which have CI builds the best documentation on how to build is usually the CI script/configuration itself; from 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)
    

    in other words: pass a different generator/option for 32bit builds like -G "Visual Studio 16 2019" -A Win32.