11# libgit2: the shared library: this CMakeLists.txt compiles the core
22# git library functionality.
33
4- add_library (git2internal OBJECT)
5- set_target_properties (git2internal PROPERTIES C_STANDARD 90)
6- set_target_properties (git2internal PROPERTIES C_EXTENSIONS OFF )
4+ add_library (libgit2 OBJECT)
5+ set_target_properties (libgit2 PROPERTIES C_STANDARD 90)
6+ set_target_properties (libgit2 PROPERTIES C_EXTENSIONS OFF )
77
88include (PkgBuildConfig)
99
@@ -16,177 +16,27 @@ set(LIBGIT2_INCLUDES
1616if (WIN32 AND EMBED_SSH_PATH)
1717 file (GLOB SRC_SSH "${EMBED_SSH_PATH} /src/*.c" )
1818 list (SORT SRC_SSH)
19- target_sources (git2internal PRIVATE ${SRC_SSH} )
19+ target_sources (libgit2 PRIVATE ${SRC_SSH} )
2020
2121 list (APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH} /include" )
2222 file (WRITE "${EMBED_SSH_PATH} /src/libssh2_config.h" "#define HAVE_WINCNG\n #define LIBSSH2_WINCNG\n #include \" ../win32/libssh2_config.h\" " )
2323 set (GIT_SSH 1)
2424endif ()
2525
26- <<<<<<< HEAD
27- include (SelectHTTPSBackend)
28- include (SelectHashes)
29- include (SelectHTTPParser)
30- include (SelectRegex)
31- include (SelectSSH)
32- include (SelectWinHTTP)
33- include (SelectZlib)
34-
35-
36- if (USE_SHA1 STREQUAL "CollisionDetection" )
37- file (GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
38- elseif (USE_SHA1 STREQUAL "OpenSSL" )
39- file (GLOB SRC_SHA1 hash/sha1/openssl.*)
40- elseif (USE_SHA1 STREQUAL "CommonCrypto" )
41- file (GLOB SRC_SHA1 hash/sha1/common_crypto.*)
42- elseif (USE_SHA1 STREQUAL "mbedTLS" )
43- file (GLOB SRC_SHA1 hash/sha1/mbedtls.*)
44- elseif (USE_SHA1 STREQUAL "Win32" )
45- file (GLOB SRC_SHA1 hash/sha1/win32 .*)
46- elseif (USE_SHA1 STREQUAL "Generic" )
47- file (GLOB SRC_SHA1 hash/sha1/generic.*)
48- endif ()
49- list (APPEND SRC_SHA1 "hash/sha1.h" )
50- target_sources (git2internal PRIVATE ${SRC_SHA1} )
51-
52- # Optional external dependency: ntlmclient
53- if (USE_NTLMCLIENT)
54- set (GIT_NTLM 1)
55- add_subdirectory ("${PROJECT_SOURCE_DIR} /deps/ntlmclient" "${PROJECT_BINARY_DIR} /deps/ntlmclient" )
56- list (APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR} /deps/ntlmclient" )
57- list (APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>" )
58- endif ()
59- add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix" )
60-
61- # Optional external dependency: GSSAPI
62-
63- include (SelectGSSAPI)
64-
65- # Optional external dependency: iconv
66- if (USE_ICONV)
67- find_package (Iconv)
68- endif ()
69- if (ICONV_FOUND)
70- set (GIT_USE_ICONV 1)
71- list (APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR} )
72- list (APPEND LIBGIT2_SYSTEM_LIBS ${ICONV_LIBRARIES} )
73- list (APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES} )
74- endif ()
75- add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support" )
76-
77-
78- if (USE_THREADS)
79- if (NOT WIN32 )
80- find_package (Threads REQUIRED)
81- endif ()
82-
83- set (GIT_THREADS 1)
84- endif ()
85-
86- if (USE_NSEC)
87- set (GIT_USE_NSEC 1)
88- endif ()
89-
90- if (HAVE_STRUCT_STAT_ST_MTIM)
91- set (GIT_USE_STAT_MTIM 1)
92- elseif (HAVE_STRUCT_STAT_ST_MTIMESPEC)
93- set (GIT_USE_STAT_MTIMESPEC 1)
94- elseif (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
95- set (GIT_USE_STAT_MTIME_NSEC 1)
96- endif ()
97-
98- target_compile_definitions (git2internal PRIVATE _FILE_OFFSET_BITS=64)
99-
100- ||||||| parent of a930dafb4 (refactor: make util an object library)
101- include (SelectHTTPSBackend)
102- include (SelectHashes)
103- include (SelectHTTPParser)
104- include (SelectRegex)
105- include (SelectSSH)
106- include (SelectWinHTTP)
107- include (SelectZlib)
108-
109-
110- if (USE_SHA1 STREQUAL "CollisionDetection" )
111- file (GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
112- elseif (USE_SHA1 STREQUAL "OpenSSL" )
113- file (GLOB SRC_SHA1 hash/sha1/openssl.*)
114- elseif (USE_SHA1 STREQUAL "CommonCrypto" )
115- file (GLOB SRC_SHA1 hash/sha1/common_crypto.*)
116- elseif (USE_SHA1 STREQUAL "mbedTLS" )
117- file (GLOB SRC_SHA1 hash/sha1/mbedtls.*)
118- elseif (USE_SHA1 STREQUAL "Win32" )
119- file (GLOB SRC_SHA1 hash/sha1/win32 .*)
120- elseif (USE_SHA1 STREQUAL "Generic" )
121- file (GLOB SRC_SHA1 hash/sha1/generic.*)
122- endif ()
123- list (APPEND SRC_SHA1 "hash/sha1.h" )
124- target_sources (git2internal PRIVATE ${SRC_SHA1} )
125-
126- # Optional external dependency: ntlmclient
127- if (USE_NTLMCLIENT)
128- set (GIT_NTLM 1)
129- add_subdirectory ("${PROJECT_SOURCE_DIR} /deps/ntlmclient" "${PROJECT_BINARY_DIR} /deps/ntlmclient" )
130- list (APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR} /deps/ntlmclient" )
131- list (APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>" )
132- endif ()
133- add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix" )
134-
135- # Optional external dependency: GSSAPI
136-
137- include (SelectGSSAPI)
138-
139- # Optional external dependency: iconv
140- if (USE_ICONV)
141- find_package (Iconv)
142- endif ()
143- if (ICONV_FOUND)
144- set (GIT_USE_ICONV 1)
145- list (APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR} )
146- list (APPEND LIBGIT2_SYSTEM_LIBS ${ICONV_LIBRARIES} )
147- list (APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES} )
148- endif ()
149- add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support" )
150-
151-
152- if (USE_THREADS)
153- if (NOT WIN32 )
154- find_package (Threads REQUIRED)
155- endif ()
156-
157- set (GIT_THREADS 1)
158- endif ()
159-
160- if (USE_NSEC)
161- set (GIT_USE_NSEC 1)
162- endif ()
163-
164- if (HAVE_STRUCT_STAT_ST_MTIM)
165- set (GIT_USE_STAT_MTIM 1)
166- elseif (HAVE_STRUCT_STAT_ST_MTIMESPEC)
167- set (GIT_USE_STAT_MTIMESPEC 1)
168- elseif (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
169- set (GIT_USE_STAT_MTIME_NSEC 1)
170- endif ()
171-
172- target_compile_definitions (git2internal PRIVATE _FILE_OFFSET_BITS=64)
173-
174- =======
175- >>>>>>> a930dafb4 (refactor: make util an object library)
17626# Collect sourcefiles
17727file (GLOB SRC_H
17828 "${PROJECT_SOURCE_DIR} /include/git2.h"
17929 "${PROJECT_SOURCE_DIR} /include/git2/*.h"
18030 "${PROJECT_SOURCE_DIR} /include/git2/sys/*.h" )
18131list (SORT SRC_H)
182- target_sources (git2internal PRIVATE ${SRC_H} )
32+ target_sources (libgit2 PRIVATE ${SRC_H} )
18333
18434file (GLOB SRC_GIT2 *.c *.h
18535 streams/*.c streams/*.h
18636 transports/*.c transports/*.h
18737 xdiff/*.c xdiff/*.h)
18838list (SORT SRC_GIT2)
189- target_sources (git2internal PRIVATE ${SRC_GIT2} )
39+ target_sources (libgit2 PRIVATE ${SRC_GIT2} )
19040
19141if (WIN32 AND NOT CYGWIN )
19242 # Add resource information on Windows
@@ -198,9 +48,9 @@ if(APPLE)
19848 set_source_files_properties (streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
19949endif ()
20050
201- # the xdiff dependency is not (yet) warning-free, disable warnings as
202- # errors for the xdiff sources until we've sorted them out
203- if (MSVC )
51+ # the xdiff dependency is not (yet) warning-free, disable warnings
52+ # as errors for the xdiff sources until we've sorted them out
53+ if (MSVC )
20454 set_source_files_properties (xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
20555 set_source_files_properties (xdiff/xemit.c PROPERTIES COMPILE_FLAGS -WX-)
20656 set_source_files_properties (xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
@@ -213,13 +63,13 @@ else()
21363 set_source_files_properties (xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" )
21464 set_source_files_properties (xdiff/xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" )
21565 set_source_files_properties (xdiff/xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" )
216- endif ()
66+ endif ()
21767
218- ide_split_sources(git2internal )
219- list (APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:util> $<TARGET_OBJECTS:git2internal > ${LIBGIT2_DEPENDENCY_OBJECTS} )
68+ ide_split_sources(libgit2 )
69+ list (APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:util> $<TARGET_OBJECTS:libgit2 > ${LIBGIT2_DEPENDENCY_OBJECTS} )
22070
221- target_include_directories (git2internal PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR} /include )
222- target_include_directories (git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES} )
71+ target_include_directories (libgit2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR} /include )
72+ target_include_directories (libgit2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES} )
22373
22474set (LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
22575set (LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
@@ -228,31 +78,34 @@ set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
22878set (LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
22979set (LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
23080
81+ #
23182# Compile and link libgit2
232- add_library (git2 ${SRC_RC} ${LIBGIT2_OBJECTS} )
233- target_link_libraries (git2 ${LIBGIT2_SYSTEM_LIBS} )
83+ #
84+
85+ add_library (libgit2package ${SRC_RC} ${LIBGIT2_OBJECTS} )
86+ target_link_libraries (libgit2package ${LIBGIT2_SYSTEM_LIBS} )
23487
235- set_target_properties (git2 PROPERTIES C_STANDARD 90)
236- set_target_properties (git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
237- set_target_properties (git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
238- set_target_properties (git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
88+ set_target_properties (libgit2package PROPERTIES C_STANDARD 90)
89+ set_target_properties (libgit2package PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
90+ set_target_properties (libgit2package PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
91+ set_target_properties (libgit2package PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
23992
24093# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
24194# Win64+MSVC+static libs = linker error
24295if (MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS )
243- set_target_properties (git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64" )
96+ set_target_properties (libgit2package PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64" )
24497endif ()
24598
246- ide_split_sources(git2 )
99+ ide_split_sources(libgit2package )
247100
248101if (SONAME)
249- set_target_properties (git2 PROPERTIES VERSION ${libgit2_VERSION} )
250- set_target_properties (git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR} .${libgit2_VERSION_MINOR} " )
102+ set_target_properties (libgit2package PROPERTIES VERSION ${libgit2_VERSION} )
103+ set_target_properties (libgit2package PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR} .${libgit2_VERSION_MINOR} " )
251104 if (LIBGIT2_FILENAME)
252- target_compile_definitions (git2 PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME} \")
253- set_target_properties (git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME} )
105+ target_compile_definitions (libgit2package PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME} \")
106+ set_target_properties (libgit2package PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME} )
254107 elseif (DEFINED LIBGIT2_PREFIX)
255- set_target_properties (git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX} " )
108+ set_target_properties (libgit2package PROPERTIES PREFIX "${LIBGIT2_PREFIX} " )
256109 endif ()
257110endif ()
258111
@@ -261,20 +114,18 @@ pkg_build_config(NAME libgit2
261114 DESCRIPTION "The git library, take 2"
262115 LIBS_SELF git2
263116 PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
264- REQUIRES ${LIBGIT2_PC_REQUIRES}
265- )
117+ REQUIRES ${LIBGIT2_PC_REQUIRES} )
266118
267119if (MSVC_IDE )
268120 # Precompiled headers
269- set_target_properties (git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h" )
121+ set_target_properties (libgit2package PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h" )
270122 set_source_files_properties (win32 /precompiled.c COMPILE_FLAGS "/Ycprecompiled.h" )
271123endif ()
272124
273125# Install
274- install (TARGETS git2
126+ install (TARGETS libgit2package
275127 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
276128 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
277- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
278- )
129+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
279130install (DIRECTORY ${PROJECT_SOURCE_DIR} /include /git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
280131install (FILES ${PROJECT_SOURCE_DIR} /include /git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
0 commit comments