<commit_before># CMake build script for the libgit2 project
#
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install

PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

FILE(STRINGS "include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")

STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR  "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")

IF (AMIGA)
	# Default AmigaOS to use the PowerPC SHA1
	SET(SHA1_TYPE "ppc")
ENDIF()

# Find required dependencies
INCLUDE_DIRECTORIES(src include deps/http-parser)

FILE(GLOB SRC_HTTP deps/http-parser/*.c)

# Specify sha1 implementation
IF (SHA1_TYPE STREQUAL "ppc")
	ADD_DEFINITIONS(-DPPC_SHA1)
	FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
ELSE ()
	SET (SRC_SHA1)
ENDIF()

IF (NOT WIN32)
	FIND_PACKAGE(ZLIB)
	IF (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
		INCLUDE_DIRECTORIES(deps/regex)
		SET(SRC_REGEX deps/regex/regex.c)
	ENDIF()
ELSE()
	# Windows doesn't understand POSIX regex on its own
	INCLUDE_DIRECTORIES(deps/regex)
	SET(SRC_REGEX deps/regex/regex.c)
ENDIF()

IF (ZLIB_FOUND)
	INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
	LINK_LIBRARIES(${ZLIB_LIBRARIES})
ELSE (ZLIB_FOUND)
	INCLUDE_DIRECTORIES(deps/zlib)
	ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
	FILE(GLOB SRC_ZLIB deps/zlib/*.c)
ENDIF()

# Installation paths
SET(INSTALL_BIN bin CACHE PATH "Where to install binaries to.")
SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
SET(INSTALL_INC include CACHE PATH "Where to install headers to.")

# Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
OPTION (BUILD_CLAR "Build Tests using the Clar suite" OFF)
OPTION (BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION (TAGS "Generate tags" OFF)
OPTION (PROFILE "Generate profiling information" OFF)

# Platform specific compilation flags
IF (MSVC)
	# Not using __stdcall with the CRT causes problems
	OPTION (STDCALL "Buildl libgit2 with the __stdcall convention" ON)

	SET(CMAKE_C_FLAGS "/W4 /MP /nologo /Zi ${CMAKE_C_FLAGS}")
	IF (STDCALL)
	  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
	ENDIF ()
	SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd /RTC1 /RTCs /RTCu")
	SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
	SET(WIN_RC "src/win32/git2.rc")

   # Precompiled headers
ELSE ()
	SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}")
	SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
	IF (MINGW) # MinGW always does PIC and complains if we tell it to
		STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
	ELSE ()
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
	ENDIF ()
	IF (PROFILE)
		SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
		SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
	ENDIF ()<commit_msg>revert defaults<commit_after># CMake build script for the libgit2 project
#
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install

PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

FILE(STRINGS "include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")

STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR  "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")

IF (AMIGA)
	# Default AmigaOS to use the PowerPC SHA1
	SET(SHA1_TYPE "ppc")
ENDIF()

# Find required dependencies
INCLUDE_DIRECTORIES(src include deps/http-parser)

FILE(GLOB SRC_HTTP deps/http-parser/*.c)

# Specify sha1 implementation
IF (SHA1_TYPE STREQUAL "ppc")
	ADD_DEFINITIONS(-DPPC_SHA1)
	FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
ELSE ()
	SET (SRC_SHA1)
ENDIF()

IF (NOT WIN32)
	FIND_PACKAGE(ZLIB)
	IF (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
		INCLUDE_DIRECTORIES(deps/regex)
		SET(SRC_REGEX deps/regex/regex.c)
	ENDIF()
ELSE()
	# Windows doesn't understand POSIX regex on its own
	INCLUDE_DIRECTORIES(deps/regex)
	SET(SRC_REGEX deps/regex/regex.c)
ENDIF()

IF (ZLIB_FOUND)
	INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
	LINK_LIBRARIES(${ZLIB_LIBRARIES})
ELSE (ZLIB_FOUND)
	INCLUDE_DIRECTORIES(deps/zlib)
	ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
	FILE(GLOB SRC_ZLIB deps/zlib/*.c)
ENDIF()

# Installation paths
SET(INSTALL_BIN bin CACHE PATH "Where to install binaries to.")
SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
SET(INSTALL_INC include CACHE PATH "Where to install headers to.")

# Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION (BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION (TAGS "Generate tags" OFF)
OPTION (PROFILE "Generate profiling information" OFF)

# Platform specific compilation flags
IF (MSVC)
	# Not using __stdcall with the CRT causes problems
	OPTION (STDCALL "Buildl libgit2 with the __stdcall convention" ON)

	SET(CMAKE_C_FLAGS "/W4 /MP /nologo /Zi ${CMAKE_C_FLAGS}")
	IF (STDCALL)
	  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
	ENDIF ()
	SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd /RTC1 /RTCs /RTCu")
	SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
	SET(WIN_RC "src/win32/git2.rc")

   # Precompiled headers
ELSE ()
	SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}")
	SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
	IF (MINGW) # MinGW always does PIC and complains if we tell it to
		STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
	ELSE ()
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
	ENDIF ()
	IF (PROFILE)
		SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
		SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
	ENDIF ()
{'fraction_non_alphanumeric': 0.13980409617097062, 'fraction_numerical': 0.016325319085782133, 'mean_word_length': 5.333646616541353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6045986', 'n_tokens_mistral': 2893, 'n_tokens_neox': 2738, 'n_words': 621}