Commit 52693ab4 by Edward Thomson

cmake: stylistic refactoring

Ensure that we always use lowercase function names, and that we do not
have spaces preceding open parentheses, for consistency.
parent e1be28c7
# CMake build script for the libgit2 project # CMake build script for the libgit2 project
# # See `README.md` for build instructions.
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) cmake_minimum_required(VERSION 3.5.1)
project(libgit2 VERSION "1.3.0" LANGUAGES C) project(libgit2 VERSION "1.3.0" LANGUAGES C)
# Add find modules to the path # Add find modules to the path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
INCLUDE(CheckLibraryExists) # Modules
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists) include(CheckLibraryExists)
INCLUDE(CheckStructHasMember) include(CheckFunctionExists)
INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0 include(CheckSymbolExists)
INCLUDE(AddCFlagIfSupported) include(CheckStructHasMember)
INCLUDE(FindPkgLibraries) include(CheckPrototypeDefinition)
INCLUDE(FindThreads) include(AddCFlagIfSupported)
INCLUDE(FindStatNsec) include(FindPkgLibraries)
INCLUDE(Findfutimens) include(FindThreads)
INCLUDE(GNUInstallDirs) include(FindStatNsec)
INCLUDE(IdeSplitSources) include(Findfutimens)
INCLUDE(FeatureSummary) include(GNUInstallDirs)
INCLUDE(EnableWarnings) include(IdeSplitSources)
include(FeatureSummary)
include(EnableWarnings)
#
# Build options # Build options
# #
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) # Optional subsystems
OPTION(THREADSAFE "Build libgit2 as threadsafe" ON) option(THREADSAFE "Build libgit2 as threadsafe" ON)
OPTION(BUILD_TESTS "Build Tests using the Clar suite" ON) option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF) option(BUILD_TESTS "Build Tests using the Clar suite" ON)
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF) option(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF) option(BUILD_FUZZERS "Build the fuzz targets" OFF)
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON) # Backend selection
OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON) option(USE_SSH "Link with libssh2 to enable SSH support" ON)
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF) option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF) option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF) option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF) set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
OPTION(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF) set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
OPTION(DEBUG_STRICT_OPEN "Enable path validation in open" OFF) option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF) # Debugging options
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.") option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF) option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.") option(DEBUG_POOL "Enable debug pool allocator" OFF)
option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
IF (UNIX) option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
IF (NOT USE_HTTPS)
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF ) # Output options
ELSE() option(SONAME "Set the (SO)VERSION of the target" ON)
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." ON ) option(LIBGIT2_FILENAME "Name of the produced binary" OFF)
ENDIF() option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF) # Compilation options
option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
OPTION(USE_ICONV "Link with and use iconv library" ON)
ENDIF() if(UNIX)
# NTLM client requires crypto libraries from the system HTTPS stack
IF(MSVC) if(NOT USE_HTTPS)
option(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF)
else()
option(USE_NTLMCLIENT "Enable NTLM support on Unix." ON)
endif()
option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
endif()
if(APPLE)
option(USE_ICONV "Link with and use iconv library" ON)
endif()
if(MSVC)
# This option must match the settings used in your program, in particular if you # This option must match the settings used in your program, in particular if you
# are linking statically # are linking statically
OPTION(STATIC_CRT "Link the static CRT libraries" ON) option(STATIC_CRT "Link the static CRT libraries" ON)
# If you want to embed a copy of libssh2 into libgit2, pass a # If you want to embed a copy of libssh2 into libgit2, pass a
# path to libssh2 # path to libssh2
OPTION(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF) option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
ENDIF()
# Enable leak checking using the debugging C runtime.
option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
endif()
IF(WIN32) if(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in # By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
OPTION(WINHTTP "Use Win32 WinHTTP routines" ON) option(WINHTTP "Use Win32 WinHTTP routines" ON)
ENDIF() endif()
IF(MSVC)
# Enable leak checking using the debugging C runtime.
OPTION(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
ENDIF()
IF (DEPRECATE_HARD) #
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD) # Compiler / linker flags
ENDIF() #
if(DEPRECATE_HARD)
add_definitions(-DGIT_DEPRECATE_HARD)
endif()
# Platform specific compilation flags # Platform specific compilation flags
IF (MSVC) if(MSVC)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# /GF - String pooling # /GF - String pooling
# /MP - Parallel build # /MP - Parallel build
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
# /Gd - explicitly set cdecl calling convention # /Gd - explicitly set cdecl calling convention
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
IF (NOT (MSVC_VERSION LESS 1900)) if(NOT (MSVC_VERSION LESS 1900))
# /guard:cf - Enable Control Flow Guard # /guard:cf - Enable Control Flow Guard
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
ENDIF() endif()
IF (STATIC_CRT) if(STATIC_CRT)
SET(CRT_FLAG_DEBUG "/MTd") set(CRT_FLAG_DEBUG "/MTd")
SET(CRT_FLAG_RELEASE "/MT") set(CRT_FLAG_RELEASE "/MT")
ELSE() else()
SET(CRT_FLAG_DEBUG "/MDd") set(CRT_FLAG_DEBUG "/MDd")
SET(CRT_FLAG_RELEASE "/MD") set(CRT_FLAG_RELEASE "/MD")
ENDIF() endif()
IF (WIN32_LEAKCHECK) if(WIN32_LEAKCHECK)
SET(GIT_WIN32_LEAKCHECK 1) set(GIT_WIN32_LEAKCHECK 1)
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}") set(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib") set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
ENDIF() endif()
# /Zi - Create debugging information # /Zi - Create debugging information
# /Od - Disable optimization # /Od - Disable optimization
...@@ -135,7 +143,7 @@ IF (MSVC) ...@@ -135,7 +143,7 @@ IF (MSVC)
# /MTd - Statically link the multithreaded debug version of the CRT # /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT # /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks # /RTC1 - Run time checks
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
# /DNDEBUG - Disables asserts # /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT # /MT - Statically link the multithreaded release version of the CRT
...@@ -144,76 +152,80 @@ IF (MSVC) ...@@ -144,76 +152,80 @@ IF (MSVC)
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off) # /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
# /GL - Link time code generation (whole program optimization) # /GL - Link time code generation (whole program optimization)
# /Gy - Function-level linking # /Gy - Function-level linking
SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /Oy- - Disable frame pointer omission (FPO) # /Oy- - Disable frame pointer omission (FPO)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}") set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
# /O1 - Optimize for size # /O1 - Optimize for size
SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") set(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /IGNORE:4221 - Ignore empty compilation units # /IGNORE:4221 - Ignore empty compilation units
SET(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221") set(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
# /DYNAMICBASE - Address space load randomization (ASLR) # /DYNAMICBASE - Address space load randomization (ASLR)
# /NXCOMPAT - Data execution prevention (DEP) # /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86 # /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header # /VERSION - Embed version information in PE header
SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}") set(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
IF (NOT (MSVC_VERSION LESS 1900)) if(NOT (MSVC_VERSION LESS 1900))
# /GUARD:CF - Enable Control Flow Guard # /GUARD:CF - Enable Control Flow Guard
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
ENDIF() endif()
# /DEBUG - Create a PDB # /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization) # /LTCG - Link time code generation (whole program optimization)
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step # /OPT:REF /OPT:ICF - Fold out duplicate code at link step
# /INCREMENTAL:NO - Required to use /LTCG # /INCREMENTAL:NO - Required to use /LTCG
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug) # /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_DEBUG "/DEBUG")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") 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_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") set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
# Same linker settings for DLL as EXE # Same linker settings for DLL as EXE
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") 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_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 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_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
ELSE () else()
IF (ENABLE_REPRODUCIBLE_BUILDS) if(ENABLE_REPRODUCIBLE_BUILDS)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>") 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_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>") set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
ENDIF() endif()
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}") if(NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENABLE_WARNINGS(all) endif()
ENABLE_WARNINGS(extra)
set(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
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}") enable_warnings(all)
ENDIF() enable_warnings(extra)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0") 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}")
IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to endif()
STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
ELSEIF (BUILD_SHARED_LIBS) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
if(MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") string(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
ENDIF () elseif(BUILD_SHARED_LIBS)
add_c_flag_IF_SUPPORTED(-fvisibility=hidden)
IF (MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
if(MINGW)
# MinGW >= 3.14 uses the C99-style stdio functions # MinGW >= 3.14 uses the C99-style stdio functions
# automatically, but forks like mingw-w64 still want # automatically, but forks like mingw-w64 still want
# us to define this in order to use them # us to define this in order to use them
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1) add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
ENDIF () endif()
enable_warnings(documentation) enable_warnings(documentation)
disable_warnings(documentation-deprecated-sync) disable_warnings(documentation-deprecated-sync)
...@@ -238,60 +250,59 @@ ELSE () ...@@ -238,60 +250,59 @@ ELSE ()
enable_warnings(format) enable_warnings(format)
enable_warnings(format-security) enable_warnings(format-security)
endif() endif()
ENDIF() endif()
# Ensure that MinGW provides the correct header files. # Ensure that MinGW provides the correct header files.
IF (WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600) add_definitions(-DWIN32 -D_WIN32_WINNT=0x0600)
ENDIF() endif()
IF( NOT CMAKE_CONFIGURATION_TYPES ) if(NOT CMAKE_CONFIGURATION_TYPES)
# Build Debug by default # Build Debug by default
IF (NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF () endif()
ELSE() else()
# Using a multi-configuration generator eg MSVC or Xcode # Using a multi-configuration generator eg MSVC or Xcode
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE # that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
ENDIF() endif()
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS) IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
# The actual sanitizer link target will be added when linking the fuzz # The actual sanitizer link target will be added when linking the fuzz
# targets. # targets.
SET(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link") set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
ADD_C_FLAG(-fsanitize=fuzzer-no-link) add_c_flag(-fsanitize=fuzzer-no-link)
UNSET(CMAKE_REQUIRED_FLAGS) unset(CMAKE_REQUIRED_FLAGS)
ENDIF () endif()
ADD_SUBDIRECTORY(src) #
# Subdirectories
# Tests #
IF (NOT MSVC)
IF (NOT BUILD_SHARED_LIBS) add_subdirectory(src)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF() if(BUILD_TESTS)
ENDIF () enable_testing()
add_subdirectory(tests)
IF (BUILD_TESTS) endif()
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests) if(BUILD_EXAMPLES)
ENDIF () add_subdirectory(examples)
endif()
IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples) if(BUILD_FUZZERS)
ENDIF () if(NOT USE_STANDALONE_FUZZERS)
if(BUILD_EXAMPLES)
IF(BUILD_FUZZERS) message(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
IF(NOT USE_STANDALONE_FUZZERS) endif()
IF(BUILD_EXAMPLES) if(BUILD_TESTS)
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the examples together") message(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
ENDIF() endif()
IF(BUILD_TESTS) endif()
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the tests together") add_subdirectory(fuzzers)
ENDIF() endif()
ENDIF()
ADD_SUBDIRECTORY(fuzzers) # Summary
ENDIF()
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
...@@ -4,18 +4,18 @@ ...@@ -4,18 +4,18 @@
# TODO: The Chromium build file (in deps/chromium-zlib/zlib/BUILD.gn) supports # TODO: The Chromium build file (in deps/chromium-zlib/zlib/BUILD.gn) supports
# more platforms (like ARM with NEON), more can be enabled as needed. # more platforms (like ARM with NEON), more can be enabled as needed.
CMAKE_MINIMUM_REQUIRED(VERSION 3.11) cmake_minimum_required(VERSION 3.11)
include(FetchContent) include(FetchContent)
include(FindGit) include(FindGit)
# Ensure that the git binary is present to download the sources. # Ensure that the git binary is present to download the sources.
find_package(Git) find_package(Git)
IF(NOT Git_FOUND) if(NOT Git_FOUND)
message(FATAL_ERROR "git is required to download the Chromium zlib sources") message(FATAL_ERROR "git is required to download the Chromium zlib sources")
ENDIF() endif()
FetchContent_Populate(chromium_zlib_src fetchcontent_populate(chromium_zlib_src
GIT_REPOSITORY https://chromium.googlesource.com/chromium/src/third_party/zlib.git GIT_REPOSITORY https://chromium.googlesource.com/chromium/src/third_party/zlib.git
GIT_TAG 2c183c9f93a328bfb3121284da13cf89a0f7e64a GIT_TAG 2c183c9f93a328bfb3121284da13cf89a0f7e64a
QUIET QUIET
...@@ -31,8 +31,8 @@ disable_warnings(missing-declarations) ...@@ -31,8 +31,8 @@ disable_warnings(missing-declarations)
# -O3 is also set by the Chromium configuration and has been deemed safe enough # -O3 is also set by the Chromium configuration and has been deemed safe enough
# for them. # for them.
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
# Common definitions. # Common definitions.
add_definitions( add_definitions(
......
FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h") file(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
LIST(SORT SRC_NTLMCLIENT) list(SORT SRC_NTLMCLIENT)
ADD_DEFINITIONS(-DNTLM_STATIC=1) add_definitions(-DNTLM_STATIC=1)
DISABLE_WARNINGS(implicit-fallthrough) disable_warnings(implicit-fallthrough)
IF(USE_ICONV) if(USE_ICONV)
ADD_DEFINITIONS(-DUNICODE_ICONV=1) add_definitions(-DUNICODE_ICONV=1)
FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h") file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
ELSE() else()
ADD_DEFINITIONS(-DUNICODE_BUILTIN=1) add_definitions(-DUNICODE_BUILTIN=1)
FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h") file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
ENDIF() endif()
IF(USE_HTTPS STREQUAL "SecureTransport") if(USE_HTTPS STREQUAL "SecureTransport")
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO) add_definitions(-DCRYPT_COMMONCRYPTO)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h") set(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
# CC_MD4 has been deprecated in macOS 10.15. # CC_MD4 has been deprecated in macOS 10.15.
SET_SOURCE_FILES_PROPERTIES("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated") set_source_files_properties("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
ELSEIF(USE_HTTPS STREQUAL "OpenSSL") elseif(USE_HTTPS STREQUAL "OpenSSL")
ADD_DEFINITIONS(-DCRYPT_OPENSSL) add_definitions(-DCRYPT_OPENSSL)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) include_directories(${OPENSSL_INCLUDE_DIR})
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h") set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
ELSEIF(USE_HTTPS STREQUAL "OpenSSL-Dynamic") elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
ADD_DEFINITIONS(-DCRYPT_OPENSSL) add_definitions(-DCRYPT_OPENSSL)
ADD_DEFINITIONS(-DCRYPT_OPENSSL_DYNAMIC) add_definitions(-DCRYPT_OPENSSL_DYNAMIC)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h") set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
ELSEIF(USE_HTTPS STREQUAL "mbedTLS") elseif(USE_HTTPS STREQUAL "mbedTLS")
ADD_DEFINITIONS(-DCRYPT_MBEDTLS) add_definitions(-DCRYPT_MBEDTLS)
INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR}) include_directories(${MBEDTLS_INCLUDE_DIR})
SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h") set(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
ELSE() else()
MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto") message(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
ENDIF() endif()
ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO}) add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
INCLUDE(CheckIncludeFile) include(CheckIncludeFile)
INCLUDE(CheckFunctionExists) include(CheckFunctionExists)
INCLUDE(CheckTypeSize) include(CheckTypeSize)
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) check_include_file(dirent.h HAVE_DIRENT_H)
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) check_include_file(stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) check_include_file(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) check_include_file(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) check_include_file(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) check_include_file(windows.h HAVE_WINDOWS_H)
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) check_function_exists(bcopy HAVE_BCOPY)
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) check_function_exists(memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) check_function_exists(strerror HAVE_STRERROR)
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL) check_function_exists(strtoll HAVE_STRTOLL)
CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ) check_function_exists(strtoq HAVE_STRTOQ)
CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64) check_function_exists(_strtoi64 HAVE__STRTOI64)
CHECK_TYPE_SIZE("long long" LONG_LONG) check_type_size("long long" LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG) check_type_size("unsigned long long" UNSIGNED_LONG_LONG)
DISABLE_WARNINGS(unused-function) disable_warnings(unused-function)
DISABLE_WARNINGS(implicit-fallthrough) disable_warnings(implicit-fallthrough)
# User-configurable options # User-configurable options
SET(SUPPORT_PCRE8 1) set(SUPPORT_PCRE8 1)
SET(PCRE_LINK_SIZE "2") set(PCRE_LINK_SIZE "2")
SET(PCRE_PARENS_NEST_LIMIT "250") set(PCRE_PARENS_NEST_LIMIT "250")
SET(PCRE_MATCH_LIMIT "10000000") set(PCRE_MATCH_LIMIT "10000000")
SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT") set(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
SET(PCRE_NEWLINE "LF") set(PCRE_NEWLINE "LF")
SET(NO_RECURSE 1) set(NO_RECURSE 1)
SET(PCRE_POSIX_MALLOC_THRESHOLD "10") set(PCRE_POSIX_MALLOC_THRESHOLD "10")
SET(BSR_ANYCRLF 0) set(BSR_ANYCRLF 0)
IF (MINGW) if(MINGW)
OPTION(NON_STANDARD_LIB_PREFIX option(NON_STANDARD_LIB_PREFIX
"ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc." "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
OFF) OFF)
OPTION(NON_STANDARD_LIB_SUFFIX option(NON_STANDARD_LIB_SUFFIX
"ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc." "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
OFF) OFF)
ENDIF(MINGW) endif(MINGW)
# Prepare build configuration # Prepare build configuration
SET(pcre_have_long_long 0) set(pcre_have_long_long 0)
SET(pcre_have_ulong_long 0) set(pcre_have_ulong_long 0)
IF(HAVE_LONG_LONG) if(HAVE_LONG_LONG)
SET(pcre_have_long_long 1) set(pcre_have_long_long 1)
ENDIF(HAVE_LONG_LONG) endif(HAVE_LONG_LONG)
IF(HAVE_UNSIGNED_LONG_LONG) if(HAVE_UNSIGNED_LONG_LONG)
SET(pcre_have_ulong_long 1) set(pcre_have_ulong_long 1)
ENDIF(HAVE_UNSIGNED_LONG_LONG) endif(HAVE_UNSIGNED_LONG_LONG)
SET(NEWLINE "") set(NEWLINE "")
IF(PCRE_NEWLINE STREQUAL "LF") if(PCRE_NEWLINE STREQUAL "LF")
SET(NEWLINE "10") set(NEWLINE "10")
ENDIF(PCRE_NEWLINE STREQUAL "LF") endif(PCRE_NEWLINE STREQUAL "LF")
IF(PCRE_NEWLINE STREQUAL "CR") if(PCRE_NEWLINE STREQUAL "CR")
SET(NEWLINE "13") set(NEWLINE "13")
ENDIF(PCRE_NEWLINE STREQUAL "CR") endif(PCRE_NEWLINE STREQUAL "CR")
IF(PCRE_NEWLINE STREQUAL "CRLF") if(PCRE_NEWLINE STREQUAL "CRLF")
SET(NEWLINE "3338") set(NEWLINE "3338")
ENDIF(PCRE_NEWLINE STREQUAL "CRLF") endif(PCRE_NEWLINE STREQUAL "CRLF")
IF(PCRE_NEWLINE STREQUAL "ANY") if(PCRE_NEWLINE STREQUAL "ANY")
SET(NEWLINE "-1") set(NEWLINE "-1")
ENDIF(PCRE_NEWLINE STREQUAL "ANY") endif(PCRE_NEWLINE STREQUAL "ANY")
IF(PCRE_NEWLINE STREQUAL "ANYCRLF") if(PCRE_NEWLINE STREQUAL "ANYCRLF")
SET(NEWLINE "-2") set(NEWLINE "-2")
ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF") endif(PCRE_NEWLINE STREQUAL "ANYCRLF")
IF(NEWLINE STREQUAL "") if(NEWLINE STREQUAL "")
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".") message(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
ENDIF(NEWLINE STREQUAL "") endif(NEWLINE STREQUAL "")
# Output files # Output files
CONFIGURE_FILE(config.h.in configure_file(config.h.in
${PROJECT_BINARY_DIR}/src/pcre/config.h ${PROJECT_BINARY_DIR}/src/pcre/config.h
@ONLY) @ONLY)
# Source code # Source code
SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h) set(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
SET(PCRE_SOURCES set(PCRE_SOURCES
pcre_byte_order.c pcre_byte_order.c
pcre_chartables.c pcre_chartables.c
pcre_compile.c pcre_compile.c
...@@ -113,28 +113,28 @@ SET(PCRE_SOURCES ...@@ -113,28 +113,28 @@ SET(PCRE_SOURCES
pcre_xclass.c pcre_xclass.c
) )
SET(PCREPOSIX_HEADERS pcreposix.h) set(PCREPOSIX_HEADERS pcreposix.h)
SET(PCREPOSIX_SOURCES pcreposix.c) set(PCREPOSIX_SOURCES pcreposix.c)
# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681 # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
# This code was taken from the CMake wiki, not from WebM. # This code was taken from the CMake wiki, not from WebM.
# Build setup # Build setup
ADD_DEFINITIONS(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
IF(MSVC) if(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC) endif(MSVC)
SET(CMAKE_INCLUDE_CURRENT_DIR 1) set(CMAKE_INCLUDE_CURRENT_DIR 1)
SET(targets) set(targets)
# Libraries # Libraries
# pcre # pcre
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/src/pcre) include_directories(${PROJECT_BINARY_DIR}/src/pcre)
ADD_LIBRARY(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES}) add_library(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
# end CMakeLists.txt # end CMakeLists.txt
FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH) find_program(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
IF (NOT DLLTOOL) if(NOT DLLTOOL)
MESSAGE(FATAL_ERROR "Could not find dlltool command") message(FATAL_ERROR "Could not find dlltool command")
ENDIF () endif()
SET(LIBWINHTTP_PATH "${libgit2_BINARY_DIR}/deps/winhttp") set(LIBWINHTTP_PATH "${libgit2_BINARY_DIR}/deps/winhttp")
SET(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE) set(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH}) file(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
IF (CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WINHTTP_DEF "winhttp64.def") set(WINHTTP_DEF "winhttp64.def")
ELSE() else()
set(WINHTTP_DEF "winhttp.def") set(WINHTTP_DEF "winhttp.def")
ENDIF() endif()
ADD_CUSTOM_COMMAND( add_custom_command(
OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a
COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a
DEPENDS ${WINHTTP_DEF} DEPENDS ${WINHTTP_DEF}
WORKING_DIRECTORY ${LIBWINHTTP_PATH} WORKING_DIRECTORY ${LIBWINHTTP_PATH}
) )
SET_SOURCE_FILES_PROPERTIES( set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c ${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a
) )
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) include_directories(${LIBGIT2_INCLUDES})
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES}) include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
FILE(GLOB LG2_SOURCES *.c *.h) file(GLOB LG2_SOURCES *.c *.h)
ADD_EXECUTABLE(lg2 ${LG2_SOURCES}) add_executable(lg2 ${LG2_SOURCES})
SET_TARGET_PROPERTIES(lg2 PROPERTIES C_STANDARD 90) set_target_properties(lg2 PROPERTIES C_STANDARD 90)
# Ensure that we do not use deprecated functions internally # Ensure that we do not use deprecated functions internally
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD) add_definitions(-DGIT_DEPRECATE_HARD)
IF(WIN32 OR ANDROID) if(WIN32 OR ANDROID)
TARGET_LINK_LIBRARIES(lg2 git2) target_link_libraries(lg2 git2)
ELSE() else()
TARGET_LINK_LIBRARIES(lg2 git2 pthread) target_link_libraries(lg2 git2 pthread)
ENDIF() endif()
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS}) link_directories(${LIBGIT2_LIBDIRS})
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) 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)
ADD_C_FLAG(-fsanitize=fuzzer) add_c_flag(-fsanitize=fuzzer)
ENDIF () endif()
FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c) file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
FOREACH(fuzz_target_src ${SRC_FUZZ}) foreach(fuzz_target_src ${SRC_FUZZ})
STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src}) string(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name}) string(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS}) set(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
IF(USE_STANDALONE_FUZZERS) if(USE_STANDALONE_FUZZERS)
LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c") list(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
ENDIF() endif()
ADD_EXECUTABLE(${fuzz_target_name} ${${fuzz_target_name}_SOURCES}) add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
SET_TARGET_PROPERTIES(${fuzz_target_name} PROPERTIES C_STANDARD 90) set_target_properties(${fuzz_target_name} PROPERTIES C_STANDARD 90)
TARGET_LINK_LIBRARIES(${fuzz_target_name} ${LIBGIT2_LIBS}) target_link_libraries(${fuzz_target_name} ${LIBGIT2_LIBS})
ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}") add_test(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
ENDFOREACH() endforeach()
add_library(git2internal OBJECT) add_library(git2internal OBJECT)
set_target_properties(git2internal PROPERTIES C_STANDARD 90) set_target_properties(git2internal PROPERTIES C_STANDARD 90)
IF(DEBUG_POOL)
SET(GIT_DEBUG_POOL 1)
ENDIF()
ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
IF(DEBUG_STRICT_ALLOC) if(DEBUG_POOL)
SET(GIT_DEBUG_STRICT_ALLOC 1) set(GIT_DEBUG_POOL 1)
ENDIF() endif()
ADD_FEATURE_INFO(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators") add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator")
if(DEBUG_STRICT_ALLOC)
set(GIT_DEBUG_STRICT_ALLOC 1)
endif()
add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
if(DEBUG_STRICT_OPEN)
set(GIT_DEBUG_STRICT_OPEN 1)
endif()
add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
IF(DEBUG_STRICT_OPEN)
SET(GIT_DEBUG_STRICT_OPEN 1)
ENDIF()
ADD_FEATURE_INFO(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
INCLUDE(PkgBuildConfig) include(PkgBuildConfig)
INCLUDE(SanitizeBool) include(SanitizeBool)
# This variable will contain the libraries we need to put into # This variable will contain the libraries we need to put into
# libgit2.pc's Requires.private. That is, what we're linking to or # libgit2.pc's Requires.private. That is, what we're linking to or
# what someone who's statically linking us needs to link to. # what someone who's statically linking us needs to link to.
SET(LIBGIT2_PC_REQUIRES "") set(LIBGIT2_PC_REQUIRES "")
# This will be set later if we use the system's http-parser library or # This will be set later if we use the system's http-parser library or
# use iconv (OSX) and will be written to the Libs.private field in the # use iconv (OSX) and will be written to the Libs.private field in the
# pc file. # pc file.
SET(LIBGIT2_PC_LIBS "") set(LIBGIT2_PC_LIBS "")
SET(LIBGIT2_INCLUDES set(LIBGIT2_INCLUDES
"${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${libgit2_SOURCE_DIR}/src" "${libgit2_SOURCE_DIR}/src"
"${libgit2_SOURCE_DIR}/include") "${libgit2_SOURCE_DIR}/include")
SET(LIBGIT2_SYSTEM_INCLUDES "") set(LIBGIT2_SYSTEM_INCLUDES "")
SET(LIBGIT2_LIBS "") set(LIBGIT2_LIBS "")
enable_warnings(missing-declarations) enable_warnings(missing-declarations)
IF (HAVE_FUTIMENS) if(HAVE_FUTIMENS)
SET(GIT_USE_FUTIMENS 1) set(GIT_USE_FUTIMENS 1)
ENDIF () endif ()
ADD_FEATURE_INFO(futimens GIT_USE_FUTIMENS "futimens support") 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" HAVE_QSORT_R_BSD)
IF (HAVE_QSORT_R_BSD) if(HAVE_QSORT_R_BSD)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
ENDIF() 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" HAVE_QSORT_R_GNU)
IF (HAVE_QSORT_R_GNU) if(HAVE_QSORT_R_GNU)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
ENDIF() endif()
CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S) check_function_exists(qsort_s HAVE_QSORT_S)
IF (HAVE_QSORT_S) if(HAVE_QSORT_S)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S) target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
ENDIF () endif()
# Find required dependencies # Find required dependencies
IF(WIN32) if(WIN32)
LIST(APPEND LIBGIT2_LIBS ws2_32) list(APPEND LIBGIT2_LIBS ws2_32)
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
LIST(APPEND LIBGIT2_LIBS socket nsl) list(APPEND LIBGIT2_LIBS socket nsl)
LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl") list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Haiku") elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
LIST(APPEND LIBGIT2_LIBS network) list(APPEND LIBGIT2_LIBS network)
LIST(APPEND LIBGIT2_PC_LIBS "-lnetwork") list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
ENDIF() endif()
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT) check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
IF(NEED_LIBRT) if(NEED_LIBRT)
LIST(APPEND LIBGIT2_LIBS rt) list(APPEND LIBGIT2_LIBS rt)
LIST(APPEND LIBGIT2_PC_LIBS "-lrt") list(APPEND LIBGIT2_PC_LIBS "-lrt")
ENDIF() endif()
IF(THREADSAFE) if(THREADSAFE)
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 THREADSAFE "threadsafe support")
if(WIN32 AND EMBED_SSH_PATH) if(WIN32 AND EMBED_SSH_PATH)
...@@ -96,204 +98,204 @@ if(WIN32 AND EMBED_SSH_PATH) ...@@ -96,204 +98,204 @@ if(WIN32 AND EMBED_SSH_PATH)
set(GIT_SSH 1) set(GIT_SSH 1)
endif() endif()
IF (WIN32 AND WINHTTP) if(WIN32 AND WINHTTP)
SET(GIT_WINHTTP 1) set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for winhttp, # 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 # we have to include a private header and generate our own import library
IF (MINGW) if(MINGW)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp") add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
LIST(APPEND LIBGIT2_LIBS winhttp) list(APPEND LIBGIT2_LIBS winhttp)
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp") list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
ELSE() else()
LIST(APPEND LIBGIT2_LIBS "winhttp") list(APPEND LIBGIT2_LIBS "winhttp")
LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp") list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
ENDIF () endif()
LIST(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32") list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32") list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
ENDIF() endif()
include(SelectHTTPSBackend) include(SelectHTTPSBackend)
include(SelectHashes) include(SelectHashes)
target_sources(git2internal PRIVATE ${SRC_SHA1}) target_sources(git2internal PRIVATE ${SRC_SHA1})
# Specify regular expression implementation # Specify regular expression implementation
FIND_PACKAGE(PCRE) find_package(PCRE)
IF(REGEX_BACKEND STREQUAL "") if(REGEX_BACKEND STREQUAL "")
CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L) check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
IF(HAVE_REGCOMP_L) if(HAVE_REGCOMP_L)
SET(REGEX_BACKEND "regcomp_l") set(REGEX_BACKEND "regcomp_l")
ELSEIF(PCRE_FOUND) elseif(PCRE_FOUND)
SET(REGEX_BACKEND "pcre") set(REGEX_BACKEND "pcre")
ELSE() else()
SET(REGEX_BACKEND "builtin") set(REGEX_BACKEND "builtin")
ENDIF() endif()
ENDIF() endif()
IF(REGEX_BACKEND STREQUAL "regcomp_l") if(REGEX_BACKEND STREQUAL "regcomp_l")
ADD_FEATURE_INFO(regex ON "using system regcomp_l") add_feature_info(regex ON "using system regcomp_l")
SET(GIT_REGEX_REGCOMP_L 1) set(GIT_REGEX_REGCOMP_L 1)
ELSEIF(REGEX_BACKEND STREQUAL "pcre2") elseif(REGEX_BACKEND STREQUAL "pcre2")
FIND_PACKAGE(PCRE2) find_package(PCRE2)
IF(NOT PCRE2_FOUND) if(NOT PCRE2_FOUND)
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found") MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
ENDIF() endif()
ADD_FEATURE_INFO(regex ON "using system PCRE2") add_feature_info(regex ON "using system PCRE2")
SET(GIT_REGEX_PCRE2 1) set(GIT_REGEX_PCRE2 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8") list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
ELSEIF(REGEX_BACKEND STREQUAL "pcre") elseif(REGEX_BACKEND STREQUAL "pcre")
ADD_FEATURE_INFO(regex ON "using system PCRE") add_feature_info(regex ON "using system PCRE")
SET(GIT_REGEX_PCRE 1) set(GIT_REGEX_PCRE 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES})
LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre") list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
ELSEIF(REGEX_BACKEND STREQUAL "regcomp") elseif(REGEX_BACKEND STREQUAL "regcomp")
ADD_FEATURE_INFO(regex ON "using system regcomp") add_feature_info(regex ON "using system regcomp")
SET(GIT_REGEX_REGCOMP 1) set(GIT_REGEX_REGCOMP 1)
ELSEIF(REGEX_BACKEND STREQUAL "builtin") elseif(REGEX_BACKEND STREQUAL "builtin")
ADD_FEATURE_INFO(regex ON "using bundled PCRE") add_feature_info(regex ON "using bundled PCRE")
SET(GIT_REGEX_BUILTIN 1) set(GIT_REGEX_BUILTIN 1)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre") add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre") list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>) list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
ELSE() else()
MESSAGE(FATAL_ERROR "The REGEX_BACKEND option provided is not supported") message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
ENDIF() endif()
# Optional external dependency: http-parser # Optional external dependency: http-parser
IF(USE_HTTP_PARSER STREQUAL "system") if(USE_HTTP_PARSER STREQUAL "system")
FIND_PACKAGE(HTTP_Parser) find_package(HTTP_Parser)
IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
ADD_FEATURE_INFO(http-parser ON "http-parser support (system)") add_feature_info(http-parser ON "http-parser support (system)")
ELSE() else()
MESSAGE(FATAL_ERROR "http-parser support was requested but not found") message(FATAL_ERROR "http-parser support was requested but not found")
ENDIF() endif()
ELSE() else()
MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.") 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") 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_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>") list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
ADD_FEATURE_INFO(http-parser ON "http-parser support (bundled)") add_feature_info(http-parser ON "http-parser support (bundled)")
ENDIF() endif()
# Optional external dependency: zlib # Optional external dependency: zlib
SanitizeBool(USE_BUNDLED_ZLIB) SanitizeBool(USE_BUNDLED_ZLIB)
IF(USE_BUNDLED_ZLIB STREQUAL ON) if(USE_BUNDLED_ZLIB STREQUAL ON)
SET(USE_BUNDLED_ZLIB "Bundled") set(USE_BUNDLED_ZLIB "Bundled")
ENDIF() endif()
IF(USE_BUNDLED_ZLIB STREQUAL "OFF") if(USE_BUNDLED_ZLIB STREQUAL "OFF")
FIND_PACKAGE(ZLIB) find_package(ZLIB)
IF(ZLIB_FOUND) if(ZLIB_FOUND)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
LIST(APPEND LIBGIT2_PC_LIBS "-lz") list(APPEND LIBGIT2_PC_LIBS "-lz")
ELSE() else()
LIST(APPEND LIBGIT2_PC_REQUIRES "zlib") list(APPEND LIBGIT2_PC_REQUIRES "zlib")
ENDIF() endif()
ADD_FEATURE_INFO(zlib ON "using system zlib") add_feature_info(zlib ON "using system zlib")
ELSE() else()
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." ) message(STATUS "zlib was not found; using bundled 3rd-party sources." )
ENDIF() endif()
ENDIF() endif()
IF(USE_BUNDLED_ZLIB STREQUAL "Chromium") if(USE_BUNDLED_ZLIB STREQUAL "Chromium")
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib") 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_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>) list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
ADD_FEATURE_INFO(zlib ON "using (Chromium) bundled zlib") add_feature_info(zlib ON "using (Chromium) bundled zlib")
ELSEIF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND) elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib") add_subdirectory("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib") list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>) list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
ADD_FEATURE_INFO(zlib ON "using bundled zlib") add_feature_info(zlib ON "using bundled zlib")
ENDIF() endif()
# Optional external dependency: libssh2 # Optional external dependency: libssh2
IF (USE_SSH) if(USE_SSH)
FIND_PKGLIBRARIES(LIBSSH2 libssh2) find_pkglibraries(LIBSSH2 libssh2)
IF (NOT LIBSSH2_FOUND) if(NOT LIBSSH2_FOUND)
FIND_PACKAGE(LibSSH2) find_package(LibSSH2)
SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY) get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
SET(LIBSSH2_LDFLAGS "-lssh2") set(LIBSSH2_LDFLAGS "-lssh2")
ENDIF() endif()
ENDIF() endif()
IF (LIBSSH2_FOUND) if(LIBSSH2_FOUND)
SET(GIT_SSH 1) set(GIT_SSH 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS}) list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS) if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
SET(GIT_SSH_MEMORY_CREDENTIALS 1) set(GIT_SSH_MEMORY_CREDENTIALS 1)
ENDIF() endif()
ELSE() else()
MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
ENDIF() endif()
ADD_FEATURE_INFO(SSH GIT_SSH "SSH transport support") add_feature_info(SSH GIT_SSH "SSH transport support")
# Optional external dependency: ntlmclient # Optional external dependency: ntlmclient
IF (USE_NTLMCLIENT) if(USE_NTLMCLIENT)
SET(GIT_NTLM 1) set(GIT_NTLM 1)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient") add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient") list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>") list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
ENDIF() endif()
ADD_FEATURE_INFO(ntlmclient GIT_NTLM "NTLM authentication support for Unix") add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
# Optional external dependency: GSSAPI # Optional external dependency: GSSAPI
INCLUDE(SelectGSSAPI) include(SelectGSSAPI)
# Optional external dependency: iconv # Optional external dependency: iconv
IF (USE_ICONV) if(USE_ICONV)
FIND_PACKAGE(Iconv) find_package(Iconv)
ENDIF() endif()
IF (ICONV_FOUND) if(ICONV_FOUND)
SET(GIT_USE_ICONV 1) set(GIT_USE_ICONV 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES}) list(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
ENDIF() 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(THREADSAFE)
IF (NOT WIN32) if(NOT WIN32)
FIND_PACKAGE(Threads REQUIRED) find_package(Threads REQUIRED)
ENDIF() endif()
SET(GIT_THREADS 1) set(GIT_THREADS 1)
ENDIF() endif()
IF (USE_NSEC) if(USE_NSEC)
SET(GIT_USE_NSEC 1) set(GIT_USE_NSEC 1)
ENDIF() endif()
IF (HAVE_STRUCT_STAT_ST_MTIM) if(HAVE_STRUCT_STAT_ST_MTIM)
SET(GIT_USE_STAT_MTIM 1) set(GIT_USE_STAT_MTIM 1)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC) elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
SET(GIT_USE_STAT_MTIMESPEC 1) set(GIT_USE_STAT_MTIMESPEC 1)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC) elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC)
SET(GIT_USE_STAT_MTIME_NSEC 1) set(GIT_USE_STAT_MTIME_NSEC 1)
ENDIF() endif()
target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64) target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
...@@ -307,7 +309,7 @@ target_sources(git2internal PRIVATE ${SRC_H}) ...@@ -307,7 +309,7 @@ target_sources(git2internal PRIVATE ${SRC_H})
# On Windows use specific platform sources # On Windows use specific platform sources
if(WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
SET(WIN_RC "win32/git2.rc") set(WIN_RC "win32/git2.rc")
file(GLOB SRC_OS win32/*.c win32/*.h) file(GLOB SRC_OS win32/*.c win32/*.h)
list(SORT SRC_OS) list(SORT SRC_OS)
...@@ -320,9 +322,9 @@ else() ...@@ -320,9 +322,9 @@ else()
target_sources(git2internal PRIVATE ${SRC_OS}) target_sources(git2internal PRIVATE ${SRC_OS})
endif() endif()
IF (USE_LEAK_CHECKER STREQUAL "valgrind") if(USE_LEAK_CHECKER STREQUAL "valgrind")
target_compile_definitions(git2internal PRIVATE VALGRIND) target_compile_definitions(git2internal PRIVATE VALGRIND)
ENDIF() endif()
file(GLOB SRC_GIT2 *.c *.h file(GLOB SRC_GIT2 *.c *.h
allocators/*.c allocators/*.h allocators/*.c allocators/*.h
...@@ -332,65 +334,65 @@ file(GLOB SRC_GIT2 *.c *.h ...@@ -332,65 +334,65 @@ file(GLOB SRC_GIT2 *.c *.h
list(SORT SRC_GIT2) list(SORT SRC_GIT2)
target_sources(git2internal PRIVATE ${SRC_GIT2}) target_sources(git2internal PRIVATE ${SRC_GIT2})
IF(APPLE) if(APPLE)
# The old Secure Transport API has been deprecated in macOS 10.15. # The old Secure Transport API has been deprecated in macOS 10.15.
SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated) set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
ENDIF() endif()
# the xdiff dependency is not (yet) warning-free, disable warnings as # the xdiff dependency is not (yet) warning-free, disable warnings as
# errors for the xdiff sources until we've sorted them out # errors for the xdiff sources until we've sorted them out
IF(MSVC) if(MSVC)
SET_SOURCE_FILES_PROPERTIES(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-) set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
SET_SOURCE_FILES_PROPERTIES(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-) set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
ENDIF() endif()
# Determine architecture of the machine # Determine architecture of the machine
IF (CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(GIT_ARCH_64 1) set(GIT_ARCH_64 1)
ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(GIT_ARCH_32 1) set(GIT_ARCH_32 1)
ELSEIF (CMAKE_SIZEOF_VOID_P) elseif(CMAKE_SIZEOF_VOID_P)
MESSAGE(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)") message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
ELSE() else()
MESSAGE(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)") message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
ENDIF() endif()
CONFIGURE_FILE(features.h.in git2/sys/features.h) configure_file(features.h.in git2/sys/features.h)
IDE_SPLIT_SOURCES(git2internal) ide_split_sources(git2internal)
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>) list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
TARGET_INCLUDE_DIRECTORIES(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include) target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
TARGET_INCLUDE_DIRECTORIES(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE) set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
SET(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE) set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE) set(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
IF(XCODE_VERSION) if(XCODE_VERSION)
# This is required for Xcode to actually link the libgit2 library # This is required for Xcode to actually link the libgit2 library
# when using only object libraries. # when using only object libraries.
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
LIST(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c) list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
ENDIF() endif()
# Compile and link libgit2 # Compile and link libgit2
ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS}) add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS}) target_link_libraries(git2 ${LIBGIT2_LIBS})
SET_TARGET_PROPERTIES(git2 PROPERTIES C_STANDARD 90) set_target_properties(git2 PROPERTIES C_STANDARD 90)
SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240) # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
# Win64+MSVC+static libs = linker error # Win64+MSVC+static libs = linker error
IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS) if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64") set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
ENDIF() endif()
IDE_SPLIT_SOURCES(git2) ide_split_sources(git2)
if(SONAME) if(SONAME)
set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION}) set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
...@@ -403,7 +405,7 @@ if(SONAME) ...@@ -403,7 +405,7 @@ if(SONAME)
endif() endif()
endif() endif()
PKG_BUILD_CONFIG(NAME libgit2 pkg_build_config(NAME libgit2
VERSION ${libgit2_VERSION} VERSION ${libgit2_VERSION}
DESCRIPTION "The git library, take 2" DESCRIPTION "The git library, take 2"
LIBS_SELF git2 LIBS_SELF git2
...@@ -411,17 +413,17 @@ PKG_BUILD_CONFIG(NAME libgit2 ...@@ -411,17 +413,17 @@ PKG_BUILD_CONFIG(NAME libgit2
REQUIRES ${LIBGIT2_PC_REQUIRES} REQUIRES ${LIBGIT2_PC_REQUIRES}
) )
IF (MSVC_IDE) if(MSVC_IDE)
# Precompiled headers # Precompiled headers
SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
SET_SOURCE_FILES_PROPERTIES(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h") set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
ENDIF () endif()
# Install # Install
INSTALL(TARGETS git2 install(TARGETS git2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
) )
INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
SET(Python_ADDITIONAL_VERSIONS 3 2.7) set(Python_ADDITIONAL_VERSIONS 3 2.7)
FIND_PACKAGE(PythonInterp) find_package(PythonInterp)
IF(NOT PYTHONINTERP_FOUND) if(NOT PYTHONINTERP_FOUND)
MESSAGE(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. " message(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. "
"Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests") "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
ENDIF() ENDIF()
SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/") set(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\") add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
ADD_DEFINITIONS(-DCLAR_WIN32_LONGPATHS) add_definitions(-DCLAR_WIN32_LONGPATHS)
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) add_definitions(-D_FILE_OFFSET_BITS=64)
# Ensure that we do not use deprecated functions internally # Ensure that we do not use deprecated functions internally
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD) add_definitions(-DGIT_DEPRECATE_HARD)
INCLUDE_DIRECTORIES(${CLAR_PATH} ${libgit2_BINARY_DIR}/src) include_directories(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h) 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") set(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")
IF(MSVC_IDE) if(MSVC_IDE)
LIST(APPEND SRC_CLAR "precompiled.c") list(APPEND SRC_CLAR "precompiled.c")
ENDIF() endif()
ADD_CUSTOM_COMMAND( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf . COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
DEPENDS ${SRC_TEST} DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH} WORKING_DIRECTORY ${CLAR_PATH}
) )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
SET_SOURCE_FILES_PROPERTIES( set_source_files_properties(
${CLAR_PATH}/clar.c ${CLAR_PATH}/clar.c
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite) PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) include_directories(${LIBGIT2_INCLUDES})
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES}) include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
ADD_EXECUTABLE(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS}) 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 C_STANDARD 90)
SET_TARGET_PROPERTIES(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(libgit2_tests PRIVATE ../src PUBLIC ../include) target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
TARGET_LINK_LIBRARIES(libgit2_tests ${LIBGIT2_LIBS}) target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
IDE_SPLIT_SOURCES(libgit2_tests) ide_split_sources(libgit2_tests)
IF (MSVC_IDE) if(MSVC_IDE)
# Precompiled headers # Precompiled headers
SET_TARGET_PROPERTIES(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
SET_SOURCE_FILES_PROPERTIES("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h") set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
ENDIF () endif()
FUNCTION(ADD_CLAR_TEST name) function(ADD_CLAR_TEST name)
IF (NOT USE_LEAK_CHECKER STREQUAL "OFF") if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
ADD_TEST(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN}) add_test(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
ELSE() else()
ADD_TEST(${name} "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN}) add_test(${name} "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
ENDIF() endif()
ENDFUNCTION(ADD_CLAR_TEST) endfunction(ADD_CLAR_TEST)
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)
ADD_CLAR_TEST(online_customcert -v -sonline::customcert) add_clar_test(online_customcert -v -sonline::customcert)
ADD_CLAR_TEST(gitdaemon -v -sonline::push) add_clar_test(gitdaemon -v -sonline::push)
ADD_CLAR_TEST(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh) add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
ADD_CLAR_TEST(proxy -v -sonline::clone::proxy) add_clar_test(proxy -v -sonline::clone::proxy)
ADD_CLAR_TEST(auth_clone -v -sonline::clone::cred) add_clar_test(auth_clone -v -sonline::clone::cred)
ADD_CLAR_TEST(auth_clone_and_push -v -sonline::clone::push -sonline::push) add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)
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