Skip to content

Commit 462dbe2

Browse files
Edward ThomsonEdward Thomson
authored andcommitted
xdiff: move xdiff to 'deps'
xdiff is a dependency (from git core) and more properly belongs in the 'deps' directory. Move it there, and add a stub for cmake to resolve xdiff from the system location in the future. (At present, bundled xdiff remains hardcoded.)
1 parent af12fc1 commit 462dbe2

24 files changed

+41
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON
3636
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
3737
option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
3838
set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
39+
# set(USE_XDIFF "" CACHE STRING "Specifies the xdiff implementation; either system or builtin.")
3940
set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
4041
option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
4142

cmake/SelectXdiff.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Optional external dependency: xdiff
2+
if(USE_XDIFF STREQUAL "system")
3+
message(FATAL_ERROR "external/system xdiff is not yet supported")
4+
else()
5+
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/xdiff" "${PROJECT_BINARY_DIR}/deps/xdiff")
6+
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/xdiff")
7+
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:xdiff>")
8+
add_feature_info(xdiff ON "xdiff support (bundled)")
9+
endif()

deps/xdiff/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
file(GLOB SRC_XDIFF "*.c" "*.h")
3+
list(SORT SRC_XDIFF)
4+
5+
add_library(xdiff OBJECT ${SRC_XDIFF})
6+
target_include_directories(xdiff SYSTEM PRIVATE
7+
"${PROJECT_SOURCE_DIR}/include"
8+
"${PROJECT_SOURCE_DIR}/src/util"
9+
"${PROJECT_BINARY_DIR}/src/util"
10+
${LIBGIT2_SYSTEM_INCLUDES}
11+
${LIBGIT2_DEPENDENCY_INCLUDES})
12+
13+
# the xdiff dependency is not (yet) warning-free, disable warnings
14+
# as errors for the xdiff sources until we've sorted them out
15+
if(MSVC)
16+
set_source_files_properties(xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
17+
set_source_files_properties(xemit.c PROPERTIES COMPILE_FLAGS -WX-)
18+
set_source_files_properties(xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
19+
set_source_files_properties(xmerge.c PROPERTIES COMPILE_FLAGS -WX-)
20+
set_source_files_properties(xutils.c PROPERTIES COMPILE_FLAGS -WX-)
21+
set_source_files_properties(xpatience.c PROPERTIES COMPILE_FLAGS -WX-)
22+
else()
23+
set_source_files_properties(xdiffi.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
24+
set_source_files_properties(xemit.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
25+
set_source_files_properties(xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
26+
set_source_files_properties(xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
27+
set_source_files_properties(xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
28+
endif()

0 commit comments

Comments
 (0)