diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-09-12 13:35:18 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-09-12 13:46:42 +0200 |
commit | 26f531d3a3c00890348660f826df4fd21e53f9c9 (patch) | |
tree | 12e0e6b106735d497d9d13c8a402a6f256ff1b9b | |
parent | 5b947b62970dc2adeb65fd875b1dc02e8f1b3579 (diff) | |
download | libgit2-26f531d3a3c00890348660f826df4fd21e53f9c9.tar.gz |
features.h: allow building without CMake-generated feature header
In commit a390a8464 (cmake: move defines into "features.h" header,
2017-07-01), we have introduced a new "features.h" header. This file is
being generated by the CMake build system based on how the libgit2 build
has been configured, replacing the preexisting method of simply setting
the defines inside of the CMake build system. This was done to help
splitting up the build instructions into multiple separate
subdirectories.
An overlooked shortcoming of this approach is that some projects making
use of libgit2 build the library with custom build systems, without
making use of CMake. For those users, the introduction of the
"features.h" file makes their life harder as they would have to also
generate this file.
Fix this issue by guarding all inclusions of the generated header file
by the `LIBGIT2_NO_FEATURES_H` define. Like this, other build systems
can skip the feature header and simply define all used features by
specifying `-D` flags for the compiler again.
-rw-r--r-- | src/common.h | 5 | ||||
-rw-r--r-- | src/unix/posix.h | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/common.h b/src/common.h index 17b9c14e5..d3622d3eb 100644 --- a/src/common.h +++ b/src/common.h @@ -7,7 +7,10 @@ #ifndef INCLUDE_common_h__ #define INCLUDE_common_h__ -#include "git2/sys/features.h" +#ifndef LIBGIT2_NO_FEATURES_H +# include "git2/sys/features.h" +#endif + #include "git2/common.h" #include "cc-compat.h" diff --git a/src/unix/posix.h b/src/unix/posix.h index bfabd1707..ee36ea0f3 100644 --- a/src/unix/posix.h +++ b/src/unix/posix.h @@ -7,7 +7,10 @@ #ifndef INCLUDE_posix__unix_h__ #define INCLUDE_posix__unix_h__ -#include "git2/sys/features.h" +#ifndef LIBGIT2_NO_FEATURES_H +# include "git2/sys/features.h" +#endif + #include <stdio.h> #include <dirent.h> #include <sys/param.h> |