declare imported targets as system to suppress warnings

Normally to suppress warnings in a third party library, I would use something like:

target_include_directories(my_target
    SYSTEM
    PUBLIC
    ${EIGEN3_INCLUDE_DIR}
)

however the SYSTEM option doesn’t work with target_link_libraries:

target_link_libraries(my_target
    SYSTEM
    PUBLIC
    Eigen3::Eigen
)

I found this solution

on stackoverflow, but it still seems hacky. It there a better way to suppress warnings for third party libs? (Eigen doesn’t actually emit any warnings, it was just the first example I could find in my code)

My initial thoughts mirror the solution that Sebastian posted on Stackoverflow.
A possible ‘cleaner’ approach would be a function that moves the contents of INTERFACE_INCLUDE_DIRECTORIES to INTERFACE_SYSTEM_INCLUDE_DIRECTORIES.

Currently, CMake expects the library author not the consumer to set the which include directories should be considered SYSTEM.

IMPORTED targets should already have their include directories treated as SYSTEM though. There is the NO_SYSTEM_FROM_IMPORTED target property to disable it.