Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
23c5c315
Unverified
Commit
23c5c315
authored
Nov 14, 2021
by
Edward Thomson
Committed by
GitHub
Nov 14, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6114 from libgit2/ethomson/cmake5
cmake: further refactorings
parents
b608af6c
2c154145
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
577 additions
and
580 deletions
+577
-580
CMakeLists.txt
+1
-1
cmake/AddCFlagIfSupported.cmake
+21
-21
cmake/EnableWarnings.cmake
+13
-13
cmake/FindCoreFoundation.cmake
+13
-13
cmake/FindGSSAPI.cmake
+0
-0
cmake/FindGSSFramework.cmake
+13
-13
cmake/FindHTTPParser.cmake
+17
-17
cmake/FindIconv.cmake
+27
-27
cmake/FindLibSSH2.cmake
+5
-5
cmake/FindPCRE.cmake
+13
-13
cmake/FindPCRE2.cmake
+12
-12
cmake/FindPkgLibraries.cmake
+19
-19
cmake/FindSecurity.cmake
+14
-14
cmake/Findfutimens.cmake
+8
-8
cmake/FindmbedTLS.cmake
+63
-70
cmake/IdeSplitSources.cmake
+17
-17
cmake/PkgBuildConfig.cmake
+60
-60
cmake/SanitizeBool.cmake
+20
-20
cmake/SelectGSSAPI.cmake
+37
-37
cmake/SelectHTTPParser.cmake
+3
-3
cmake/SelectHTTPSBackend.cmake
+100
-100
cmake/SelectHashes.cmake
+39
-49
cmake/SelectRegex.cmake
+4
-4
cmake/SelectSSH.cmake
+3
-3
cmake/SelectWinHTTP.cmake
+3
-3
cmake/SelectZlib.cmake
+5
-5
examples/CMakeLists.txt
+5
-4
fuzzers/CMakeLists.txt
+7
-7
src/CMakeLists.txt
+30
-15
tests/CMakeLists.txt
+5
-7
No files found.
CMakeLists.txt
View file @
23c5c315
...
...
@@ -40,7 +40,7 @@ option(DEBUG_STRICT_OPEN "Enable path validation in open"
# Output options
option
(
SONAME
"Set the (SO)VERSION of the target"
ON
)
option
(
LIBGIT2_FILENAME
"Name of the produced binary"
OFF
)
set
(
LIBGIT2_FILENAME
"git2"
CACHE STRING
"Name of the produced binary"
)
option
(
DEPRECATE_HARD
"Do not include deprecated functions in the library"
OFF
)
# Compilation options
...
...
cmake/AddCFlagIfSupported.cmake
View file @
23c5c315
...
...
@@ -3,28 +3,28 @@
# <flag> - the compiler flag to test
# This internally calls the CHECK_C_COMPILER_FLAG macro.
INCLUDE
(
CheckCCompilerFlag
)
include
(
CheckCCompilerFlag
)
MACRO
(
ADD_C_FLAG _FLAG
)
STRING
(
TOUPPER
${
_FLAG
}
UPCASE
)
STRING
(
REGEX REPLACE
"[-=]"
"_"
UPCASE_PRETTY
${
UPCASE
}
)
STRING
(
REGEX REPLACE
"^_+"
""
UPCASE_PRETTY
${
UPCASE_PRETTY
}
)
CHECK_C_COMPILER_FLAG
(
${
_FLAG
}
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
macro
(
ADD_C_FLAG _FLAG
)
string
(
TOUPPER
${
_FLAG
}
UPCASE
)
string
(
REGEX REPLACE
"[-=]"
"_"
UPCASE_PRETTY
${
UPCASE
}
)
string
(
REGEX REPLACE
"^_+"
""
UPCASE_PRETTY
${
UPCASE_PRETTY
}
)
check_c_compiler_flag
(
${
_FLAG
}
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
IF
(
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
_FLAG
}
"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Required flag
${
_FLAG
}
is not supported"
)
ENDIF
()
ENDMACRO
()
if
(
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
_FLAG
}
"
)
else
()
message
(
FATAL_ERROR
"Required flag
${
_FLAG
}
is not supported"
)
endif
()
endmacro
()
MACRO
(
ADD_C_FLAG_IF_SUPPORTED _FLAG
)
STRING
(
TOUPPER
${
_FLAG
}
UPCASE
)
STRING
(
REGEX REPLACE
"[-=]"
"_"
UPCASE_PRETTY
${
UPCASE
}
)
STRING
(
REGEX REPLACE
"^_+"
""
UPCASE_PRETTY
${
UPCASE_PRETTY
}
)
CHECK_C_COMPILER_FLAG
(
${
_FLAG
}
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
macro
(
ADD_C_FLAG_IF_SUPPORTED _FLAG
)
string
(
TOUPPER
${
_FLAG
}
UPCASE
)
string
(
REGEX REPLACE
"[-=]"
"_"
UPCASE_PRETTY
${
UPCASE
}
)
string
(
REGEX REPLACE
"^_+"
""
UPCASE_PRETTY
${
UPCASE_PRETTY
}
)
check_c_compiler_flag
(
${
_FLAG
}
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
IF
(
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
_FLAG
}
"
)
ENDIF
()
ENDMACRO
()
if
(
IS_
${
UPCASE_PRETTY
}
_SUPPORTED
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
_FLAG
}
"
)
endif
()
endmacro
()
cmake/EnableWarnings.cmake
View file @
23c5c315
MACRO
(
ENABLE_WARNINGS flag
)
ADD_C_FLAG_IF_SUPPORTED
(
-W
${
flag
}
)
ENDMACRO
()
macro
(
ENABLE_WARNINGS flag
)
add_c_flag_if_supported
(
-W
${
flag
}
)
endmacro
()
MACRO
(
DISABLE_WARNINGS flag
)
ADD_C_FLAG_IF_SUPPORTED
(
-Wno-
${
flag
}
)
ENDMACRO
()
macro
(
DISABLE_WARNINGS flag
)
add_c_flag_if_supported
(
-Wno-
${
flag
}
)
endmacro
()
IF
(
ENABLE_WERROR
)
IF
(
MSVC
)
ADD_COMPILE_OPTIONS
(
-WX
)
ELSE
()
ADD_C_FLAG_IF_SUPPORTED
(
-Werror
)
ENDIF
()
ENDIF
()
if
(
ENABLE_WERROR
)
if
(
MSVC
)
add_compile_options
(
-WX
)
else
()
add_c_flag_if_supported
(
-Werror
)
endif
()
endif
()
cmake/FindCoreFoundation.cmake
View file @
23c5c315
...
...
@@ -6,21 +6,21 @@
# COREFOUNDATION_LDFLAGS
#
FIND_PATH
(
COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h
)
FIND_LIBRARY
(
COREFOUNDATION_LIBRARIES NAMES CoreFoundation
)
IF
(
COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES
)
IF
(
NOT CoreFoundation_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found CoreFoundation
${
COREFOUNDATION_LIBRARIES
}
"
)
ENDIF
()
SET
(
COREFOUNDATION_FOUND TRUE
)
SET
(
COREFOUNDATION_LDFLAGS
"-framework CoreFoundation"
)
ENDIF
()
find_path
(
COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h
)
find_library
(
COREFOUNDATION_LIBRARIES NAMES CoreFoundation
)
if
(
COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES
)
if
(
NOT CoreFoundation_FIND_QUIETLY
)
message
(
STATUS
"Found CoreFoundation
${
COREFOUNDATION_LIBRARIES
}
"
)
endif
()
set
(
COREFOUNDATION_FOUND TRUE
)
set
(
COREFOUNDATION_LDFLAGS
"-framework CoreFoundation"
)
endif
()
IF
(
CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND
)
MESSAGE
(
FATAL_ERROR
"CoreFoundation not found"
)
ENDIF
()
if
(
CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND
)
message
(
FATAL_ERROR
"CoreFoundation not found"
)
endif
()
MARK_AS_ADVANCED
(
mark_as_advanced
(
COREFOUNDATION_INCLUDE_DIR
COREFOUNDATION_LIBRARIES
)
cmake/FindGSSAPI.cmake
View file @
23c5c315
This diff is collapsed.
Click to expand it.
cmake/FindGSSFramework.cmake
View file @
23c5c315
...
...
@@ -7,21 +7,21 @@
# GSSFRAMEWORK_LDFLAGS
#
FIND_PATH
(
GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h
)
FIND_LIBRARY
(
GSSFRAMEWORK_LIBRARIES NAMES GSS
)
IF
(
GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES
)
IF
(
NOT CoreFoundation_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found GSS.framework
${
GSSFRAMEWORK_LIBRARIES
}
"
)
ENDIF
()
SET
(
GSSFRAMEWORK_FOUND TRUE
)
SET
(
GSSFRAMEWORK_LDFLAGS
"-framework GSS"
)
ENDIF
()
find_path
(
GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h
)
find_library
(
GSSFRAMEWORK_LIBRARIES NAMES GSS
)
if
(
GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES
)
if
(
NOT CoreFoundation_FIND_QUIETLY
)
message
(
STATUS
"Found GSS.framework
${
GSSFRAMEWORK_LIBRARIES
}
"
)
endif
()
set
(
GSSFRAMEWORK_FOUND TRUE
)
set
(
GSSFRAMEWORK_LDFLAGS
"-framework GSS"
)
endif
()
IF
(
GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND
)
MESSAGE
(
FATAL_ERROR
"CoreFoundation not found"
)
ENDIF
()
if
(
GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND
)
message
(
FATAL_ERROR
"CoreFoundation not found"
)
endif
()
MARK_AS_ADVANCED
(
mark_as_advanced
(
GSSFRAMEWORK_INCLUDE_DIR
GSSFRAMEWORK_LIBRARIES
GSSFRAMEWORK_LDFLAGS
...
...
cmake/FindHTTPParser.cmake
View file @
23c5c315
...
...
@@ -10,30 +10,30 @@
# HTTP_PARSER_VERSION_STRING - the version of http-parser found
# Find the header and library
FIND_PATH
(
HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h
)
FIND_LIBRARY
(
HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser
)
find_path
(
HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h
)
find_library
(
HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser
)
# Found the header, read version
if
(
HTTP_PARSER_INCLUDE_DIR AND EXISTS
"
${
HTTP_PARSER_INCLUDE_DIR
}
/http_parser.h"
)
FILE
(
READ
"
${
HTTP_PARSER_INCLUDE_DIR
}
/http_parser.h"
HTTP_PARSER_H
)
IF
(
HTTP_PARSER_H
)
STRING
(
REGEX REPLACE
".*#define[
\t
]+HTTP_PARSER_VERSION_MAJOR[
\t
]+([0-9]+).*"
"
\\
1"
HTTP_PARSER_VERSION_MAJOR
"
${
HTTP_PARSER_H
}
"
)
STRING
(
REGEX REPLACE
".*#define[
\t
]+HTTP_PARSER_VERSION_MINOR[
\t
]+([0-9]+).*"
"
\\
1"
HTTP_PARSER_VERSION_MINOR
"
${
HTTP_PARSER_H
}
"
)
SET
(
HTTP_PARSER_VERSION_STRING
"
${
HTTP_PARSER_VERSION_MAJOR
}
.
${
HTTP_PARSER_VERSION_MINOR
}
"
)
ENDIF
()
UNSET
(
HTTP_PARSER_H
)
ENDIF
()
if
(
HTTP_PARSER_INCLUDE_DIR AND EXISTS
"
${
HTTP_PARSER_INCLUDE_DIR
}
/http_parser.h"
)
file
(
READ
"
${
HTTP_PARSER_INCLUDE_DIR
}
/http_parser.h"
HTTP_PARSER_H
)
if
(
HTTP_PARSER_H
)
string
(
REGEX REPLACE
".*#define[
\t
]+HTTP_PARSER_VERSION_MAJOR[
\t
]+([0-9]+).*"
"
\\
1"
HTTP_PARSER_VERSION_MAJOR
"
${
HTTP_PARSER_H
}
"
)
string
(
REGEX REPLACE
".*#define[
\t
]+HTTP_PARSER_VERSION_MINOR[
\t
]+([0-9]+).*"
"
\\
1"
HTTP_PARSER_VERSION_MINOR
"
${
HTTP_PARSER_H
}
"
)
set
(
HTTP_PARSER_VERSION_STRING
"
${
HTTP_PARSER_VERSION_MAJOR
}
.
${
HTTP_PARSER_VERSION_MINOR
}
"
)
endif
()
unset
(
HTTP_PARSER_H
)
endif
()
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
# to TRUE if all listed variables are TRUE
INCLUDE
(
FindPackageHandleStandardArgs
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS
(
HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY
)
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY
)
# Hide advanced variables
MARK_AS_ADVANCED
(
HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY
)
mark_as_advanced
(
HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY
)
# Set standard variables
IF
(
HTTP_PARSER_FOUND
)
SET
(
HTTP_PARSER_LIBRARIES
${
HTTP_PARSER_LIBRARY
}
)
if
(
HTTP_PARSER_FOUND
)
set
(
HTTP_PARSER_LIBRARIES
${
HTTP_PARSER_LIBRARY
}
)
set
(
HTTP_PARSER_INCLUDE_DIRS
${
HTTP_PARSER_INCLUDE_DIR
}
)
ENDIF
()
endif
()
cmake/FindIconv.cmake
View file @
23c5c315
...
...
@@ -6,40 +6,40 @@
# ICONV_LIBRARIES - Link these to use Iconv
#
IF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
if
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
# Already in cache, be silent
SET
(
ICONV_FIND_QUIETLY TRUE
)
ENDIF
()
set
(
ICONV_FIND_QUIETLY TRUE
)
endif
()
FIND_PATH
(
ICONV_INCLUDE_DIR iconv.h
)
CHECK_FUNCTION_EXISTS
(
iconv_open libc_has_iconv
)
FIND_LIBRARY
(
iconv_lib NAMES iconv libiconv libiconv-2 c
)
find_path
(
ICONV_INCLUDE_DIR iconv.h
)
check_function_exists
(
iconv_open libc_has_iconv
)
find_library
(
iconv_lib NAMES iconv libiconv libiconv-2 c
)
IF
(
ICONV_INCLUDE_DIR AND libc_has_iconv
)
SET
(
ICONV_FOUND TRUE
)
SET
(
ICONV_LIBRARIES
""
)
IF
(
NOT ICONV_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found Iconv: provided by libc"
)
ENDIF
(
NOT ICONV_FIND_QUIETLY
)
ELSEIF
(
ICONV_INCLUDE_DIR AND iconv_lib
)
SET
(
ICONV_FOUND TRUE
)
if
(
ICONV_INCLUDE_DIR AND libc_has_iconv
)
set
(
ICONV_FOUND TRUE
)
set
(
ICONV_LIBRARIES
""
)
if
(
NOT ICONV_FIND_QUIETLY
)
message
(
STATUS
"Found Iconv: provided by libc"
)
endif
(
NOT ICONV_FIND_QUIETLY
)
elseif
(
ICONV_INCLUDE_DIR AND iconv_lib
)
set
(
ICONV_FOUND TRUE
)
# split iconv into -L and -l linker options, so we can
# set them for pkg-config
GET_FILENAME_COMPONENT
(
iconv_path
${
iconv_lib
}
PATH
)
GET_FILENAME_COMPONENT
(
iconv_name
${
iconv_lib
}
NAME_WE
)
STRING
(
REGEX REPLACE
"^lib"
""
iconv_name
${
iconv_name
}
)
SET
(
ICONV_LIBRARIES
"-L
${
iconv_path
}
-l
${
iconv_name
}
"
)
get_filename_component
(
iconv_path
${
iconv_lib
}
PATH
)
get_filename_component
(
iconv_name
${
iconv_lib
}
NAME_WE
)
string
(
REGEX REPLACE
"^lib"
""
iconv_name
${
iconv_name
}
)
set
(
ICONV_LIBRARIES
"-L
${
iconv_path
}
-l
${
iconv_name
}
"
)
IF
(
NOT ICONV_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found Iconv:
${
ICONV_LIBRARIES
}
"
)
ENDIF
(
NOT ICONV_FIND_QUIETLY
)
ELSE
()
IF
(
Iconv_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Could not find Iconv"
)
ENDIF
(
Iconv_FIND_REQUIRED
)
ENDIF
()
if
(
NOT ICONV_FIND_QUIETLY
)
message
(
STATUS
"Found Iconv:
${
ICONV_LIBRARIES
}
"
)
endif
(
)
else
()
if
(
Iconv_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Could not find Iconv"
)
endif
(
Iconv_FIND_REQUIRED
)
endif
()
MARK_AS_ADVANCED
(
mark_as_advanced
(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
)
cmake/FindLibSSH2.cmake
View file @
23c5c315
...
...
@@ -2,12 +2,12 @@
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
# LIBSSH2_LIBRARY - the libssh2 library name
FIND_PATH
(
LIBSSH2_INCLUDE_DIR libssh2.h
)
find_path
(
LIBSSH2_INCLUDE_DIR libssh2.h
)
FIND_LIBRARY
(
LIBSSH2_LIBRARY NAMES ssh2 libssh2
)
find_library
(
LIBSSH2_LIBRARY NAMES ssh2 libssh2
)
INCLUDE
(
FindPackageHandleStandardArgs
)
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR
)
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR
)
MARK_AS_ADVANCED
(
LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY
)
mark_as_advanced
(
LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY
)
cmake/FindPCRE.cmake
View file @
23c5c315
...
...
@@ -16,23 +16,23 @@
# PCRE_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH
(
PCRE_INCLUDE_DIR NAMES pcreposix.h
)
find_path
(
PCRE_INCLUDE_DIR NAMES pcreposix.h
)
# Look for the library.
FIND_LIBRARY
(
PCRE_LIBRARY NAMES pcre
)
FIND_LIBRARY
(
PCRE_POSIX_LIBRARY NAMES pcreposix
)
find_library
(
PCRE_LIBRARY NAMES pcre
)
find_library
(
PCRE_POSIX_LIBRARY NAMES pcreposix
)
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE
(
FindPackageHandleStandardArgs
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS
(
PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR
)
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR
)
# Copy the results to the output variables.
IF
(
PCRE_FOUND
)
SET
(
PCRE_LIBRARIES
${
PCRE_LIBRARY
}
${
PCRE_POSIX_LIBRARY
}
)
SET
(
PCRE_INCLUDE_DIRS
${
PCRE_INCLUDE_DIR
}
)
ELSE
(
PCRE_FOUND
)
SET
(
PCRE_LIBRARIES
)
SET
(
PCRE_INCLUDE_DIRS
)
ENDIF
(
PCRE_FOUND
)
if
(
PCRE_FOUND
)
set
(
PCRE_LIBRARIES
${
PCRE_LIBRARY
}
${
PCRE_POSIX_LIBRARY
}
)
set
(
PCRE_INCLUDE_DIRS
${
PCRE_INCLUDE_DIR
}
)
else
(
PCRE_FOUND
)
set
(
PCRE_LIBRARIES
)
set
(
PCRE_INCLUDE_DIRS
)
endif
(
)
MARK_AS_ADVANCED
(
PCRE_INCLUDE_DIRS PCRE_LIBRARIES
)
mark_as_advanced
(
PCRE_INCLUDE_DIRS PCRE_LIBRARIES
)
cmake/FindPCRE2.cmake
View file @
23c5c315
...
...
@@ -16,22 +16,22 @@
# PCRE2_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH
(
PCRE2_INCLUDE_DIR NAMES pcre2posix.h
)
find_path
(
PCRE2_INCLUDE_DIR NAMES pcre2posix.h
)
# Look for the library.
FIND_LIBRARY
(
PCRE2_LIBRARY NAMES pcre2-8
)
find_library
(
PCRE2_LIBRARY NAMES pcre2-8
)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE
(
FindPackageHandleStandardArgs
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS
(
PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR
)
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR
)
# Copy the results to the output variables.
IF
(
PCRE2_FOUND
)
SET
(
PCRE2_LIBRARIES
${
PCRE2_LIBRARY
}
)
SET
(
PCRE2_INCLUDE_DIRS
${
PCRE2_INCLUDE_DIR
}
)
ELSE
(
PCRE2_FOUND
)
SET
(
PCRE2_LIBRARIES
)
SET
(
PCRE2_INCLUDE_DIRS
)
ENDIF
(
PCRE2_FOUND
)
if
(
PCRE2_FOUND
)
set
(
PCRE2_LIBRARIES
${
PCRE2_LIBRARY
}
)
set
(
PCRE2_INCLUDE_DIRS
${
PCRE2_INCLUDE_DIR
}
)
else
(
PCRE2_FOUND
)
set
(
PCRE2_LIBRARIES
)
set
(
PCRE2_INCLUDE_DIRS
)
endif
(
)
MARK_AS_ADVANCED
(
PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES
)
mark_as_advanced
(
PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES
)
cmake/FindPkgLibraries.cmake
View file @
23c5c315
INCLUDE
(
FindPkgConfig
)
include
(
FindPkgConfig
)
# This function will find and set up a pkg-config based module.
# If a pc-file was found, it will resolve library paths to
# absolute paths. Furthermore, the function will automatically
# fall back to use static libraries in case no dynamic libraries
# were found.
FUNCTION
(
FIND_PKGLIBRARIES prefix package
)
PKG_CHECK_MODULES
(
${
prefix
}
${
package
}
)
IF
(
NOT
${
prefix
}
_FOUND
)
RETURN
()
ENDIF
()
function
(
FIND_PKGLIBRARIES prefix package
)
pkg_check_modules
(
${
prefix
}
${
package
}
)
if
(
NOT
${
prefix
}
_FOUND
)
return
()
endif
()
FOREACH
(
LIBRARY
${${
prefix
}
_LIBRARIES
}
)
FIND_LIBRARY
(
${
LIBRARY
}
_RESOLVED
${
LIBRARY
}
PATHS
${${
prefix
}
_LIBRARY_DIRS
}
)
IF
(
${${
LIBRARY
}
_RESOLVED
}
STREQUAL
"
${
LIBRARY
}
_RESOLVED-NOTFOUND"
)
MESSAGE
(
FATAL_ERROR
"could not resolve
${
LIBRARY
}
"
)
ENDIF
()
LIST
(
APPEND RESOLVED_LIBRARIES
${${
LIBRARY
}
_RESOLVED
}
)
ENDFOREACH
(
LIBRARY
)
foreach
(
LIBRARY
${${
prefix
}
_LIBRARIES
}
)
find_library
(
${
LIBRARY
}
_RESOLVED
${
LIBRARY
}
PATHS
${${
prefix
}
_LIBRARY_DIRS
}
)
if
(
${${
LIBRARY
}
_RESOLVED
}
STREQUAL
"
${
LIBRARY
}
_RESOLVED-NOTFOUND"
)
message
(
FATAL_ERROR
"could not resolve
${
LIBRARY
}
"
)
endif
()
list
(
APPEND RESOLVED_LIBRARIES
${${
LIBRARY
}
_RESOLVED
}
)
endforeach
(
)
SET
(
${
prefix
}
_FOUND 1 PARENT_SCOPE
)
SET
(
${
prefix
}
_LIBRARIES
${
RESOLVED_LIBRARIES
}
PARENT_SCOPE
)
SET
(
${
prefix
}
_INCLUDE_DIRS
${${
prefix
}
_INCLUDE_DIRS
}
PARENT_SCOPE
)
SET
(
${
prefix
}
_LDFLAGS
${${
prefix
}
_LDFLAGS
}
PARENT_SCOPE
)
set
(
${
prefix
}
_FOUND 1 PARENT_SCOPE
)
set
(
${
prefix
}
_LIBRARIES
${
RESOLVED_LIBRARIES
}
PARENT_SCOPE
)
set
(
${
prefix
}
_INCLUDE_DIRS
${${
prefix
}
_INCLUDE_DIRS
}
PARENT_SCOPE
)
set
(
${
prefix
}
_LDFLAGS
${${
prefix
}
_LDFLAGS
}
PARENT_SCOPE
)
MESSAGE
(
STATUS
" Resolved libraries:
${
RESOLVED_LIBRARIES
}
"
)
ENDFUNCTION
()
message
(
STATUS
" Resolved libraries:
${
RESOLVED_LIBRARIES
}
"
)
endfunction
()
cmake/FindSecurity.cmake
View file @
23c5c315
...
...
@@ -7,22 +7,22 @@
# SECURITY_HAS_SSLCREATECONTEXT
#
FIND_PATH
(
SECURITY_INCLUDE_DIR NAMES Security/Security.h
)
FIND_LIBRARY
(
SECURITY_LIBRARIES NAMES Security
)
IF
(
SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES
)
IF
(
NOT Security_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found Security
${
SECURITY_LIBRARIES
}
"
)
ENDIF
()
SET
(
SECURITY_FOUND TRUE
)
SET
(
SECURITY_LDFLAGS
"-framework Security"
)
CHECK_LIBRARY_EXISTS
(
"
${
SECURITY_LIBRARIES
}
"
SSLCreateContext
"Security/SecureTransport.h"
SECURITY_HAS_SSLCREATECONTEXT
)
ENDIF
()
find_path
(
SECURITY_INCLUDE_DIR NAMES Security/Security.h
)
find_library
(
SECURITY_LIBRARIES NAMES Security
)
if
(
SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES
)
if
(
NOT Security_FIND_QUIETLY
)
message
(
STATUS
"Found Security
${
SECURITY_LIBRARIES
}
"
)
endif
()
set
(
SECURITY_FOUND TRUE
)
set
(
SECURITY_LDFLAGS
"-framework Security"
)
check_library_exists
(
"
${
SECURITY_LIBRARIES
}
"
SSLCreateContext
"Security/SecureTransport.h"
SECURITY_HAS_SSLCREATECONTEXT
)
endif
()
IF
(
Security_FIND_REQUIRED AND NOT SECURITY_FOUND
)
MESSAGE
(
FATAL_ERROR
"Security not found"
)
ENDIF
()
if
(
Security_FIND_REQUIRED AND NOT SECURITY_FOUND
)
message
(
FATAL_ERROR
"Security not found"
)
endif
()
MARK_AS_ADVANCED
(
mark_as_advanced
(
SECURITY_INCLUDE_DIR
SECURITY_LIBRARIES
)
cmake/Findfutimens.cmake
View file @
23c5c315
INCLUDE
(
EnableWarnings
)
include
(
EnableWarnings
)
IF
(
APPLE
)
if
(
APPLE
)
# We cannot simply CHECK_FUNCTION_EXISTS on macOS because
# MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
# that doesn't have futimens. Instead we need to enable warnings
# as errors, then check for the symbol existing in `sys/stat.h`,
# then reset warnings as errors.
ENABLE_WARNINGS
(
error
)
CHECK_SYMBOL_EXISTS
(
futimens sys/stat.h HAVE_FUTIMENS
)
DISABLE_WARNINGS
(
error
)
ELSE
()
CHECK_FUNCTION_EXISTS
(
futimens HAVE_FUTIMENS
)
ENDIF
()
enable_warnings
(
error
)
check_symbol_exists
(
futimens sys/stat.h HAVE_FUTIMENS
)
disable_warnings
(
error
)
else
()
check_function_exists
(
futimens HAVE_FUTIMENS
)
endif
()
cmake/FindmbedTLS.cmake
View file @
23c5c315
...
...
@@ -13,81 +13,74 @@
# Hint
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
SET
(
_MBEDTLS_ROOT_HINTS
${
MBEDTLS_ROOT_DIR
}
ENV MBEDTLS_ROOT_DIR
)
set
(
_MBEDTLS_ROOT_HINTS
${
MBEDTLS_ROOT_DIR
}
ENV MBEDTLS_ROOT_DIR
)
SET
(
_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS
${
_MBEDTLS_ROOT_HINTS
}
PATHS
${
_MBEDTLS_ROOT_PATHS
}
)
set
(
_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS
${
_MBEDTLS_ROOT_HINTS
}
PATHS
${
_MBEDTLS_ROOT_PATHS
}
)
FIND_PATH
(
MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES include
)
find_path
(
MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES include
)
IF
(
MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES
)
# Already in cache, be silent
SET
(
MBEDTLS_FIND_QUIETLY TRUE
)
ENDIF
()
if
(
MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES
)
# Already in cache, be silent
set
(
MBEDTLS_FIND_QUIETLY TRUE
)
endif
()
FIND_LIBRARY
(
MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
FIND_LIBRARY
(
MBEDX509_LIBRARY
NAMES mbedx509 libmbedx509
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
FIND_LIBRARY
(
MBEDCRYPTO_LIBRARY
NAMES mbedcrypto libmbedcrypto
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
find_library
(
MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
find_library
(
MBEDX509_LIBRARY
NAMES mbedx509 libmbedx509
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
find_library
(
MBEDCRYPTO_LIBRARY
NAMES mbedcrypto libmbedcrypto
${
_MBEDTLS_ROOT_HINTS_AND_PATHS
}
PATH_SUFFIXES library
)
IF
(
MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY
)
SET
(
MBEDTLS_FOUND TRUE
)
ENDIF
()
if
(
MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY
)
set
(
MBEDTLS_FOUND TRUE
)
endif
()
IF
(
MBEDTLS_FOUND
)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
GET_FILENAME_COMPONENT
(
MBEDTLS_LIBRARY_DIR
${
MBEDTLS_LIBRARY
}
PATH
)
GET_FILENAME_COMPONENT
(
MBEDTLS_LIBRARY_FILE
${
MBEDTLS_LIBRARY
}
NAME_WE
)
GET_FILENAME_COMPONENT
(
MBEDX509_LIBRARY_FILE
${
MBEDX509_LIBRARY
}
NAME_WE
)
GET_FILENAME_COMPONENT
(
MBEDCRYPTO_LIBRARY_FILE
${
MBEDCRYPTO_LIBRARY
}
NAME_WE
)
STRING
(
REGEX REPLACE
"^lib"
""
MBEDTLS_LIBRARY_FILE
${
MBEDTLS_LIBRARY_FILE
}
)
STRING
(
REGEX REPLACE
"^lib"
""
MBEDX509_LIBRARY_FILE
${
MBEDX509_LIBRARY_FILE
}
)
STRING
(
REGEX REPLACE
"^lib"
""
MBEDCRYPTO_LIBRARY_FILE
${
MBEDCRYPTO_LIBRARY_FILE
}
)
SET
(
MBEDTLS_LIBRARIES
"-L
${
MBEDTLS_LIBRARY_DIR
}
-l
${
MBEDTLS_LIBRARY_FILE
}
-l
${
MBEDX509_LIBRARY_FILE
}
-l
${
MBEDCRYPTO_LIBRARY_FILE
}
"
)
if
(
MBEDTLS_FOUND
)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
get_filename_component
(
MBEDTLS_LIBRARY_DIR
${
MBEDTLS_LIBRARY
}
PATH
)
get_filename_component
(
MBEDTLS_LIBRARY_FILE
${
MBEDTLS_LIBRARY
}
NAME_WE
)
get_filename_component
(
MBEDX509_LIBRARY_FILE
${
MBEDX509_LIBRARY
}
NAME_WE
)
get_filename_component
(
MBEDCRYPTO_LIBRARY_FILE
${
MBEDCRYPTO_LIBRARY
}
NAME_WE
)
string
(
REGEX REPLACE
"^lib"
""
MBEDTLS_LIBRARY_FILE
${
MBEDTLS_LIBRARY_FILE
}
)
string
(
REGEX REPLACE
"^lib"
""
MBEDX509_LIBRARY_FILE
${
MBEDX509_LIBRARY_FILE
}
)
string
(
REGEX REPLACE
"^lib"
""
MBEDCRYPTO_LIBRARY_FILE
${
MBEDCRYPTO_LIBRARY_FILE
}
)
set
(
MBEDTLS_LIBRARIES
"-L
${
MBEDTLS_LIBRARY_DIR
}
-l
${
MBEDTLS_LIBRARY_FILE
}
-l
${
MBEDX509_LIBRARY_FILE
}
-l
${
MBEDCRYPTO_LIBRARY_FILE
}
"
)
IF
(
NOT MBEDTLS_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found mbedTLS:"
)
FILE
(
READ
${
MBEDTLS_INCLUDE_DIR
}
/mbedtls/version.h MBEDTLSCONTENT
)
STRING
(
REGEX MATCH
"MBEDTLS_VERSION_STRING +
\"
[0-9|.]+
\"
"
MBEDTLSMATCH
${
MBEDTLSCONTENT
}
)
IF
(
MBEDTLSMATCH
)
STRING
(
REGEX REPLACE
"MBEDTLS_VERSION_STRING +
\"
([0-9|.]+)
\"
"
"
\\
1"
MBEDTLS_VERSION
${
MBEDTLSMATCH
}
)
MESSAGE
(
STATUS
" version
${
MBEDTLS_VERSION
}
"
)
ENDIF
(
MBEDTLSMATCH
)
MESSAGE
(
STATUS
" TLS:
${
MBEDTLS_LIBRARY
}
"
)
MESSAGE
(
STATUS
" X509:
${
MBEDX509_LIBRARY
}
"
)
MESSAGE
(
STATUS
" Crypto:
${
MBEDCRYPTO_LIBRARY
}
"
)
ENDIF
(
NOT MBEDTLS_FIND_QUIETLY
)
ELSE
(
MBEDTLS_FOUND
)
IF
(
MBEDTLS_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Could not find mbedTLS"
)
ENDIF
(
MBEDTLS_FIND_REQUIRED
)
ENDIF
(
MBEDTLS_FOUND
)
if
(
NOT MBEDTLS_FIND_QUIETLY
)
message
(
STATUS
"Found mbedTLS:"
)
file
(
READ
${
MBEDTLS_INCLUDE_DIR
}
/mbedtls/version.h MBEDTLSCONTENT
)
string
(
REGEX MATCH
"MBEDTLS_VERSION_STRING +
\"
[0-9|.]+
\"
"
MBEDTLSMATCH
${
MBEDTLSCONTENT
}
)
if
(
MBEDTLSMATCH
)
string
(
REGEX REPLACE
"MBEDTLS_VERSION_STRING +
\"
([0-9|.]+)
\"
"
"
\\
1"
MBEDTLS_VERSION
${
MBEDTLSMATCH
}
)
message
(
STATUS
" version
${
MBEDTLS_VERSION
}
"
)
endif
(
)
message
(
STATUS
" TLS:
${
MBEDTLS_LIBRARY
}
"
)
message
(
STATUS
" X509:
${
MBEDX509_LIBRARY
}
"
)
message
(
STATUS
" Crypto:
${
MBEDCRYPTO_LIBRARY
}
"
)
endif
(
)
else
(
MBEDTLS_FOUND
)
if
(
MBEDTLS_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Could not find mbedTLS"
)
endif
(
)
endif
(
)
MARK_AS_ADVANCED
(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)
mark_as_advanced
(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)
cmake/IdeSplitSources.cmake
View file @
23c5c315
...
...
@@ -3,20 +3,20 @@
# Visual Studio, so that you can navigate into the libgit2_tests project,
# and see the folders within the tests folder (instead of just seeing all
# source and tests in a single folder.)
FUNCTION
(
IDE_SPLIT_SOURCES target
)
IF
(
MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode
)
GET_TARGET_PROPERTY
(
sources
${
target
}
SOURCES
)
FOREACH
(
source
${
sources
}
)
IF
(
source MATCHES
".*/"
)
STRING
(
REPLACE
${
libgit2_SOURCE_DIR
}
/
""
rel
${
source
}
)
IF
(
rel
)
STRING
(
REGEX REPLACE
"/([^/]*)$"
""
rel
${
rel
}
)
IF
(
rel
)
STRING
(
REPLACE
"/"
"
\\\\
"
rel
${
rel
}
)
SOURCE_GROUP
(
${
rel
}
FILES
${
source
}
)
ENDIF
()
ENDIF
()
ENDIF
()
ENDFOREACH
()
ENDIF
()
ENDFUNCTION
()
function
(
IDE_SPLIT_SOURCES target
)
if
(
MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode
)
get_target_property
(
sources
${
target
}
SOURCES
)
foreach
(
source
${
sources
}
)
if
(
source MATCHES
".*/"
)
string
(
REPLACE
${
libgit2_SOURCE_DIR
}
/
""
rel
${
source
}
)
if
(
rel
)
string
(
REGEX REPLACE
"/([^/]*)$"
""
rel
${
rel
}
)
if
(
rel
)
string
(
REPLACE
"/"
"
\\\\
"
rel
${
rel
}
)
source_group
(
${
rel
}
FILES
${
source
}
)
endif
()
endif
()
endif
()
endforeach
()
endif
()
endfunction
()
cmake/PkgBuildConfig.cmake
View file @
23c5c315
...
...
@@ -2,76 +2,76 @@
#
function
(
pkg_build_config
)
set
(
options
)
set
(
oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF
)
set
(
multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS
)
set
(
options
)
set
(
oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF
)
set
(
multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS
)
cmake_parse_arguments
(
PKGCONFIG
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
PKGCONFIG
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
if
(
NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME
)
set
(
PKGCONFIG_FILENAME
${
PKGCONFIG_NAME
}
)
endif
()
if
(
NOT DEFINED PKGCONFIG_FILENAME
)
message
(
FATAL_ERROR
"Missing FILENAME argument"
)
endif
()
set
(
PKGCONFIG_FILE
"
${
PROJECT_BINARY_DIR
}
/
${
PKGCONFIG_FILENAME
}
.pc"
)
if
(
NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME
)
set
(
PKGCONFIG_FILENAME
${
PKGCONFIG_NAME
}
)
endif
()
if
(
NOT DEFINED PKGCONFIG_FILENAME
)
message
(
FATAL_ERROR
"Missing FILENAME argument"
)
endif
()
set
(
PKGCONFIG_FILE
"
${
PROJECT_BINARY_DIR
}
/
${
PKGCONFIG_FILENAME
}
.pc"
)
if
(
NOT DEFINED PKGCONFIG_DESCRIPTION
)
message
(
FATAL_ERROR
"Missing DESCRIPTION argument"
)
endif
()
if
(
NOT DEFINED PKGCONFIG_DESCRIPTION
)
message
(
FATAL_ERROR
"Missing DESCRIPTION argument"
)
endif
()
if
(
NOT DEFINED PKGCONFIG_VERSION
)
message
(
FATAL_ERROR
"Missing VERSION argument"
)
endif
()
if
(
NOT DEFINED PKGCONFIG_VERSION
)
message
(
FATAL_ERROR
"Missing VERSION argument"
)
endif
()
# Write .pc "header"
file
(
WRITE
"
${
PKGCONFIG_FILE
}
"
"prefix=
\"
${
CMAKE_INSTALL_PREFIX
}
\"\n
"
"libdir=
\"
${
CMAKE_INSTALL_FULL_LIBDIR
}
\"\n
"
"includedir=
\"
${
CMAKE_INSTALL_FULL_INCLUDEDIR
}
\"\n
"
"
\n
"
"Name:
${
PKGCONFIG_NAME
}
\n
"
"Description:
${
PKGCONFIG_DESCRIPTION
}
\n
"
"Version:
${
PKGCONFIG_VERSION
}
\n
"
)
# Write .pc "header"
file
(
WRITE
"
${
PKGCONFIG_FILE
}
"
"prefix=
\"
${
CMAKE_INSTALL_PREFIX
}
\"\n
"
"libdir=
\"
${
CMAKE_INSTALL_FULL_LIBDIR
}
\"\n
"
"includedir=
\"
${
CMAKE_INSTALL_FULL_INCLUDEDIR
}
\"\n
"
"
\n
"
"Name:
${
PKGCONFIG_NAME
}
\n
"
"Description:
${
PKGCONFIG_DESCRIPTION
}
\n
"
"Version:
${
PKGCONFIG_VERSION
}
\n
"
)
# Prepare Libs
if
(
NOT DEFINED PKGCONFIG_LIBS_SELF
)
set
(
PKGCONFIG_LIBS_SELF
"
${
PKGCONFIG_FILE
}
"
)
endif
()
# Prepare Libs
if
(
NOT DEFINED PKGCONFIG_LIBS_SELF
)
set
(
PKGCONFIG_LIBS_SELF
"
${
PKGCONFIG_FILE
}
"
)
endif
()
if
(
NOT DEFINED PKGCONFIG_LIBS
)
set
(
PKGCONFIG_LIBS
"-l
${
PKGCONFIG_LIBS_SELF
}
"
)
else
()
list
(
INSERT PKGCONFIG_LIBS 0
"-l
${
PKGCONFIG_LIBS_SELF
}
"
)
endif
()
if
(
NOT DEFINED PKGCONFIG_LIBS
)
set
(
PKGCONFIG_LIBS
"-l
${
PKGCONFIG_LIBS_SELF
}
"
)
else
()
list
(
INSERT PKGCONFIG_LIBS 0
"-l
${
PKGCONFIG_LIBS_SELF
}
"
)
endif
()
list
(
REMOVE_DUPLICATES PKGCONFIG_LIBS
)
string
(
REPLACE
";"
" "
PKGCONFIG_LIBS
"
${
PKGCONFIG_LIBS
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Libs: -L
\$
{libdir}
${
PKGCONFIG_LIBS
}
\n
"
)
list
(
REMOVE_DUPLICATES PKGCONFIG_LIBS
)
string
(
REPLACE
";"
" "
PKGCONFIG_LIBS
"
${
PKGCONFIG_LIBS
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Libs: -L
\$
{libdir}
${
PKGCONFIG_LIBS
}
\n
"
)
# Prepare Libs.private
if
(
DEFINED PKGCONFIG_PRIVATE_LIBS
)
list
(
REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS
)
string
(
REPLACE
";"
" "
PKGCONFIG_PRIVATE_LIBS
"
${
PKGCONFIG_PRIVATE_LIBS
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Libs.private:
${
PKGCONFIG_PRIVATE_LIBS
}
\n
"
)
endif
()
# Prepare Libs.private
if
(
DEFINED PKGCONFIG_PRIVATE_LIBS
)
list
(
REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS
)
string
(
REPLACE
";"
" "
PKGCONFIG_PRIVATE_LIBS
"
${
PKGCONFIG_PRIVATE_LIBS
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Libs.private:
${
PKGCONFIG_PRIVATE_LIBS
}
\n
"
)
endif
()
# Prepare Requires.private
if
(
DEFINED PKGCONFIG_REQUIRES
)
list
(
REMOVE_DUPLICATES PKGCONFIG_REQUIRES
)
string
(
REPLACE
";"
" "
PKGCONFIG_REQUIRES
"
${
PKGCONFIG_REQUIRES
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Requires.private:
${
PKGCONFIG_REQUIRES
}
\n
"
)
endif
()
# Prepare Requires.private
if
(
DEFINED PKGCONFIG_REQUIRES
)
list
(
REMOVE_DUPLICATES PKGCONFIG_REQUIRES
)
string
(
REPLACE
";"
" "
PKGCONFIG_REQUIRES
"
${
PKGCONFIG_REQUIRES
}
"
)
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Requires.private:
${
PKGCONFIG_REQUIRES
}
\n
"
)
endif
()
# Prepare Cflags
if
(
DEFINED PKGCONFIG_CFLAGS
)
string
(
REPLACE
";"
" "
PKGCONFIG_CFLAGS
"
${
PKGCONFIG_CFLAGS
}
"
)
else
()
set
(
PKGCONFIG_CFLAGS
""
)
endif
()
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Cflags: -I
\$
{includedir}
${
PKGCONFIG_CFLAGS
}
\n
"
)
# Prepare Cflags
if
(
DEFINED PKGCONFIG_CFLAGS
)
string
(
REPLACE
";"
" "
PKGCONFIG_CFLAGS
"
${
PKGCONFIG_CFLAGS
}
"
)
else
()
set
(
PKGCONFIG_CFLAGS
""
)
endif
()
file
(
APPEND
"
${
PKGCONFIG_FILE
}
"
"Cflags: -I
\$
{includedir}
${
PKGCONFIG_CFLAGS
}
\n
"
)
# Install .pc file
install
(
FILES
"
${
PKGCONFIG_FILE
}
"
DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
/pkgconfig"
)
# Install .pc file
install
(
FILES
"
${
PKGCONFIG_FILE
}
"
DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
/pkgconfig"
)
endfunction
()
cmake/SanitizeBool.cmake
View file @
23c5c315
FUNCTION
(
SanitizeBool VAR
)
STRING
(
TOLOWER
"
${${
VAR
}}
"
VALUE
)
IF
(
VALUE STREQUAL
"on"
)
SET
(
${
VAR
}
"ON"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"yes"
)
SET
(
${
VAR
}
"ON"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"true"
)
SET
(
${
VAR
}
"ON"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"1"
)
SET
(
${
VAR
}
"ON"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"off"
)
SET
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"no"
)
SET
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"false"
)
SET
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
ELSEIF
(
VALUE STREQUAL
"0"
)
SET
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
ENDIF
()
ENDFUNCTION
()
function
(
SanitizeBool VAR
)
string
(
TOLOWER
"
${${
VAR
}}
"
VALUE
)
if
(
VALUE STREQUAL
"on"
)
set
(
${
VAR
}
"ON"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"yes"
)
set
(
${
VAR
}
"ON"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"true"
)
set
(
${
VAR
}
"ON"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"1"
)
set
(
${
VAR
}
"ON"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"off"
)
set
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"no"
)
set
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"false"
)
set
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
elseif
(
VALUE STREQUAL
"0"
)
set
(
${
VAR
}
"OFF"
PARENT_SCOPE
)
endif
()
endfunction
()
cmake/SelectGSSAPI.cmake
View file @
23c5c315
INCLUDE
(
SanitizeBool
)
include
(
SanitizeBool
)
# We try to find any packages our backends might use
FIND_PACKAGE
(
GSSAPI
)
IF
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
INCLUDE
(
FindGSSFramework
)
ENDIF
()
find_package
(
GSSAPI
)
if
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
include
(
FindGSSFramework
)
endif
()
IF
(
USE_GSSAPI
)
if
(
USE_GSSAPI
)
# Auto-select GSS backend
SanitizeB
ool
(
USE_GSSAPI
)
IF
(
USE_GSSAPI STREQUAL ON
)
IF
(
GSSFRAMEWORK_FOUND
)
SET
(
USE_GSSAPI
"GSS.framework"
)
ELSEIF
(
GSSAPI_FOUND
)
SET
(
USE_GSSAPI
"gssapi"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unable to autodetect a usable GSS backend."
sanitizeb
ool
(
USE_GSSAPI
)
if
(
USE_GSSAPI STREQUAL ON
)
if
(
GSSFRAMEWORK_FOUND
)
set
(
USE_GSSAPI
"GSS.framework"
)
elseif
(
GSSAPI_FOUND
)
set
(
USE_GSSAPI
"gssapi"
)
else
()
message
(
FATAL_ERROR
"Unable to autodetect a usable GSS backend."
"Please pass the backend name explicitly (-DUSE_GSS=backend)"
)
ENDIF
()
ENDIF
()
endif
()
endif
()
# Check that we can find what's required for the selected backend
IF
(
USE_GSSAPI STREQUAL
"GSS.framework"
)
IF
(
NOT GSSFRAMEWORK_FOUND
)
MESSAGE
(
FATAL_ERROR
"Asked for GSS.framework backend, but it wasn't found"
)
ENDIF
()
if
(
USE_GSSAPI STREQUAL
"GSS.framework"
)
if
(
NOT GSSFRAMEWORK_FOUND
)
message
(
FATAL_ERROR
"Asked for GSS.framework backend, but it wasn't found"
)
endif
()
LIST
(
APPEND LIBGIT2
_LIBS
${
GSSFRAMEWORK_LIBRARIES
}
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS
${
GSSFRAMEWORK_LIBRARIES
}
)
SET
(
GIT_GSSFRAMEWORK 1
)
ADD_FEATURE_INFO
(
SPNEGO GIT_GSSFRAMEWORK
"SPNEGO authentication support (
${
USE_GSSAPI
}
)"
)
ELSEIF
(
USE_GSSAPI STREQUAL
"gssapi"
)
IF
(
NOT GSSAPI_FOUND
)
MESSAGE
(
FATAL_ERROR
"Asked for gssapi GSS backend, but it wasn't found"
)
ENDIF
()
set
(
GIT_GSSFRAMEWORK 1
)
add_feature_info
(
SPNEGO GIT_GSSFRAMEWORK
"SPNEGO authentication support (
${
USE_GSSAPI
}
)"
)
elseif
(
USE_GSSAPI STREQUAL
"gssapi"
)
if
(
NOT GSSAPI_FOUND
)
message
(
FATAL_ERROR
"Asked for gssapi GSS backend, but it wasn't found"
)
endif
()
LIST
(
APPEND LIBGIT2
_LIBS
${
GSSAPI_LIBRARIES
}
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS
${
GSSAPI_LIBRARIES
}
)
SET
(
GIT_GSSAPI 1
)
ADD_FEATURE_INFO
(
SPNEGO GIT_GSSAPI
"SPNEGO authentication support (
${
USE_GSSAPI
}
)"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Asked for backend
${
USE_GSSAPI
}
but it wasn't found"
)
ENDIF
()
ELSE
()
SET
(
GIT_GSSAPI 0
)
ADD_FEATURE_INFO
(
SPNEGO NO
"SPNEGO authentication support"
)
ENDIF
()
set
(
GIT_GSSAPI 1
)
add_feature_info
(
SPNEGO GIT_GSSAPI
"SPNEGO authentication support (
${
USE_GSSAPI
}
)"
)
else
()
message
(
FATAL_ERROR
"Asked for backend
${
USE_GSSAPI
}
but it wasn't found"
)
endif
()
else
()
set
(
GIT_GSSAPI 0
)
add_feature_info
(
SPNEGO NO
"SPNEGO authentication support"
)
endif
()
cmake/SelectHTTPParser.cmake
View file @
23c5c315
...
...
@@ -4,7 +4,7 @@ if(USE_HTTP_PARSER STREQUAL "system")
if
(
HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
HTTP_PARSER_INCLUDE_DIRS
}
)
list
(
APPEND LIBGIT2_LIBS
${
HTTP_PARSER_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
HTTP_PARSER_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lhttp_parser"
)
add_feature_info
(
http-parser ON
"http-parser support (system)"
)
else
()
...
...
@@ -13,7 +13,7 @@ if(USE_HTTP_PARSER STREQUAL "system")
else
()
message
(
STATUS
"http-parser version 2 was not found or disabled; using bundled 3rd-party sources."
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/http-parser"
"
${
libgit2_BINARY_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_OBJECTS
"$<TARGET_OBJECTS:http-parser>"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS
"$<TARGET_OBJECTS:http-parser>"
)
add_feature_info
(
http-parser ON
"http-parser support (bundled)"
)
endif
()
cmake/SelectHTTPSBackend.cmake
View file @
23c5c315
INCLUDE
(
SanitizeBool
)
include
(
SanitizeBool
)
# We try to find any packages our backends might use
FIND_PACKAGE
(
OpenSSL
)
FIND_PACKAGE
(
mbedTLS
)
IF
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
FIND_PACKAGE
(
Security
)
FIND_PACKAGE
(
CoreFoundation
)
ENDIF
()
find_package
(
OpenSSL
)
find_package
(
mbedTLS
)
if
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
find_package
(
Security
)
find_package
(
CoreFoundation
)
endif
()
IF
(
USE_HTTPS
)
if
(
USE_HTTPS
)
# Auto-select TLS backend
SanitizeB
ool
(
USE_HTTPS
)
IF
(
USE_HTTPS STREQUAL ON
)
IF
(
SECURITY_FOUND
)
IF
(
SECURITY_HAS_SSLCREATECONTEXT
)
SET
(
USE_HTTPS
"SecureTransport"
)
ELSE
()
MESSAGE
(
STATUS
"Security framework is too old, falling back to OpenSSL"
)
SET
(
USE_HTTPS
"OpenSSL"
)
ENDIF
()
ELSEIF
(
USE_WINHTTP
)
SET
(
USE_HTTPS
"WinHTTP"
)
ELSEIF
(
OPENSSL_FOUND
)
SET
(
USE_HTTPS
"OpenSSL"
)
ELSEIF
(
MBEDTLS_FOUND
)
SET
(
USE_HTTPS
"mbedTLS"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unable to autodetect a usable HTTPS backend."
sanitizeb
ool
(
USE_HTTPS
)
if
(
USE_HTTPS STREQUAL ON
)
if
(
SECURITY_FOUND
)
if
(
SECURITY_HAS_SSLCREATECONTEXT
)
set
(
USE_HTTPS
"SecureTransport"
)
else
()
message
(
STATUS
"Security framework is too old, falling back to OpenSSL"
)
set
(
USE_HTTPS
"OpenSSL"
)
endif
()
elseif
(
USE_WINHTTP
)
set
(
USE_HTTPS
"WinHTTP"
)
elseif
(
OPENSSL_FOUND
)
set
(
USE_HTTPS
"OpenSSL"
)
elseif
(
MBEDTLS_FOUND
)
set
(
USE_HTTPS
"mbedTLS"
)
else
()
message
(
FATAL_ERROR
"Unable to autodetect a usable HTTPS backend."
"Please pass the backend name explicitly (-DUSE_HTTPS=backend)"
)
ENDIF
()
ENDIF
()
endif
()
endif
()
# Check that we can find what's required for the selected backend
IF
(
USE_HTTPS STREQUAL
"SecureTransport"
)
IF
(
NOT COREFOUNDATION_FOUND
)
MESSAGE
(
FATAL_ERROR
"Cannot use SecureTransport backend, CoreFoundation.framework not found"
)
ENDIF
()
IF
(
NOT SECURITY_FOUND
)
MESSAGE
(
FATAL_ERROR
"Cannot use SecureTransport backend, Security.framework not found"
)
ENDIF
()
IF
(
NOT SECURITY_HAS_SSLCREATECONTEXT
)
MESSAGE
(
FATAL_ERROR
"Cannot use SecureTransport backend, SSLCreateContext not supported"
)
ENDIF
()
if
(
USE_HTTPS STREQUAL
"SecureTransport"
)
if
(
NOT COREFOUNDATION_FOUND
)
message
(
FATAL_ERROR
"Cannot use SecureTransport backend, CoreFoundation.framework not found"
)
endif
()
if
(
NOT SECURITY_FOUND
)
message
(
FATAL_ERROR
"Cannot use SecureTransport backend, Security.framework not found"
)
endif
()
if
(
NOT SECURITY_HAS_SSLCREATECONTEXT
)
message
(
FATAL_ERROR
"Cannot use SecureTransport backend, SSLCreateContext not supported"
)
endif
()
SET
(
GIT_SECURE_TRANSPORT 1
)
LIST
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
SECURITY_INCLUDE_DIR
}
)
LIST
(
APPEND LIBGIT2
_LIBS
${
COREFOUNDATION_LDFLAGS
}
${
SECURITY_LDFLAGS
}
)
LIST
(
APPEND LIBGIT2_PC_LIBS
${
COREFOUNDATION_LDFLAGS
}
${
SECURITY_LDFLAGS
}
)
ELSEIF
(
USE_HTTPS STREQUAL
"OpenSSL"
)
IF
(
NOT OPENSSL_FOUND
)
MESSAGE
(
FATAL_ERROR
"Asked for OpenSSL TLS backend, but it wasn't found"
)
ENDIF
()
set
(
GIT_SECURE_TRANSPORT 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
SECURITY_INCLUDE_DIR
}
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS
${
COREFOUNDATION_LDFLAGS
}
${
SECURITY_LDFLAGS
}
)
list
(
APPEND LIBGIT2_PC_LIBS
${
COREFOUNDATION_LDFLAGS
}
${
SECURITY_LDFLAGS
}
)
elseif
(
USE_HTTPS STREQUAL
"OpenSSL"
)
if
(
NOT OPENSSL_FOUND
)
message
(
FATAL_ERROR
"Asked for OpenSSL TLS backend, but it wasn't found"
)
endif
()
SET
(
GIT_OPENSSL 1
)
LIST
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
OPENSSL_INCLUDE_DIR
}
)
LIST
(
APPEND LIBGIT2
_LIBS
${
OPENSSL_LIBRARIES
}
)
LIST
(
APPEND LIBGIT2_PC_LIBS
${
OPENSSL_LDFLAGS
}
)
LIST
(
APPEND LIBGIT2_PC_REQUIRES
"openssl"
)
ELSEIF
(
USE_HTTPS STREQUAL
"mbedTLS"
)
IF
(
NOT MBEDTLS_FOUND
)
MESSAGE
(
FATAL_ERROR
"Asked for mbedTLS backend, but it wasn't found"
)
ENDIF
()
set
(
GIT_OPENSSL 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
OPENSSL_INCLUDE_DIR
}
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS
${
OPENSSL_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_LIBS
${
OPENSSL_LDFLAGS
}
)
list
(
APPEND LIBGIT2_PC_REQUIRES
"openssl"
)
elseif
(
USE_HTTPS STREQUAL
"mbedTLS"
)
if
(
NOT MBEDTLS_FOUND
)
message
(
FATAL_ERROR
"Asked for mbedTLS backend, but it wasn't found"
)
endif
()
IF
(
NOT CERT_LOCATION
)
MESSAGE
(
STATUS
"Auto-detecting default certificates location"
)
IF
(
CMAKE_SYSTEM_NAME MATCHES Darwin
)
if
(
NOT CERT_LOCATION
)
message
(
STATUS
"Auto-detecting default certificates location"
)
if
(
CMAKE_SYSTEM_NAME MATCHES Darwin
)
# Check for an Homebrew installation
SET
(
OPENSSL_CMD
"/usr/local/opt/openssl/bin/openssl"
)
ELSE
()
SET
(
OPENSSL_CMD
"openssl"
)
ENDIF
()
EXECUTE_PROCESS
(
COMMAND
${
OPENSSL_CMD
}
version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
IF
(
OPENSSL_DIR
)
STRING
(
REGEX REPLACE
"^OPENSSLDIR:
\"
(.*)
\"
$"
"
\\
1/"
OPENSSL_DIR
${
OPENSSL_DIR
}
)
set
(
OPENSSL_CMD
"/usr/local/opt/openssl/bin/openssl"
)
else
()
set
(
OPENSSL_CMD
"openssl"
)
endif
()
execute_process
(
COMMAND
${
OPENSSL_CMD
}
version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
OPENSSL_DIR
)
string
(
REGEX REPLACE
"^OPENSSLDIR:
\"
(.*)
\"
$"
"
\\
1/"
OPENSSL_DIR
${
OPENSSL_DIR
}
)
SET
(
OPENSSL_CA_LOCATIONS
set
(
OPENSSL_CA_LOCATIONS
"ca-bundle.pem"
# OpenSUSE Leap 42.1
"cert.pem"
# Ubuntu 14.04, FreeBSD
"certs/ca-certificates.crt"
# Ubuntu 16.04
"certs/ca.pem"
# Debian 7
)
FOREACH
(
SUFFIX IN LISTS OPENSSL_CA_LOCATIONS
)
SET
(
LOC
"
${
OPENSSL_DIR
}${
SUFFIX
}
"
)
IF
(
NOT CERT_LOCATION AND EXISTS
"
${
OPENSSL_DIR
}${
SUFFIX
}
"
)
SET
(
CERT_LOCATION
${
LOC
}
)
ENDIF
()
ENDFOREACH
()
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION"
)
ENDIF
()
ENDIF
()
foreach
(
SUFFIX IN LISTS OPENSSL_CA_LOCATIONS
)
set
(
LOC
"
${
OPENSSL_DIR
}${
SUFFIX
}
"
)
if
(
NOT CERT_LOCATION AND EXISTS
"
${
OPENSSL_DIR
}${
SUFFIX
}
"
)
set
(
CERT_LOCATION
${
LOC
}
)
endif
()
endforeach
()
else
()
message
(
FATAL_ERROR
"Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION"
)
endif
()
endif
()
IF
(
CERT_LOCATION
)
IF
(
NOT EXISTS
${
CERT_LOCATION
}
)
MESSAGE
(
FATAL_ERROR
"Cannot use CERT_LOCATION=
${
CERT_LOCATION
}
as it doesn't exist"
)
ENDIF
()
ADD_FEATURE_INFO
(
CERT_LOCATION ON
"using certificates from
${
CERT_LOCATION
}
"
)
ADD_DEFINITIONS
(
-DGIT_DEFAULT_CERT_LOCATION=
"
${
CERT_LOCATION
}
"
)
ENDIF
()
if
(
CERT_LOCATION
)
if
(
NOT EXISTS
${
CERT_LOCATION
}
)
message
(
FATAL_ERROR
"Cannot use CERT_LOCATION=
${
CERT_LOCATION
}
as it doesn't exist"
)
endif
()
add_feature_info
(
CERT_LOCATION ON
"using certificates from
${
CERT_LOCATION
}
"
)
add_definitions
(
-DGIT_DEFAULT_CERT_LOCATION=
"
${
CERT_LOCATION
}
"
)
endif
()
SET
(
GIT_MBEDTLS 1
)
LIST
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
MBEDTLS_INCLUDE_DIR
}
)
LIST
(
APPEND LIBGIT2
_LIBS
${
MBEDTLS_LIBRARIES
}
)
set
(
GIT_MBEDTLS 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
MBEDTLS_INCLUDE_DIR
}
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS
${
MBEDTLS_LIBRARIES
}
)
# mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own
LIST
(
APPEND LIBGIT2_PC_LIBS
${
MBEDTLS_LIBRARIES
}
)
ELSEIF
(
USE_HTTPS STREQUAL
"WinHTTP"
)
list
(
APPEND LIBGIT2_PC_LIBS
${
MBEDTLS_LIBRARIES
}
)
elseif
(
USE_HTTPS STREQUAL
"WinHTTP"
)
# WinHTTP setup was handled in the WinHTTP-specific block above
ELSEIF
(
USE_HTTPS STREQUAL
"OpenSSL-Dynamic"
)
SET
(
GIT_OPENSSL 1
)
SET
(
GIT_OPENSSL_DYNAMIC 1
)
LIST
(
APPEND LIBGIT2
_LIBS dl
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Asked for backend
${
USE_HTTPS
}
but it wasn't found"
)
ENDIF
()
elseif
(
USE_HTTPS STREQUAL
"OpenSSL-Dynamic"
)
set
(
GIT_OPENSSL 1
)
set
(
GIT_OPENSSL_DYNAMIC 1
)
list
(
APPEND LIBGIT2_SYSTEM
_LIBS dl
)
else
()
message
(
FATAL_ERROR
"Asked for backend
${
USE_HTTPS
}
but it wasn't found"
)
endif
()
SET
(
GIT_HTTPS 1
)
ADD_FEATURE_INFO
(
HTTPS GIT_HTTPS
"using
${
USE_HTTPS
}
"
)
ELSE
()
SET
(
GIT_HTTPS 0
)
ADD_FEATURE_INFO
(
HTTPS NO
""
)
ENDIF
()
set
(
GIT_HTTPS 1
)
add_feature_info
(
HTTPS GIT_HTTPS
"using
${
USE_HTTPS
}
"
)
else
()
set
(
GIT_HTTPS 0
)
add_feature_info
(
HTTPS NO
""
)
endif
()
cmake/SelectHashes.cmake
View file @
23c5c315
# Select a hash backend
INCLUDE
(
SanitizeBool
)
include
(
SanitizeBool
)
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
sanitizebool
(
USE_SHA1
)
SanitizeBool
(
USE_SHA1
)
IF
(
USE_SHA1 STREQUAL ON
)
if
(
USE_SHA1 STREQUAL ON
)
SET
(
USE_SHA1
"CollisionDetection"
)
ELSEIF
(
USE_SHA1 STREQUAL
"HTTPS"
)
IF
(
USE_HTTPS STREQUAL
"SecureTransport"
)
SET
(
USE_SHA1
"CommonCrypto"
)
ELSEIF
(
USE_HTTPS STREQUAL
"WinHTTP"
)
SET
(
USE_SHA1
"Win32"
)
ELSEIF
(
USE_HTTPS
)
SET
(
USE_SHA1
${
USE_HTTPS
}
)
ELSE
()
SET
(
USE_SHA1
"CollisionDetection"
)
ENDIF
()
ENDIF
()
elseif
(
USE_SHA1 STREQUAL
"HTTPS"
)
if
(
USE_HTTPS STREQUAL
"SecureTransport"
)
set
(
USE_SHA1
"CommonCrypto"
)
elseif
(
USE_HTTPS STREQUAL
"WinHTTP"
)
set
(
USE_SHA1
"Win32"
)
elseif
(
USE_HTTPS
)
set
(
USE_SHA1
${
USE_HTTPS
}
)
else
()
set
(
USE_SHA1
"CollisionDetection"
)
endif
()
endif
()
IF
(
USE_SHA1 STREQUAL
"CollisionDetection"
)
SET
(
GIT_SHA1_COLLISIONDETECT 1
)
ADD_DEFINITIONS
(
-DSHA1DC_NO_STANDARD_INCLUDES=1
)
ADD_DEFINITIONS
(
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\
"common.h
\"
)
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=
\"
common.h
\"
)
FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
ELSEIF(USE_SHA1 STREQUAL "
OpenSSL
")
if
(
USE_SHA1 STREQUAL
"CollisionDetection"
)
set
(
GIT_SHA1_COLLISIONDETECT 1
)
add_definitions
(
-DSHA1DC_NO_STANDARD_INCLUDES=1
)
add_definitions
(
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\
"common.h
\"
)
add_definitions(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=
\"
common.h
\"
)
elseif(USE_SHA1 STREQUAL "
OpenSSL
")
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS
SET(GIT_SHA1_OPENSSL 1)
IF(CMAKE_SYSTEM_NAME MATCHES "
FreeBSD
")
LIST(APPEND LIBGIT2_PC_LIBS "
-lssl
")
ELSE()
LIST(APPEND LIBGIT2_PC_REQUIRES "
openssl
")
ENDIF()
FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
ELSEIF(USE_SHA1 STREQUAL "
CommonCrypto
")
SET(GIT_SHA1_COMMON_CRYPTO 1)
FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
ELSEIF(USE_SHA1 STREQUAL "
mbedTLS
")
SET(GIT_SHA1_MBEDTLS 1)
FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES
${
MBEDTLS_INCLUDE_DIR
}
)
LIST(APPEND LIBGIT2_LIBS
${
MBEDTLS_LIBRARIES
}
)
set(GIT_SHA1_OPENSSL 1)
if(CMAKE_SYSTEM_NAME MATCHES "
FreeBSD
")
list(APPEND LIBGIT2_PC_LIBS "
-lssl
")
else()
list(APPEND LIBGIT2_PC_REQUIRES "
openssl
")
endif()
elseif(USE_SHA1 STREQUAL "
CommonCrypto
")
set(GIT_SHA1_COMMON_CRYPTO 1)
elseif(USE_SHA1 STREQUAL "
mbedTLS
")
set(GIT_SHA1_MBEDTLS 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES
${
MBEDTLS_INCLUDE_DIR
}
)
list(APPEND LIBGIT2_SYSTEM_LIBS
${
MBEDTLS_LIBRARIES
}
)
# mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own
LIST(APPEND LIBGIT2_PC_LIBS
${
MBEDTLS_LIBRARIES
}
)
ELSEIF(USE_SHA1 STREQUAL "
Win32
")
SET(GIT_SHA1_WIN32 1)
FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
ELSEIF(USE_SHA1 STREQUAL "
Generic
")
FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
ELSE()
MESSAGE(FATAL_ERROR "
Asked for unknown SHA1 backend:
${
USE_SHA1
}
")
ENDIF()
list(APPEND LIBGIT2_PC_LIBS
${
MBEDTLS_LIBRARIES
}
)
elseif(USE_SHA1 STREQUAL "
Win32
")
set(GIT_SHA1_WIN32 1)
elseif(NOT (USE_SHA1 STREQUAL "
Generic
"))
message(FATAL_ERROR "
Asked for unknown SHA1 backend:
${
USE_SHA1
}
")
endif()
list(APPEND SRC_SHA1 "
hash/sha1.h
")
list(SORT SRC_SHA1)
ADD_FEATURE_INFO(SHA ON "
using
${
USE_SHA1
}
")
add_feature_info(SHA ON "
using
${
USE_SHA1
}
")
cmake/SelectRegex.cmake
View file @
23c5c315
...
...
@@ -27,14 +27,14 @@ elseif(REGEX_BACKEND STREQUAL "pcre2")
set
(
GIT_REGEX_PCRE2 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
PCRE2_INCLUDE_DIRS
}
)
list
(
APPEND LIBGIT2_LIBS
${
PCRE2_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
PCRE2_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_REQUIRES
"libpcre2-8"
)
elseif
(
REGEX_BACKEND STREQUAL
"pcre"
)
add_feature_info
(
regex ON
"using system PCRE"
)
set
(
GIT_REGEX_PCRE 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
PCRE_INCLUDE_DIRS
}
)
list
(
APPEND LIBGIT2_LIBS
${
PCRE_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
PCRE_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_REQUIRES
"libpcre"
)
elseif
(
REGEX_BACKEND STREQUAL
"regcomp"
)
add_feature_info
(
regex ON
"using system regcomp"
)
...
...
@@ -44,8 +44,8 @@ elseif(REGEX_BACKEND STREQUAL "builtin")
set
(
GIT_REGEX_BUILTIN 1
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/pcre"
"
${
libgit2_BINARY_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS $<TARGET_OBJECTS:pcre>
)
else
()
message
(
FATAL_ERROR
"The REGEX_BACKEND option provided is not supported"
)
endif
()
cmake/SelectSSH.cmake
View file @
23c5c315
...
...
@@ -17,7 +17,7 @@ endif()
if
(
LIBSSH2_FOUND
)
set
(
GIT_SSH 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
LIBSSH2_INCLUDE_DIRS
}
)
list
(
APPEND LIBGIT2_LIBS
${
LIBSSH2_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
LIBSSH2_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_LIBS
${
LIBSSH2_LDFLAGS
}
)
check_library_exists
(
"
${
LIBSSH2_LIBRARIES
}
"
libssh2_userauth_publickey_frommemory
"
${
LIBSSH2_LIBRARY_DIRS
}
"
HAVE_LIBSSH2_MEMORY_CREDENTIALS
)
...
...
@@ -31,9 +31,9 @@ endif()
if
(
WIN32 AND EMBED_SSH_PATH
)
file
(
GLOB SSH_SRC
"
${
EMBED_SSH_PATH
}
/src/*.c"
)
list
(
SORT SSH_SRC
)
list
(
APPEND LIBGIT2_OBJECTS
${
SSH_SRC
}
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS
${
SSH_SRC
}
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
EMBED_SSH_PATH
}
/include"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
EMBED_SSH_PATH
}
/include"
)
file
(
WRITE
"
${
EMBED_SSH_PATH
}
/src/libssh2_config.h"
"#define HAVE_WINCNG
\n
#define LIBSSH2_WINCNG
\n
#include
\"
../win32/libssh2_config.h
\"
"
)
set
(
GIT_SSH 1
)
endif
()
...
...
cmake/SelectWinHTTP.cmake
View file @
23c5c315
...
...
@@ -5,13 +5,13 @@ if(WIN32 AND WINHTTP)
# we have to include a private header and generate our own import library
if
(
MINGW
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/winhttp"
"
${
libgit2_BINARY_DIR
}
/deps/winhttp"
)
list
(
APPEND LIBGIT2_LIBS winhttp
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS winhttp
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/winhttp"
)
else
()
list
(
APPEND LIBGIT2_LIBS
"winhttp"
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
"winhttp"
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lwinhttp"
)
endif
()
list
(
APPEND LIBGIT2_LIBS
"rpcrt4"
"crypt32"
"ole32"
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
"rpcrt4"
"crypt32"
"ole32"
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lrpcrt4"
"-lcrypt32"
"-lole32"
)
endif
()
cmake/SelectZlib.cmake
View file @
23c5c315
...
...
@@ -10,7 +10,7 @@ if(USE_BUNDLED_ZLIB STREQUAL "OFF")
find_package
(
ZLIB
)
if
(
ZLIB_FOUND
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
ZLIB_INCLUDE_DIRS
}
)
list
(
APPEND LIBGIT2_LIBS
${
ZLIB_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
ZLIB_LIBRARIES
}
)
if
(
APPLE OR CMAKE_SYSTEM_NAME MATCHES
"FreeBSD"
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lz"
)
else
()
...
...
@@ -23,12 +23,12 @@ if(USE_BUNDLED_ZLIB STREQUAL "OFF")
endif
()
if
(
USE_BUNDLED_ZLIB STREQUAL
"Chromium"
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/chromium-zlib"
"
${
libgit2_BINARY_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS $<TARGET_OBJECTS:chromium_zlib>
)
add_feature_info
(
zlib ON
"using (Chromium) bundled zlib"
)
elseif
(
USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/zlib"
"
${
libgit2_BINARY_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS $<TARGET_OBJECTS:zlib>
)
add_feature_info
(
zlib ON
"using bundled zlib"
)
endif
()
examples/CMakeLists.txt
View file @
23c5c315
include_directories
(
${
LIBGIT2_INCLUDES
}
)
include_directories
(
SYSTEM
${
LIBGIT2_SYSTEM_INCLUDES
}
)
file
(
GLOB SRC_EXAMPLES *.c *.h
)
file
(
GLOB LG2_SOURCES *.c *.h
)
add_executable
(
lg2
${
LG2_SOURCES
}
)
add_executable
(
lg2
${
SRC_EXAMPLES
}
)
set_target_properties
(
lg2 PROPERTIES C_STANDARD 90
)
# Ensure that we do not use deprecated functions internally
add_definitions
(
-DGIT_DEPRECATE_HARD
)
target_include_directories
(
lg2 PRIVATE
${
LIBGIT2_INCLUDES
}
${
LIBGIT2_DEPENDENCY_INCLUDES
}
)
target_include_directories
(
lg2 SYSTEM PRIVATE
${
LIBGIT2_SYSTEM_INCLUDES
}
)
if
(
WIN32 OR ANDROID
)
target_link_libraries
(
lg2 git2
)
else
()
...
...
fuzzers/CMakeLists.txt
View file @
23c5c315
link_directories
(
${
LIBGIT2_LIBDIRS
}
)
include_directories
(
${
LIBGIT2_INCLUDES
}
)
include_directories
(
SYSTEM
${
LIBGIT2_SYSTEM_INCLUDES
}
)
if
(
BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS
)
set
(
CMAKE_REQUIRED_FLAGS
"-fsanitize=fuzzer-no-link"
)
add_c_flag
(
-fsanitize=fuzzer
)
...
...
@@ -9,8 +5,8 @@ if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
unset
(
CMAKE_REQUIRED_FLAGS
)
endif
()
file
(
GLOB SRC_FUZZ RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*_fuzzer.c
)
foreach
(
fuzz_target_src
${
SRC_FUZZ
}
)
file
(
GLOB SRC_FUZZ
ERS
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*_fuzzer.c
)
foreach
(
fuzz_target_src
${
SRC_FUZZ
ERS
}
)
string
(
REPLACE
".c"
""
fuzz_target_name
${
fuzz_target_src
}
)
string
(
REPLACE
"_fuzzer"
""
fuzz_name
${
fuzz_target_name
}
)
...
...
@@ -20,7 +16,11 @@ foreach(fuzz_target_src ${SRC_FUZZ})
endif
()
add_executable
(
${
fuzz_target_name
}
${${
fuzz_target_name
}
_SOURCES
}
)
set_target_properties
(
${
fuzz_target_name
}
PROPERTIES C_STANDARD 90
)
target_link_libraries
(
${
fuzz_target_name
}
${
LIBGIT2_LIBS
}
)
target_include_directories
(
${
fuzz_target_name
}
PRIVATE
${
LIBGIT2_INCLUDES
}
${
LIBGIT2_DEPENDENCY_INCLUDES
}
)
target_include_directories
(
${
fuzz_target_name
}
SYSTEM PRIVATE
${
LIBGIT2_SYSTEM_INCLUDES
}
)
target_link_libraries
(
${
fuzz_target_name
}
${
LIBGIT2_SYSTEM_LIBS
}
)
add_test
(
${
fuzz_target_name
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
fuzz_target_name
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/corpora/
${
fuzz_name
}
"
)
endforeach
()
src/CMakeLists.txt
View file @
23c5c315
...
...
@@ -38,8 +38,6 @@ set(LIBGIT2_INCLUDES
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
"
${
libgit2_SOURCE_DIR
}
/src"
"
${
libgit2_SOURCE_DIR
}
/include"
)
set
(
LIBGIT2_SYSTEM_INCLUDES
""
)
set
(
LIBGIT2_LIBS
""
)
if
(
HAVE_FUTIMENS
)
set
(
GIT_USE_FUTIMENS 1
)
...
...
@@ -59,23 +57,23 @@ check_function_exists(qsort_s GIT_QSORT_S)
# Find required dependencies
if
(
WIN32
)
list
(
APPEND LIBGIT2_LIBS ws2_32
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS ws2_32
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"(Solaris|SunOS)"
)
list
(
APPEND LIBGIT2_LIBS socket nsl
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS socket nsl
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lsocket"
"-lnsl"
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"Haiku"
)
list
(
APPEND LIBGIT2_LIBS network
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS network
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lnetwork"
)
endif
()
check_library_exists
(
rt clock_gettime
"time.h"
NEED_LIBRT
)
if
(
NEED_LIBRT
)
list
(
APPEND LIBGIT2_LIBS rt
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS rt
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lrt"
)
endif
()
if
(
USE_THREADS
)
list
(
APPEND LIBGIT2_LIBS
${
CMAKE_THREAD_LIBS_INIT
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
CMAKE_THREAD_LIBS_INIT
}
)
list
(
APPEND LIBGIT2_PC_LIBS
${
CMAKE_THREAD_LIBS_INIT
}
)
endif
()
add_feature_info
(
threadsafe USE_THREADS
"threadsafe support"
)
...
...
@@ -99,14 +97,29 @@ include(SelectSSH)
include
(
SelectWinHTTP
)
include
(
SelectZlib
)
if
(
USE_SHA1 STREQUAL
"CollisionDetection"
)
file
(
GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*
)
elseif
(
USE_SHA1 STREQUAL
"OpenSSL"
)
file
(
GLOB SRC_SHA1 hash/sha1/openssl.*
)
elseif
(
USE_SHA1 STREQUAL
"CommonCrypto"
)
file
(
GLOB SRC_SHA1 hash/sha1/common_crypto.*
)
elseif
(
USE_SHA1 STREQUAL
"mbedTLS"
)
file
(
GLOB SRC_SHA1 hash/sha1/mbedtls.*
)
elseif
(
USE_SHA1 STREQUAL
"Win32"
)
file
(
GLOB SRC_SHA1 hash/sha1/win32.*
)
elseif
(
USE_SHA1 STREQUAL
"Generic"
)
file
(
GLOB SRC_SHA1 hash/sha1/generic.*
)
endif
()
list
(
APPEND SRC_SHA1
"hash/sha1.h"
)
target_sources
(
git2internal PRIVATE
${
SRC_SHA1
}
)
# Optional external dependency: ntlmclient
if
(
USE_NTLMCLIENT
)
set
(
GIT_NTLM 1
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/ntlmclient"
"
${
libgit2_BINARY_DIR
}
/deps/ntlmclient"
)
list
(
APPEND LIBGIT2_INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/ntlmclient"
)
list
(
APPEND LIBGIT2_OBJECTS
"$<TARGET_OBJECTS:ntlmclient>"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
INCLUDES
"
${
libgit2_SOURCE_DIR
}
/deps/ntlmclient"
)
list
(
APPEND LIBGIT2_
DEPENDENCY_
OBJECTS
"$<TARGET_OBJECTS:ntlmclient>"
)
endif
()
add_feature_info
(
ntlmclient GIT_NTLM
"NTLM authentication support for Unix"
)
...
...
@@ -121,7 +134,7 @@ endif()
if
(
ICONV_FOUND
)
set
(
GIT_USE_ICONV 1
)
list
(
APPEND LIBGIT2_SYSTEM_INCLUDES
${
ICONV_INCLUDE_DIR
}
)
list
(
APPEND LIBGIT2_LIBS
${
ICONV_LIBRARIES
}
)
list
(
APPEND LIBGIT2_
SYSTEM_
LIBS
${
ICONV_LIBRARIES
}
)
list
(
APPEND LIBGIT2_PC_LIBS
${
ICONV_LIBRARIES
}
)
endif
()
add_feature_info
(
iconv GIT_USE_ICONV
"iconv encoding conversion support"
)
...
...
@@ -210,15 +223,17 @@ endif()
configure_file
(
features.h.in git2/sys/features.h
)
ide_split_sources
(
git2internal
)
list
(
APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>
)
list
(
APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>
${
LIBGIT2_DEPENDENCY_OBJECTS
}
)
target_include_directories
(
git2internal PRIVATE
${
LIBGIT2_INCLUDES
}
PUBLIC
${
libgit2_SOURCE_DIR
}
/include
)
target_include_directories
(
git2internal PRIVATE
${
LIBGIT2_INCLUDES
}
${
LIBGIT2_DEPENDENCY_INCLUDES
}
PUBLIC
${
libgit2_SOURCE_DIR
}
/include
)
target_include_directories
(
git2internal SYSTEM PRIVATE
${
LIBGIT2_SYSTEM_INCLUDES
}
)
set
(
LIBGIT2_OBJECTS
${
LIBGIT2_OBJECTS
}
PARENT_SCOPE
)
set
(
LIBGIT2_INCLUDES
${
LIBGIT2_INCLUDES
}
PARENT_SCOPE
)
set
(
LIBGIT2_OBJECTS
${
LIBGIT2_OBJECTS
}
PARENT_SCOPE
)
set
(
LIBGIT2_DEPENDENCY_INCLUDES
${
LIBGIT2_DEPENDENCY_INCLUDES
}
PARENT_SCOPE
)
set
(
LIBGIT2_DEPENDENCY_OBJECTS
${
LIBGIT2_DEPENDENCY_OBJECTS
}
PARENT_SCOPE
)
set
(
LIBGIT2_SYSTEM_INCLUDES
${
LIBGIT2_SYSTEM_INCLUDES
}
PARENT_SCOPE
)
set
(
LIBGIT2_
LIBS
${
LIBGIT2
_LIBS
}
PARENT_SCOPE
)
set
(
LIBGIT2_
SYSTEM_LIBS
${
LIBGIT2_SYSTEM
_LIBS
}
PARENT_SCOPE
)
if
(
XCODE_VERSION
)
# This is required for Xcode to actually link the libgit2 library
...
...
@@ -229,7 +244,7 @@ endif()
# Compile and link libgit2
add_library
(
git2
${
WIN_RC
}
${
LIBGIT2_OBJECTS
}
)
target_link_libraries
(
git2
${
LIBGIT2_LIBS
}
)
target_link_libraries
(
git2
${
LIBGIT2_
SYSTEM_
LIBS
}
)
set_target_properties
(
git2 PROPERTIES C_STANDARD 90
)
set_target_properties
(
git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${
libgit2_BINARY_DIR
}
)
...
...
tests/CMakeLists.txt
View file @
23c5c315
...
...
@@ -16,7 +16,7 @@ add_definitions(-D_FILE_OFFSET_BITS=64)
# Ensure that we do not use deprecated functions internally
add_definitions(-DGIT_DEPRECATE_HARD)
include_directories(
${
CLAR_PATH
}
${
libgit2_BINARY_DIR
}
/src
)
set(TEST_INCLUDES "
${
CLAR_PATH
}
" "
${
CMAKE_CURRENT_BINARY_DIR
}
"
)
file(GLOB_RECURSE SRC_TEST
${
CLAR_PATH
}
/*/*.c
${
CLAR_PATH
}
/*/*.h)
set(SRC_CLAR "
main.c
" "
clar_libgit2.c
" "
clar_libgit2_trace.c
" "
clar_libgit2_timer.c
" "
clar.c
")
...
...
@@ -30,22 +30,20 @@ add_custom_command(
DEPENDS
${
SRC_TEST
}
WORKING_DIRECTORY
${
CLAR_PATH
}
)
include_directories(
${
CMAKE_CURRENT_BINARY_DIR
}
)
set_source_files_properties(
${
CLAR_PATH
}
/clar.c
PROPERTIES OBJECT_DEPENDS
${
CMAKE_CURRENT_BINARY_DIR
}
/clar.suite)
include_directories(
${
LIBGIT2_INCLUDES
}
)
include_directories(SYSTEM
${
LIBGIT2_SYSTEM_INCLUDES
}
)
add_executable(libgit2_tests
${
SRC_CLAR
}
${
SRC_TEST
}
${
LIBGIT2_OBJECTS
}
)
set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${
libgit2_BINARY_DIR
}
)
target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
target_link_libraries(libgit2_tests
${
LIBGIT2_LIBS
}
)
target_include_directories(libgit2_tests PRIVATE
${
TEST_INCLUDES
}
${
LIBGIT2_INCLUDES
}
${
LIBGIT2_DEPENDENCY_INCLUDES
}
)
target_include_directories(libgit2_tests SYSTEM PRIVATE
${
LIBGIT2_SYSTEM_INCLUDES
}
)
target_link_libraries(libgit2_tests
${
LIBGIT2_SYSTEM_LIBS
}
)
ide_split_sources(libgit2_tests)
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment