Unverified Commit 7687948a by Edward Thomson Committed by GitHub

Merge pull request #6112 from libgit2/ethomson/cmake3

cmake refactorings
parents 42205e72 4e84ddd5
...@@ -91,7 +91,7 @@ jobs: ...@@ -91,7 +91,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, GCC, mbedTLS - # Xenial, GCC, mbedTLS
container: container:
...@@ -99,7 +99,7 @@ jobs: ...@@ -99,7 +99,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, OpenSSL - # Xenial, Clang, OpenSSL
container: container:
...@@ -107,14 +107,14 @@ jobs: ...@@ -107,14 +107,14 @@ jobs:
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, mbedTLS - # Xenial, Clang, mbedTLS
container: container:
name: xenial name: xenial
env: env:
CC: clang CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer - # Focal, Clang 10, mbedTLS, MemorySanitizer
...@@ -123,7 +123,7 @@ jobs: ...@@ -123,7 +123,7 @@ jobs:
env: env:
CC: clang-10 CC: clang-10
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
...@@ -136,7 +136,7 @@ jobs: ...@@ -136,7 +136,7 @@ jobs:
env: env:
CC: clang-10 CC: clang-10
CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
...@@ -149,7 +149,7 @@ jobs: ...@@ -149,7 +149,7 @@ jobs:
env: env:
CC: clang-10 CC: clang-10
CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
......
...@@ -25,7 +25,7 @@ jobs: ...@@ -25,7 +25,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, GCC, mbedTLS - # Xenial, GCC, mbedTLS
container: container:
...@@ -33,7 +33,7 @@ jobs: ...@@ -33,7 +33,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, OpenSSL - # Xenial, Clang, OpenSSL
container: container:
...@@ -41,14 +41,14 @@ jobs: ...@@ -41,14 +41,14 @@ jobs:
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, mbedTLS - # Xenial, Clang, mbedTLS
container: container:
name: xenial name: xenial
env: env:
CC: clang CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Xenial, GCC, thread-free - # Xenial, GCC, thread-free
...@@ -56,7 +56,7 @@ jobs: ...@@ -56,7 +56,7 @@ jobs:
name: xenial name: xenial
env: env:
CC: gcc CC: gcc
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, OpenSSL (dynamically loaded) - # Xenial, Clang, OpenSSL (dynamically loaded)
...@@ -64,7 +64,7 @@ jobs: ...@@ -64,7 +64,7 @@ jobs:
name: xenial name: xenial
env: env:
CC: clang CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer - # Focal, Clang 10, mbedTLS, MemorySanitizer
...@@ -119,7 +119,7 @@ jobs: ...@@ -119,7 +119,7 @@ jobs:
container: container:
name: centos7 name: centos7
env: env:
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
...@@ -127,7 +127,7 @@ jobs: ...@@ -127,7 +127,7 @@ jobs:
container: container:
name: centos7 name: centos7
env: env:
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
...@@ -212,7 +212,7 @@ jobs: ...@@ -212,7 +212,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, x86, Clang, OpenSSL - # Bionic, x86, Clang, OpenSSL
...@@ -223,7 +223,7 @@ jobs: ...@@ -223,7 +223,7 @@ jobs:
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, x86, GCC, OpenSSL - # Bionic, x86, GCC, OpenSSL
...@@ -233,7 +233,7 @@ jobs: ...@@ -233,7 +233,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, arm32, GCC, OpenSSL - # Bionic, arm32, GCC, OpenSSL
...@@ -244,7 +244,7 @@ jobs: ...@@ -244,7 +244,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true SKIP_PROXY_TESTS: true
os: ubuntu-latest os: ubuntu-latest
...@@ -256,7 +256,7 @@ jobs: ...@@ -256,7 +256,7 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true SKIP_PROXY_TESTS: true
os: ubuntu-latest os: ubuntu-latest
......
...@@ -279,7 +279,7 @@ The following CMake variables are declared: ...@@ -279,7 +279,7 @@ The following CMake variables are declared:
- `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to. - `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON) - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_TESTS`: Build the unit and integration test suites (defaults to ON) - `BUILD_TESTS`: Build the unit and integration test suites (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON) - `USE_THREADS`: Build libgit2 with threading support (defaults to ON)
To list all build options and their current value, you can do the To list all build options and their current value, you can do the
following: following:
......
# Platform specific compilation flags
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
string(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# /GF - String pooling
# /MP - Parallel build
set(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
# /Gd - explicitly set cdecl calling convention
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
if(NOT (MSVC_VERSION LESS 1900))
# /guard:cf - Enable Control Flow Guard
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
endif()
if(STATIC_CRT)
set(CRT_FLAG_DEBUG "/MTd")
set(CRT_FLAG_RELEASE "/MT")
else()
set(CRT_FLAG_DEBUG "/MDd")
set(CRT_FLAG_RELEASE "/MD")
endif()
if(WIN32_LEAKCHECK)
set(GIT_WIN32_LEAKCHECK 1)
set(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
endif()
# /Zi - Create debugging information
# /Od - Disable optimization
# /D_DEBUG - #define _DEBUG
# /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
# /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT
# /MD - Dynamically link the multithreaded release version of the CRT
# /O2 - Optimize for speed
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
# /GL - Link time code generation (whole program optimization)
# /Gy - Function-level linking
set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /Oy- - Disable frame pointer omission (FPO)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
# /O1 - Optimize for size
set(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /IGNORE:4221 - Ignore empty compilation units
set(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
# /DYNAMICBASE - Address space load randomization (ASLR)
# /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header
set(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
if(NOT (MSVC_VERSION LESS 1900))
# /GUARD:CF - Enable Control Flow Guard
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
endif()
# /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization)
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step
# /INCREMENTAL:NO - Required to use /LTCG
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
# Same linker settings for DLL as EXE
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
else()
if(ENABLE_REPRODUCIBLE_BUILDS)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
endif()
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
set(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
enable_warnings(all)
enable_warnings(extra)
if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
if(MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
string(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
elseif(BUILD_SHARED_LIBS)
add_c_flag_IF_SUPPORTED(-fvisibility=hidden)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
if(MINGW)
# MinGW >= 3.14 uses the C99-style stdio functions
# automatically, but forks like mingw-w64 still want
# us to define this in order to use them
add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
endif()
enable_warnings(documentation)
disable_warnings(documentation-deprecated-sync)
disable_warnings(missing-field-initializers)
enable_warnings(strict-aliasing)
enable_warnings(strict-prototypes)
enable_warnings(declaration-after-statement)
enable_warnings(shift-count-overflow)
enable_warnings(unused-const-variable)
enable_warnings(unused-function)
enable_warnings(int-conversion)
enable_warnings(c11-extensions)
enable_warnings(c99-c11-compat)
# MinGW uses gcc, which expects POSIX formatting for printf, but
# uses the Windows C library, which uses its own format specifiers.
# Disable format specifier warnings.
if(MINGW)
disable_warnings(format)
disable_warnings(format-security)
else()
enable_warnings(format)
enable_warnings(format-security)
endif()
endif()
# Ensure that MinGW provides the correct header files.
if(WIN32 AND NOT CYGWIN)
add_definitions(-DWIN32 -D_WIN32_WINNT=0x0600)
endif()
INCLUDE(FeatureSummary) include(FeatureSummary)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h" check_struct_has_member("struct stat" st_mtim "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C) HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h" check_struct_has_member("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C) HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h check_struct_has_member("struct stat" st_mtime_nsec sys/stat.h
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C) HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
IF (HAVE_STRUCT_STAT_ST_MTIM) if(HAVE_STRUCT_STAT_ST_MTIM)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h check_struct_has_member("struct stat" st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C) HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC) elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h check_struct_has_member("struct stat" st_mtimespec.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C) HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSE () else()
SET( HAVE_STRUCT_STAT_NSEC ON ) set(HAVE_STRUCT_STAT_NSEC ON )
ENDIF() endif()
IF (HAVE_STRUCT_STAT_NSEC OR WIN32) add_feature_info(nanoseconds USE_NSEC "support nanosecond precision file mtimes and ctimes")
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
ELSE()
SET(USE_NSEC OFF)
ENDIF()
ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
# Optional external dependency: http-parser
if(USE_HTTP_PARSER STREQUAL "system")
find_package(HTTP_Parser)
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_PC_LIBS "-lhttp_parser")
add_feature_info(http-parser ON "http-parser support (system)")
else()
message(FATAL_ERROR "http-parser support was requested but not found")
endif()
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>")
add_feature_info(http-parser ON "http-parser support (bundled)")
endif()
...@@ -19,7 +19,7 @@ IF(USE_HTTPS) ...@@ -19,7 +19,7 @@ IF(USE_HTTPS)
MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL") MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
SET(USE_HTTPS "OpenSSL") SET(USE_HTTPS "OpenSSL")
ENDIF() ENDIF()
ELSEIF (WINHTTP) ELSEIF (USE_WINHTTP)
SET(USE_HTTPS "WinHTTP") SET(USE_HTTPS "WinHTTP")
ELSEIF(OPENSSL_FOUND) ELSEIF(OPENSSL_FOUND)
SET(USE_HTTPS "OpenSSL") SET(USE_HTTPS "OpenSSL")
......
# Specify regular expression implementation
find_package(PCRE)
if(REGEX_BACKEND STREQUAL "")
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
if(HAVE_REGCOMP_L)
set(REGEX_BACKEND "regcomp_l")
elseif(PCRE_FOUND)
set(REGEX_BACKEND "pcre")
else()
set(REGEX_BACKEND "builtin")
endif()
endif()
if(REGEX_BACKEND STREQUAL "regcomp_l")
add_feature_info(regex ON "using system regcomp_l")
set(GIT_REGEX_REGCOMP_L 1)
elseif(REGEX_BACKEND STREQUAL "pcre2")
find_package(PCRE2)
if(NOT PCRE2_FOUND)
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
endif()
add_feature_info(regex ON "using system PCRE2")
set(GIT_REGEX_PCRE2 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
list(APPEND LIBGIT2_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_PC_REQUIRES "libpcre")
elseif(REGEX_BACKEND STREQUAL "regcomp")
add_feature_info(regex ON "using system regcomp")
set(GIT_REGEX_REGCOMP 1)
elseif(REGEX_BACKEND STREQUAL "builtin")
add_feature_info(regex ON "using bundled PCRE")
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>)
else()
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
endif()
# Optional external dependency: libssh2
if(USE_SSH)
find_pkglibraries(LIBSSH2 libssh2)
if(NOT LIBSSH2_FOUND)
find_package(LibSSH2)
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
set(LIBSSH2_LDFLAGS "-lssh2")
endif()
if(NOT LIBSSH2_FOUND)
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif()
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_PC_LIBS ${LIBSSH2_LDFLAGS})
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
set(GIT_SSH_MEMORY_CREDENTIALS 1)
endif()
else()
message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
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_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()
add_feature_info(SSH GIT_SSH "SSH transport support")
if(WIN32 AND WINHTTP)
set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for 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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
else()
list(APPEND LIBGIT2_LIBS "winhttp")
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
endif()
list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
endif()
# Optional external dependency: zlib
include(SanitizeBool)
SanitizeBool(USE_BUNDLED_ZLIB)
if(USE_BUNDLED_ZLIB STREQUAL ON)
set(USE_BUNDLED_ZLIB "Bundled")
endif()
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})
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
list(APPEND LIBGIT2_PC_LIBS "-lz")
else()
list(APPEND LIBGIT2_PC_REQUIRES "zlib")
endif()
add_feature_info(zlib ON "using system zlib")
else()
message(STATUS "zlib was not found; using bundled 3rd-party sources." )
endif()
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>)
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>)
add_feature_info(zlib ON "using bundled zlib")
endif()
...@@ -21,7 +21,7 @@ critical failures (such as a packfile being corrupted, a loose object ...@@ -21,7 +21,7 @@ critical failures (such as a packfile being corrupted, a loose object
having the wrong access permissions, etc.) all of which will return -1. having the wrong access permissions, etc.) all of which will return -1.
When the object lookup is successful, it will return 0. When the object lookup is successful, it will return 0.
If libgit2 was compiled with threads enabled (`-DTHREADSAFE=ON` when using If libgit2 was compiled with threads enabled (`-DUSE_THREADS=ON` when using
CMake), then the error message will be kept in thread-local storage, so it CMake), then the error message will be kept in thread-local storage, so it
will not be modified by other threads. If threads are not enabled, then will not be modified by other threads. If threads are not enabled, then
the error message is in global data. the error message is in global data.
......
...@@ -3,7 +3,10 @@ include_directories(${LIBGIT2_INCLUDES}) ...@@ -3,7 +3,10 @@ include_directories(${LIBGIT2_INCLUDES})
include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES}) include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS) if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
add_c_flag(-fsanitize=fuzzer) add_c_flag(-fsanitize=fuzzer)
add_c_flag(-fsanitize=fuzzer-no-link)
unset(CMAKE_REQUIRED_FLAGS)
endif() endif()
file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c) file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
......
...@@ -2,6 +2,10 @@ add_library(git2internal OBJECT) ...@@ -2,6 +2,10 @@ add_library(git2internal OBJECT)
set_target_properties(git2internal PROPERTIES C_STANDARD 90) set_target_properties(git2internal PROPERTIES C_STANDARD 90)
if(DEPRECATE_HARD)
add_definitions(-DGIT_DEPRECATE_HARD)
endif()
if(DEBUG_POOL) if(DEBUG_POOL)
set(GIT_DEBUG_POOL 1) set(GIT_DEBUG_POOL 1)
endif() endif()
...@@ -46,22 +50,13 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support") ...@@ -46,22 +50,13 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
check_prototype_definition(qsort_r check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" HAVE_QSORT_R_BSD) "" "stdlib.h" GIT_QSORT_R_BSD)
if(HAVE_QSORT_R_BSD)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
endif()
check_prototype_definition(qsort_r check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
"" "stdlib.h" HAVE_QSORT_R_GNU) "" "stdlib.h" GIT_QSORT_R_GNU)
if(HAVE_QSORT_R_GNU)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
endif()
check_function_exists(qsort_s HAVE_QSORT_S) check_function_exists(qsort_s GIT_QSORT_S)
if(HAVE_QSORT_S)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
endif()
# Find required dependencies # Find required dependencies
...@@ -81,11 +76,11 @@ if(NEED_LIBRT) ...@@ -81,11 +76,11 @@ if(NEED_LIBRT)
list(APPEND LIBGIT2_PC_LIBS "-lrt") list(APPEND LIBGIT2_PC_LIBS "-lrt")
endif() endif()
if(THREADSAFE) if(USE_THREADS)
list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT}) list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT}) list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
add_feature_info(threadsafe THREADSAFE "threadsafe support") add_feature_info(threadsafe USE_THREADS "threadsafe support")
if(WIN32 AND EMBED_SSH_PATH) if(WIN32 AND EMBED_SSH_PATH)
...@@ -98,158 +93,15 @@ if(WIN32 AND EMBED_SSH_PATH) ...@@ -98,158 +93,15 @@ if(WIN32 AND EMBED_SSH_PATH)
set(GIT_SSH 1) set(GIT_SSH 1)
endif() endif()
if(WIN32 AND WINHTTP)
set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for 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_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
else()
list(APPEND LIBGIT2_LIBS "winhttp")
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
endif()
list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
endif()
include(SelectHTTPSBackend) include(SelectHTTPSBackend)
include(SelectHashes) include(SelectHashes)
target_sources(git2internal PRIVATE ${SRC_SHA1}) include(SelectHTTPParser)
include(SelectRegex)
include(SelectSSH)
include(SelectWinHTTP)
include(SelectZlib)
# Specify regular expression implementation target_sources(git2internal PRIVATE ${SRC_SHA1})
find_package(PCRE)
if(REGEX_BACKEND STREQUAL "")
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
if(HAVE_REGCOMP_L)
set(REGEX_BACKEND "regcomp_l")
elseif(PCRE_FOUND)
set(REGEX_BACKEND "pcre")
else()
set(REGEX_BACKEND "builtin")
endif()
endif()
if(REGEX_BACKEND STREQUAL "regcomp_l")
add_feature_info(regex ON "using system regcomp_l")
set(GIT_REGEX_REGCOMP_L 1)
elseif(REGEX_BACKEND STREQUAL "pcre2")
find_package(PCRE2)
if(NOT PCRE2_FOUND)
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
endif()
add_feature_info(regex ON "using system PCRE2")
set(GIT_REGEX_PCRE2 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
list(APPEND LIBGIT2_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_PC_REQUIRES "libpcre")
elseif(REGEX_BACKEND STREQUAL "regcomp")
add_feature_info(regex ON "using system regcomp")
set(GIT_REGEX_REGCOMP 1)
elseif(REGEX_BACKEND STREQUAL "builtin")
add_feature_info(regex ON "using bundled PCRE")
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>)
else()
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
endif()
# Optional external dependency: http-parser
if(USE_HTTP_PARSER STREQUAL "system")
find_package(HTTP_Parser)
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_PC_LIBS "-lhttp_parser")
add_feature_info(http-parser ON "http-parser support (system)")
else()
message(FATAL_ERROR "http-parser support was requested but not found")
endif()
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>")
add_feature_info(http-parser ON "http-parser support (bundled)")
endif()
# Optional external dependency: zlib
SanitizeBool(USE_BUNDLED_ZLIB)
if(USE_BUNDLED_ZLIB STREQUAL ON)
set(USE_BUNDLED_ZLIB "Bundled")
endif()
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})
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
list(APPEND LIBGIT2_PC_LIBS "-lz")
else()
list(APPEND LIBGIT2_PC_REQUIRES "zlib")
endif()
add_feature_info(zlib ON "using system zlib")
else()
message(STATUS "zlib was not found; using bundled 3rd-party sources." )
endif()
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>)
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>)
add_feature_info(zlib ON "using bundled zlib")
endif()
# Optional external dependency: libssh2
if(USE_SSH)
find_pkglibraries(LIBSSH2 libssh2)
if(NOT LIBSSH2_FOUND)
find_package(LibSSH2)
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
set(LIBSSH2_LDFLAGS "-lssh2")
endif()
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_PC_LIBS ${LIBSSH2_LDFLAGS})
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
set(GIT_SSH_MEMORY_CREDENTIALS 1)
endif()
else()
message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif()
add_feature_info(SSH GIT_SSH "SSH transport support")
# Optional external dependency: ntlmclient # Optional external dependency: ntlmclient
if(USE_NTLMCLIENT) if(USE_NTLMCLIENT)
...@@ -277,7 +129,7 @@ endif() ...@@ -277,7 +129,7 @@ endif()
add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support") add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support")
if(THREADSAFE) if(USE_THREADS)
if(NOT WIN32) if(NOT WIN32)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
endif() endif()
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
#cmakedefine GIT_REGEX_PCRE2 #cmakedefine GIT_REGEX_PCRE2
#cmakedefine GIT_REGEX_BUILTIN 1 #cmakedefine GIT_REGEX_BUILTIN 1
#cmakedefine GIT_QSORT_R_BSD
#cmakedefine GIT_QSORT_R_GNU
#cmakedefine GIT_QSORT_S
#cmakedefine GIT_SSH 1 #cmakedefine GIT_SSH 1
#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1 #cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#if defined(__clang__) #if defined(__clang__)
# if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)) # if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1))
# error Atomic primitives do not exist on this version of clang; configure libgit2 with -DTHREADSAFE=OFF # error Atomic primitives do not exist on this version of clang; configure libgit2 with -DUSE_THREADS=OFF
# else # else
# define GIT_BUILTIN_ATOMIC # define GIT_BUILTIN_ATOMIC
# endif # endif
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)) # if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
# error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF # error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DUSE_THREADS=OFF
# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) # elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
# define GIT_BUILTIN_ATOMIC # define GIT_BUILTIN_ATOMIC
# else # else
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# endif # endif
# include <windows.h> # include <windows.h>
# ifdef HAVE_QSORT_S # ifdef GIT_QSORT_S
# include <search.h> # include <search.h>
# endif # endif
#endif #endif
...@@ -673,7 +673,7 @@ size_t git__unescape(char *str) ...@@ -673,7 +673,7 @@ size_t git__unescape(char *str)
return (pos - str); return (pos - str);
} }
#if defined(HAVE_QSORT_S) || defined(HAVE_QSORT_R_BSD) #if defined(GIT_QSORT_S) || defined(GIT_QSORT_R_BSD)
typedef struct { typedef struct {
git__sort_r_cmp cmp; git__sort_r_cmp cmp;
void *payload; void *payload;
...@@ -688,9 +688,9 @@ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp( ...@@ -688,9 +688,9 @@ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
#endif #endif
#if !defined(HAVE_QSORT_R_BSD) && \ #if !defined(GIT_QSORT_R_BSD) && \
!defined(HAVE_QSORT_R_GNU) && \ !defined(GIT_QSORT_R_GNU) && \
!defined(HAVE_QSORT_S) !defined(GIT_QSORT_S)
static void swap(uint8_t *a, uint8_t *b, size_t elsize) static void swap(uint8_t *a, uint8_t *b, size_t elsize)
{ {
char tmp[256]; char tmp[256];
...@@ -721,12 +721,12 @@ static void insertsort( ...@@ -721,12 +721,12 @@ static void insertsort(
void git__qsort_r( void git__qsort_r(
void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload) void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload)
{ {
#if defined(HAVE_QSORT_R_BSD) #if defined(GIT_QSORT_R_BSD)
git__qsort_r_glue glue = { cmp, payload }; git__qsort_r_glue glue = { cmp, payload };
qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp); qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp);
#elif defined(HAVE_QSORT_R_GNU) #elif defined(GIT_QSORT_R_GNU)
qsort_r(els, nel, elsize, cmp, payload); qsort_r(els, nel, elsize, cmp, payload);
#elif defined(HAVE_QSORT_S) #elif defined(GIT_QSORT_S)
git__qsort_r_glue glue = { cmp, payload }; git__qsort_r_glue glue = { cmp, payload };
qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue); qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue);
#else #else
......
...@@ -62,6 +62,8 @@ function(ADD_CLAR_TEST name) ...@@ -62,6 +62,8 @@ function(ADD_CLAR_TEST name)
endif() endif()
endfunction(ADD_CLAR_TEST) endfunction(ADD_CLAR_TEST)
enable_testing()
add_clar_test(offline -v -xonline) add_clar_test(offline -v -xonline)
add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root) add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
add_clar_test(online -v -sonline -xonline::customcert) add_clar_test(online -v -sonline -xonline::customcert)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment