Skip to content

Commit 0db52d2

Browse files
committed
cmake: Use vendored libgit2 by default
Just because build system has libgit2 headers globally, doesn't mean we need to use them by default :/ Use LIBGIT2_USE_VENDORED=OFF to override this and look for installed package.
1 parent 06f6c04 commit 0db52d2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
55
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
66

77
# Add libgit2
8-
find_package(PkgConfig)
9-
if(PkgConfig_FOUND)
10-
PKG_CHECK_MODULES(LIBGIT2 libgit2>=1.4.0)
11-
endif()
12-
if(NOT LIBGIT2_FOUND)
8+
OPTION(LIBGIT2_USE_VENDORED "Use the vendored libgit2, instead of finding the package externally" ON)
9+
if(LIBGIT2_USE_VENDORED)
1310
ADD_SUBDIRECTORY(ext/libgit2 ${CMAKE_BINARY_DIR}/lib)
1411
set(LIBGIT2_INCLUDEDIR ext/libgit2/include)
12+
else()
13+
find_package(PkgConfig)
14+
if(PkgConfig_FOUND)
15+
PKG_CHECK_MODULES(LIBGIT2 libgit2>=1.4.0)
16+
endif()
1517
endif()
1618

1719
INCLUDE(CMakePackageConfigHelpers)

0 commit comments

Comments
 (0)