How to add option to the compiler?

I want to build a project uisng cmake+qt6.

My CMakeLists.txt is:

cmake_minimum_required(VERSION 3.15)
project(qt_cmake)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6Core REQUIRED)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Gui REQUIRED)


add_executable(qt_cmake main.cpp)
target_link_libraries(qt_cmake
	Qt6::Core
	Qt6::Gui
	Qt6::Widgets
)

After building, my vs reports:

D:\Qt6\6.3.1\mingw_64\include\QtCore/qglobal.h(141,1): fatal error C1189: #error:  "Qt requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler."

I can add /Zc:__cplusplus to vs by: property–>C/C+±->command.
But, how can I add /Zc:__cplusplus to compiler using cmake?

try adding the flag it says you need as a compile option.

target_compile_options(qt_cmake PUBLIC "/Zc:__cplusplus")

Here is a stack overflow post that looks relevant c++ - Cannot set __cplusplus to C++17 standard with Visual Studio and CMake - Stack Overflow

First, I suggest using the right build of Qt6 for VS2019 or later. Maybe they already cater for this then.

Else, use

if (MSVC)
  target_compile_options(...)
elseif ()

@TripRichert Thank you for your kindly reply.
target_compile_options(qt_cmake PUBLIC "/Zc:__cplusplus") works for me.