I would like to offer a way that always builds my target as a 32-bit or always as 64-bit executable executable with cmake independent of the host system (Adding the "-m32" or "-m64" flag for gcc, not sure yet what to do for other compilers).
I can think of three ways to do this, which one should I use?
In my case the forced 32-bit build will be the default and should be easy to use. A forced 64-bit build is the also useful for some cases and should not be too difficult. Using the bit width of the host system rarely makes sense for my case and I don't want to support it.
I found a related question here (The proper way of forcing a 32-bit compile using CMake) but the answers mostly discuss how it can be done at all, not how best to make it configurable.
For Visual Studio and per https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_PLATFORM.html
For Visual Studio Generators with VS 2005 and above this specifies the target architecture.
cmake . -DCMAKE_GENERATOR_PLATFORM=x64