External Include on MSVC


I found that cmake seems to support -external:I since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4766.

I have something something like this in my project:

get_property(date_include_dirs TARGET date PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET date PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${date_include_dirs}")

To make third party libs via fetch Content System Includes.

On MSVC this still leads to:


while on CLang / GCC it correctly leads to:

-isystem /home/leon/Projects/beans/build/_deps/date-src/include

Why is it not using -external:I on MSVC? Isn’t this what above mentioned Merge Request did implement or do I miss something?

Are you using a new enough MSVC compiler? It is only enabled for a toolchain that was released a few months ago.

Additionally, it is only supported with the Makefiles and Ninja generator as Visual Studio generation seems quite a bit more involved and I didn’t have the time to do that as well.

Oh yes it’s with the Visual Studio Generator. Is there any workaround?

No, the XML elements that are needed in the .vcxproj need to be generated at the right place and that code has not yet been written.