target_include_directory SYSTEM fails with Xcode

Hi – Attempting to include a portion of code as a “system” header group fails in Xcode:

The library:

file(GLOB_RECURSE 
  Sources 
    ${CMAKE_CURRENT_LIST_DIR}/*.cpp 
    ${CMAKE_CURRENT_LIST_DIR}/*.c 
    ${CMAKE_CURRENT_LIST_DIR}/*.h)

source_group(TREE 
  ${CMAKE_CURRENT_LIST_DIR} 
    FILES 
      ${Sources})

add_library(Externals 
  STATIC 
    ${Sources})

# SILENCE WARNINGS FOR THESE FILES
target_compile_options(Externals PRIVATE -w)

# PUBLIC INCLUDE DIRECTORIES AS SYSTEM (SUPPRESS WARNINGS)
file(GLOB_RECURSE sources_list LIST_DIRECTORIES true ${CMAKE_CURRENT_LIST_DIR}/*)
foreach(dir ${sources_list})
  IF(IS_DIRECTORY ${dir})
    target_include_directories(Externals PUBLIC SYSTEM ${dir})
  ELSE()
      CONTINUE()
  ENDIF()
endforeach()

However anytime a file includes a header from this library – warning flags are triggered.

Is there a better way?

Thanks,

J

gentle bump – it appears the SYSTEM keyboard does not work with Xcode

Nevermind…

target_include_directories(Externals PUBLIC SYSTEM ${dir})

target_include_directories(Externals SYSTEM PUBLIC ${dir})