/MP on all files but pre_compiled_header

We have switched to using target_precompile_headers() and since we did this we’ve been getting the following warning in MSBuild based builds:

cl : command line warning D9030: ‘/Yc’ is incompatible with multiprocessing; ignoring /MP switch

our main cmake script contains
if(MSVC)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} /MP”)
endif()

So the “/MP” is added on purpose - as it’s absolutely impossible to build without it (large code base and we have high-end workstations with minimum 18-cores - parallelbuild is essential for a realistic build-time).

I’d like to disable the /MP on my precompiled header to get rid of this warning (we don’t like warnings).

My first attempt was to just ignore it with /wd9030 but that didn’t work as this is not a compiler warning but a compiler invocation warning no idea how to disable those.

Would there be a way to fix the precompiled header files CXX_FLAGS?

Try adding:

if(MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
    list(APPEND CMAKE_CXX_COMPILE_OPTIONS_CREATE_PCH /wd9030)
endif()