CMake: `glfw/include` dirictory propagates not as SYSTEM include
Challanger524 opened this issue · 3 comments
Program build results in next include paths:
cl.exe /TP -IC:\<projpath>\src -IC:\<projpath>\deps\glfw\include -external:IC:\<projpath>\deps ...
-IC:\<projpath>\deps\glfw\include
- not a system include (-I
while must be -external:I
)
Consider using target_include_directories(glfw SYSTEM PUBLIC **/include)
Lines 132 to 134 in bf945f1
Add
SYSTEM
: glfw PUBLIC
-> glfw SYSTEM PUBLIC
:https://stackoverflow.com/a/61797712/11753532
The one more caveat is a need to conditionalize SYSTEM
apply, so internal tests and/or examples builds will keep produce warnings
Looks like more of a CMake-wide issue coz every library is being setup this way.
Workaround is to add same or rooted include like:
fullpath: ${CMAKE_SOURCE_DIR}/deps/glfw/include
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE
"${CMAKE_SOURCE_DIR}/deps" # all upper dirs will be treated as SYSTEM, even if opposite stated explicitly (with: -I)
)
If you install glfw in a particular directory and add the prefix to your other project, you'll get system headers by default for any library. CMake solved this but only for find_package
.