diff options
| author | Patrick Steinhardt <ps@pks.im> | 2018-06-25 14:12:53 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2018-07-13 08:25:12 +0200 |
| commit | c13e56f91c3a15dd47b9543984e763ab74270aa9 (patch) | |
| tree | 4765de141dda855983855e041b96dde3504a8d52 /examples | |
| parent | 9994cd3f0ffcd7b28d26c82ecb6564bc4072dc2a (diff) | |
| download | libgit2-c13e56f91c3a15dd47b9543984e763ab74270aa9.tar.gz | |
cmake: distinguish internal and system include directories
While we want to enforce strict C90 mode, this may cause issues with
system provided header files which are themselves not strictly
conforming. E.g. if a system header has C++ style comments, a compiler
in strict C90 mode would produce an error and abort the build. As the
user most likely doesn't want to change the system header, this would
completely break the build on such systems. One example of this is
mbedtls, which provides such header files.
The problem can be worked around by distinguishing between
system-provided and project-provided include directories. When adding
include directories via "-isystem" instead of "-I", the compiler will
skip certain checks and print out less warnings. To use system includes,
we can simply add the "SYSTEM" flag to CMake's `INCLUDE_DIRECTORIES` and
`TARGET_INCLUDE_DIRECTORIES` functions. Note that we have to split the
include directories into two variables because of this, as we definitely
still want to check for all warnings produced by our own header files.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ca7515e5d..d4dca5a31 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,5 @@ INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) +INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES}) FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c network/*.h common.?) ADD_EXECUTABLE(cgit2 ${SRC_EXAMPLE_GIT2}) |
