Build both static and shared libraries

This commit is contained in:
Russell Sim 2012-05-21 22:13:29 +10:00
parent d2adea23dd
commit d2f0d0f4e3
4 changed files with 41 additions and 1 deletions

2
debian/changelog vendored
View File

@ -1,6 +1,8 @@
libgit2 (0.17.0-1) UNRELEASED; urgency=low
* New Upstream Release.
* Patch added that enables building as both static and dynamic
library.
-- Russell Sim <russell.sim@gmail.com> Sun, 20 May 2012 21:34:12 +1000

View File

@ -1,3 +1,4 @@
/usr/include
/usr/lib/lib*.a
/usr/lib/lib*.so
/usr/lib/pkgconfig

37
debian/patches/build_static.patch vendored Normal file
View File

@ -0,0 +1,37 @@
Build both static and shared libraries.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bfbabc0..891d2af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,7 +49,6 @@ SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options
-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 (TAGS "Generate tags" OFF)
@@ -110,7 +109,8 @@ ELSE()
ENDIF ()
# Compile and link libgit2
-ADD_LIBRARY(git2 ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC})
+ADD_LIBRARY(git2 SHARED ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC})
+ADD_LIBRARY(git2static STATIC ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC})
IF (WIN32)
TARGET_LINK_LIBRARIES(git2 ws2_32)
@@ -120,11 +120,12 @@ ENDIF ()
TARGET_LINK_LIBRARIES(git2 ${CMAKE_THREAD_LIBS_INIT})
SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
+SET_TARGET_PROPERTIES(git2static PROPERTIES OUTPUT_NAME git2)
SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_VERSION_MAJOR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libgit2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc @ONLY)
# Install
-INSTALL(TARGETS git2
+INSTALL(TARGETS git2 git2static
RUNTIME DESTINATION ${INSTALL_BIN}
LIBRARY DESTINATION ${INSTALL_LIB}
ARCHIVE DESTINATION ${INSTALL_LIB}

View File

@ -1 +1 @@
build_static.patch