Merge pull request #716 from scottjg/examples-cleanup Build fixes for examples/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/.travis.yml b/.travis.yml
index b9a08dc..11c85bb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@ language: erlang
# Settings to try
env:
- OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release"
- - OPTIONS="-DBUILD_CLAR=ON"
+ - OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=ON"
# Make sure CMake is installed
install:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bfbabc0..165baba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,7 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON)
+OPTION (BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION (TAGS "Generate tags" OFF)
OPTION (PROFILE "Generate profiling information" OFF)
@@ -183,3 +184,18 @@ IF (TAGS)
DEPENDS tags
)
ENDIF ()
+
+IF (BUILD_EXAMPLES)
+ FILE(GLOB_RECURSE EXAMPLE_SRC examples/network/*.c)
+ ADD_EXECUTABLE(cgit2 ${EXAMPLE_SRC})
+ TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
+
+ ADD_EXECUTABLE(git-diff examples/diff.c)
+ TARGET_LINK_LIBRARIES(git-diff git2)
+
+ ADD_EXECUTABLE(git-general examples/general.c)
+ TARGET_LINK_LIBRARIES(git-general git2)
+
+ ADD_EXECUTABLE(git-showindex examples/showindex.c)
+ TARGET_LINK_LIBRARIES(git-showindex git2)
+ENDIF ()
diff --git a/examples/general.c b/examples/general.c
index 4585a4a..5269785 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -392,7 +392,7 @@ int main (int argc, char** argv)
// Here we will implement something like `git for-each-ref` simply listing out all available
// references and the object SHA they resolve to.
git_strarray ref_list;
- git_reference_listall(&ref_list, repo, GIT_REF_LISTALL);
+ git_reference_list(&ref_list, repo, GIT_REF_LISTALL);
const char *refname;
git_reference *ref;