Skip to content

Commit 26f531d

Browse files
committed
features.h: allow building without CMake-generated feature header
In commit a390a84 (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.
1 parent 5b947b6 commit 26f531d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#ifndef INCLUDE_common_h__
88
#define INCLUDE_common_h__
99

10-
#include "git2/sys/features.h"
10+
#ifndef LIBGIT2_NO_FEATURES_H
11+
# include "git2/sys/features.h"
12+
#endif
13+
1114
#include "git2/common.h"
1215
#include "cc-compat.h"
1316

src/unix/posix.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#ifndef INCLUDE_posix__unix_h__
88
#define INCLUDE_posix__unix_h__
99

10-
#include "git2/sys/features.h"
10+
#ifndef LIBGIT2_NO_FEATURES_H
11+
# include "git2/sys/features.h"
12+
#endif
13+
1114
#include <stdio.h>
1215
#include <dirent.h>
1316
#include <sys/param.h>

0 commit comments

Comments
 (0)