CMake: target_link_libraries include as SYSTEM to suppress compiler warnings
I defined a function to handle this for me: function(target_link_libraries_system target) set(libs ${ARGN}) foreach(lib ${libs}) get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES) target_include_directories(${target} SYSTEM PRIVATE ${lib_include_dirs}) target_link_libraries(${target} ${lib}) endforeach(lib) endfunction(target_link_libraries_system) I can now call target_link_libraries_system(myapp lib::lib) and the include directories are read from the target’s properties. This can be extended to optionally specify the PUBLIC|PRIVATE|INTERFACE scope: function(target_link_libraries_system target) set(options … Read more