summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlosmn@github.com>2017-09-28 18:28:37 +0200
committerGitHub <noreply@github.com>2017-09-28 18:28:37 +0200
commitc7c5f2c4ecc727ac555f51bd20353f7f3ae9c07a (patch)
treeda60ff15fb0917208c1d7798c7d5a2fdd589de54
parent524c1d3c9eef1f63d058ca5d4a61af7d5588ebfb (diff)
parent366f4136ec50888d2d52316dc07d775a71bed97e (diff)
downloadlibgit2-c7c5f2c4ecc727ac555f51bd20353f7f3ae9c07a.tar.gz
Merge pull request #4339 from pks-t/pks/static-linking
Static linking for bundled deps
-rw-r--r--.travis.yml4
-rw-r--r--CMakeLists.txt2
-rw-r--r--deps/http-parser/CMakeLists.txt2
-rw-r--r--deps/regex/CMakeLists.txt2
-rw-r--r--deps/zlib/CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt34
-rw-r--r--tests/CMakeLists.txt6
7 files changed, 24 insertions, 28 deletions
diff --git a/.travis.yml b/.travis.yml
index 8bbcb3929..08289aaca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,10 +31,6 @@ matrix:
compiler: gcc
include:
- compiler: gcc
- env: PRECISE=1
- os: linux
- dist: precise
- - compiler: gcc
env: COVERITY=1
os: linux
dist: trusty
diff --git a/CMakeLists.txt b/CMakeLists.txt
index af4c34e3e..3f360e2af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@
# > cmake --build . --target install
PROJECT(libgit2 C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
CMAKE_POLICY(SET CMP0015 NEW)
IF (CMAKE_VERSION VERSION_GREATER 3.0)
CMAKE_POLICY(SET CMP0051 NEW)
diff --git a/deps/http-parser/CMakeLists.txt b/deps/http-parser/CMakeLists.txt
index 9309841db..77d9de7a3 100644
--- a/deps/http-parser/CMakeLists.txt
+++ b/deps/http-parser/CMakeLists.txt
@@ -1,3 +1,3 @@
FILE(GLOB SRC_HTTP "*.c" "*.h")
-ADD_LIBRARY(http-parser STATIC ${SRC_HTTP})
+ADD_LIBRARY(http-parser OBJECT ${SRC_HTTP})
diff --git a/deps/regex/CMakeLists.txt b/deps/regex/CMakeLists.txt
index 6ef8a270f..141b54c4c 100644
--- a/deps/regex/CMakeLists.txt
+++ b/deps/regex/CMakeLists.txt
@@ -1,2 +1,2 @@
INCLUDE_DIRECTORIES(".")
-ADD_LIBRARY(regex STATIC "regex.c" "regex.h")
+ADD_LIBRARY(regex OBJECT "regex.c" "regex.h")
diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt
index ca50d80c4..b0cb7f7ea 100644
--- a/deps/zlib/CMakeLists.txt
+++ b/deps/zlib/CMakeLists.txt
@@ -1,4 +1,4 @@
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
FILE(GLOB SRC_ZLIB "*.c" "*.h")
INCLUDE_DIRECTORIES(".")
-ADD_LIBRARY(zlib STATIC ${SRC_ZLIB})
+ADD_LIBRARY(zlib OBJECT ${SRC_ZLIB})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3392a4218..daecc5a84 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,6 +2,8 @@ IF(DEBUG_POOL)
SET(GIT_DEBUG_POOL 1)
ENDIF()
+SET(LIBGIT2_OBJECTS "")
+
# This variable will contain the libraries we need to put into
# libgit2.pc's Requires.private. That is, what we're linking to or
# what someone who's statically linking us needs to link to.
@@ -181,7 +183,7 @@ ENDIF()
IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/deps/regex" "${CMAKE_BINARY_DIR}/deps/regex")
LIST(APPEND LIBGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/regex")
- LIST(APPEND LIBGIT2_LIBS regex)
+ LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:regex>)
ENDIF()
# Optional external dependency: http-parser
@@ -194,7 +196,7 @@ ELSE()
MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/deps/http-parser" "${CMAKE_BINARY_DIR}/deps/http-parser")
LIST(APPEND LIBGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/http-parser")
- LIST(APPEND LIBGIT2_LIBS http-parser)
+ LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
ENDIF()
# Optional external dependency: zlib
@@ -212,7 +214,7 @@ ELSE()
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/deps/zlib" "${CMAKE_BINARY_DIR}/deps/zlib")
LIST(APPEND LIBGIT2_INCLUDES "${CMAKE_SOURCE_DIR}/deps/zlib")
- LIST(APPEND LIBGIT2_LIBS zlib)
+ LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
ENDIF()
# Optional external dependency: libssh2
@@ -330,32 +332,28 @@ ENDIF()
CONFIGURE_FILE(features.h.in git2/sys/features.h)
-SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
+SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
-IF (CMAKE_VERSION VERSION_GREATER 2.8.7)
- ADD_LIBRARY(git2internal OBJECT ${GIT2INTERNAL_OBJECTS})
- IDE_SPLIT_SOURCES(git2internal)
- SET(GIT2INTERNAL_OBJECTS $<TARGET_OBJECTS:git2internal>)
+ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES})
+IDE_SPLIT_SOURCES(git2internal)
+LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
- IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
- INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
- ELSE()
- TARGET_INCLUDE_DIRECTORIES(git2internal
- PRIVATE ${LIBGIT2_INCLUDES}
- PUBLIC ${CMAKE_SOURCE_DIR}/include)
- ENDIF()
-ELSE()
+IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
+ELSE()
+ TARGET_INCLUDE_DIRECTORIES(git2internal
+ PRIVATE ${LIBGIT2_INCLUDES}
+ PUBLIC ${CMAKE_SOURCE_DIR}/include)
ENDIF()
-SET(GIT2INTERNAL_OBJECTS ${GIT2INTERNAL_OBJECTS} PARENT_SCOPE)
+SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
SET(LIBGIT2_LIBDIRS ${LIBGIT2_LIBDIRS} PARENT_SCOPE)
# Compile and link libgit2
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
-ADD_LIBRARY(git2 ${WIN_RC} ${GIT2INTERNAL_OBJECTS})
+ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5aba2914a..53265cc55 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -33,11 +33,13 @@ SET_SOURCE_FILES_PROPERTIES(
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
-ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${GIT2INTERNAL_OBJECTS})
+ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-IF (${CMAKE_VERSION} VERSION_GREATER 2.8.11)
+IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
+ # Already handled by a global INCLUDE_DIRECTORY()
+ELSE()
TARGET_INCLUDE_DIRECTORIES(libgit2_clar PRIVATE ../src PUBLIC ../include)
ENDIF()