This repository was archived by the owner on Jan 19, 2021. It is now read-only.
File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,14 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
5
5
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
6
6
7
7
# Add libgit2
8
- ADD_SUBDIRECTORY (ext /libgit2 ${CMAKE_BINARY_DIR} /lib)
8
+ find_package (PkgConfig)
9
+ if (PkgConfig_FOUND)
10
+ PKG_CHECK_MODULES(LIBGIT2 libgit2>=0.99)
11
+ endif ()
12
+ if (NOT LIBGIT2_FOUND)
13
+ ADD_SUBDIRECTORY (ext /libgit2 ${CMAKE_BINARY_DIR} /lib)
14
+ set (LIBGIT2_INCLUDEDIR ext /libgit2/include )
15
+ endif ()
9
16
10
17
INCLUDE (CMakePackageConfigHelpers)
11
18
@@ -20,7 +27,7 @@ SET(CPPGIT2_VERSION_STRING "${CPPGIT2_VERSION_MAJOR}.${CPPGIT2_VERSION_MINOR}.${
20
27
21
28
# Build object library
22
29
ADD_LIBRARY (CPPGIT2_OBJECT_LIBRARY OBJECT ${CPPGIT2_SOURCES} )
23
- INCLUDE_DIRECTORIES ("include" "ext/libgit2/include " "test" )
30
+ INCLUDE_DIRECTORIES ("include" "${LIBGIT2_INCLUDEDIR} " "test" )
24
31
SET_PROPERTY (TARGET CPPGIT2_OBJECT_LIBRARY PROPERTY CXX_STANDARD 11)
25
32
26
33
# Shared libraries need PIC
@@ -42,7 +49,8 @@ TARGET_LINK_LIBRARIES(CPPGIT2_STATIC git2)
42
49
43
50
# Copy include directories to build/include
44
51
FILE (COPY "include" DESTINATION "${CMAKE_BINARY_DIR} /." )
45
- FILE (COPY "ext/libgit2/include" DESTINATION "${CMAKE_BINARY_DIR} /." )
52
+ FILE (COPY "${LIBGIT2_INCLUDEDIR} /git2" DESTINATION "${CMAKE_BINARY_DIR} /include" )
53
+ FILE (COPY "${LIBGIT2_INCLUDEDIR} /git2.h" DESTINATION "${CMAKE_BINARY_DIR} /include" )
46
54
47
55
# Build samples
48
56
FILE (GLOB SAMPLES "samples/*.cpp" )
You can’t perform that action at this time.
0 commit comments