I have a project which uses cmake, one target is set to only build with MSVC:
if (MSVC)
add_library(test SHARED source.cpp)
endif()
On recent versions of CMake/Visual Studio the bitness is selected with CMAKE_GENERATOR_PLATFORM, which can be specified on the command line with -A option:
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_BUILD_TYPE=Release ..
So, based on this feature you can then query the value from within the CMakeLists.txt:
if(NOT ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win64"))
...
ENDIF()