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()
This example worked for me on cmake 3.17.0:
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64") .... endif() if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32") ... endif()