summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-09-19 05:38:56 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2022-09-19 06:34:51 -0400
commitc11724686c145e8074d46b2289e2a857613ea4a2 (patch)
tree5bb93ce4e334fb9b9043468cd7a477a65a96b80c
parentc8d5b43bbcf0bb04d0d20602248c0eb905b2c81f (diff)
downloadlibgit2-c11724686c145e8074d46b2289e2a857613ea4a2.tar.gz
cmake: provide empty experimental.h for non-cmake users
Not everybody builds libgit2 using cmake; provide an `experimental.h` with no experiments configured for those that do not. To support this, we also now create compile definitions for experimental functionality, to supplant that empty `experimental.h`. cmake will continue to generate the proper `experimental.h` file for use with `make install`.
-rw-r--r--cmake/ExperimentalFeatures.cmake11
-rw-r--r--include/git2/experimental.h20
-rw-r--r--src/libgit2/experimental.h.in7
3 files changed, 38 insertions, 0 deletions
diff --git a/cmake/ExperimentalFeatures.cmake b/cmake/ExperimentalFeatures.cmake
index f23bfe376..57a66e68d 100644
--- a/cmake/ExperimentalFeatures.cmake
+++ b/cmake/ExperimentalFeatures.cmake
@@ -1,8 +1,19 @@
+# Experimental feature support for libgit2 - developers can opt in to
+# experimental functionality, like sha256 support. When experimental
+# functionality is enabled, we set both a cmake flag *and* a compile
+# definition. The cmake flag is used to generate `experimental.h`,
+# which will be installed by a `make install`. But the compile definition
+# is used by the libgit2 sources to detect the functionality at library
+# build time. This allows us to have an in-tree `experimental.h` with
+# *no* experiments enabled. This lets us support users who build without
+# cmake and cannot generate the `experimental.h` file.
+
if(EXPERIMENTAL_SHA256)
add_feature_info("SHA256 API" ON "experimental SHA256 APIs")
set(EXPERIMENTAL 1)
set(GIT_EXPERIMENTAL_SHA256 1)
+ add_compile_definitions(GIT_EXPERIMENTAL_SHA256)
else()
add_feature_info("SHA256 API" OFF "experimental SHA256 APIs")
endif()
diff --git a/include/git2/experimental.h b/include/git2/experimental.h
new file mode 100644
index 000000000..06435f9a7
--- /dev/null
+++ b/include/git2/experimental.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_experimental_h__
+#define INCLUDE_experimental_h__
+
+/*
+ * This file exists to support users who build libgit2 with a bespoke
+ * build system and do not use our cmake configuration. Normally, cmake
+ * will create `experimental.h` from the `experimental.h.in` file and
+ * will include the generated file instead of this one. For non-cmake
+ * users, we bundle this `experimental.h` file which will be used
+ * instead.
+ */
+
+#endif
diff --git a/src/libgit2/experimental.h.in b/src/libgit2/experimental.h.in
index 3d6e931e2..25fb14b9d 100644
--- a/src/libgit2/experimental.h.in
+++ b/src/libgit2/experimental.h.in
@@ -1,3 +1,10 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
#ifndef INCLUDE_experimental_h__
#define INCLUDE_experimental_h__