diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-07-01 13:06:00 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-08-16 07:12:38 +0200 |
commit | a390a8464e720365271238d80586d2b6c6ac3780 (patch) | |
tree | 78fe8c1777d6f56b8488c610574cce47c8d04e7f /src/features.h.in | |
parent | 35087f0eeff10efaf2304fa0772e9836a9fd9fc7 (diff) | |
download | libgit2-a390a8464e720365271238d80586d2b6c6ac3780.tar.gz |
cmake: move defines into "features.h" header
In a future commit, we will split out the build instructions for our
library directory and move them into a subdirectory. One of the benefits
is fixing scoping issues, where e.g. defines do not leak to build
targets where they do not belong to. But unfortunately, this does also
pose the problem of how to propagate some defines which are required by
both the library and the test suite.
One way would be to create another variable keeping track of all added
defines and declare it inside of the parent scope. While this is the
most obvious and simplest way of going ahead, it is kind of unfortunate.
The main reason to not use this is that these defines become implicit
dependencies between the build targets. By simply observing a define
inside of the CMakeLists.txt file, one cannot reason whether this define
is only required by the current target or whether it is required by
different targets, as well.
Another approach would be to use an internal header file keeping track
of all defines shared between targets. While configuring the library, we
will set various variables and let CMake configure the file, adding or
removing defines based on what has been configured. Like this, one can
easily keep track of the current environment by simply inspecting the
header file. Furthermore, these dependencies are becoming clear inside
the CMakeLists.txt, as instead of simply adding a define, we now call
e.g. `SET(GIT_THREADSAFE 1)`.
Having this header file though requires us to make sure it is always
included before any "#ifdef"-preprocessor checks are executed. As we
have already refactored code to always include the "common.h" header
file before any statement inside of a file, this becomes easy: just make
sure "common.h" includes the new "features.h" header file first.
Diffstat (limited to 'src/features.h.in')
-rw-r--r-- | src/features.h.in | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/features.h.in b/src/features.h.in new file mode 100644 index 000000000..c3fcc5170 --- /dev/null +++ b/src/features.h.in @@ -0,0 +1,34 @@ +#ifndef INCLUDE_features_h__ +#define INCLUDE_features_h__ + +#cmakedefine GIT_DEBUG_POOL 1 +#cmakedefine GIT_TRACE 1 +#cmakedefine GIT_THREADS 1 +#cmakedefine GIT_MSVC_CRTDBG 1 + +#cmakedefine GIT_ARCH_64 1 +#cmakedefine GIT_ARCH_32 1 + +#cmakedefine GIT_USE_ICONV 1 +#cmakedefine GIT_USE_NSEC 1 +#cmakedefine GIT_USE_STAT_MTIM 1 +#cmakedefine GIT_USE_STAT_MTIMESPEC 1 +#cmakedefine GIT_USE_STAT_MTIME_NSEC 1 + +#cmakedefine GIT_SSH 1 +#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1 + +#cmakedefine GIT_GSSAPI 1 +#cmakedefine GIT_WINHTTP 1 +#cmakedefine GIT_CURL 1 + +#cmakedefine GIT_HTTPS 1 +#cmakedefine GIT_OPENSSL 1 +#cmakedefine GIT_SECURE_TRANSPORT 1 + +#cmakedefine GIT_SHA1_COLLISIONDETECT 1 +#cmakedefine GIT_SHA1_WIN32 1 +#cmakedefine GIT_SHA1_COMMON_CRYPTO 1 +#cmakedefine GIT_SHA1_OPENSSL 1 + +#endif |