FetchContent_Declare SYSTEM property for hierarchical dependencies


We’re currently using the SYSTEM property to ignore warnings for imported libraries (lets call them B,C,…) (via FetchContent) into a library A.
This works very well, but when we are then consume library A in another project (also via FetchContent) the SYSTEM property is no longer working for the indirectly imported targets (B,C,…) , so the warnings appear again.

Is this intended? Or how can I consume library A using fetch_content and prevent the warnings in the header files of B,C at this point?

    GIT_TAG         ...
    SYSTEM #This still shows the warnings from libB,libC which are dependencies of libA

P.S. I’m using CMake 3.27.6

Can you provide a complete, minimal pair of projects which demonstrate this? I can’t think of a reason why FetchContent would do that when used in the expected way, so I suspect there’s something about the way you’re using it which is causing the behavior you’re observing.

Hi Craig,

Sorry for this taking a while. Basically https://github.com/psyinf/cmake_min_consumer_app.git and the minimal dependencies show what I suspect to be a misunderstanding of how the SYSTEM property is used. The minimal app includes the minConsumingLib which fetches the minLib. When I compile the App with SYSTEM set to the FetchDeclare of the minConsumingLib i still see warnings regarding the minLib headers.


Thanks Sebastian, I can reproduce your problem. This isn’t actually a FetchContent issue. I’m able to reproduce the same problem without it. I’m currently reducing the project down to something minimal to narrow down the cause. Once I manage that, I’ll open a bug report and link back to here.

Issue opened here: https://gitlab.kitware.com/cmake/cmake/-/issues/25364