<commit_before>cmake_minimum_required(VERSION 3.6)
project(snip)

set(SNIP_VERSION 0.1)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/third_party/libevent/" "/usr/lib/" "/usr/local/lib/" )
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/third_party/libevent/include" "/usr/include/" "/usr/local/include/" )

set(CMAKE_C_STANDARD 99)

option(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES
    "Download and build dependencies files." OFF)

if(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES)
	if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/libevent/include/event2/event.h")
		execute_process(COMMAND "git" "clone" "-b" "patches-2.1" "https://github.com/libevent/libevent.git" "${CMAKE_SOURCE_DIR}/third_party/libevent")
	endif()
	set(EVENT__DISABLE_OPENSSL ON)
	set(EVENT__DISABLE_TESTS ON)
	add_subdirectory("third_party/libevent")
	set(LIBEVENT_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/libevent/include")
	if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/libyaml/include/yaml.h")
		execute_process(COMMAND "git" "clone" "https://github.com/yaml/libyaml.git" "${CMAKE_SOURCE_DIR}/third_party/libyaml")
	endif()
	add_subdirectory("third_party/libyaml")
	set(LibYAML_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/libyaml/include")
	set(LibYAML_LIBRARIES "${CMAKE_SOURCE_DIR}/third_party/libyaml")
else ()
	find_package(LibYAML)
	include_directories(${LibYAML_INCLUDE_DIRS})
	set(LIBS ${LIBS} ${LibYAML_LIBRARIES})
	if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
		find_package(Libevent 2.1 REQUIRED libevent windows)
	else()
		find_package(Libevent 2.1 REQUIRED libevent pthreads)
	endif()
endif()




include_directories(${LIBEVENT_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBEVENT_LIBRARIES})



#find_package(OpenSSL REQUIRED)
#include_directories(${OPENSSL_INCLUDE_DIR})
#set(LIBS ${LIBS} ${OPENSSL_LIBRARIES})

set(SOURCE_FILES snip.c snip.h tls.h compat.h config.c config.h log.c log.h net_util.c net_util.h sys_util.c sys_util.h tls.c)
add_executable(snip main.c ${SOURCE_FILES})



target_compile_definitions(snip
        PUBLIC SNIP_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        PUBLIC SNIP_INSTALL_CONF_DIR="${CMAKE_INSTALL_PREFIX}etc/"
        PUBLIC SNIP_INSTALL_CONF_PATH="${CMAKE_INSTALL_CONF_DIR}snip.yml"
        PUBLIC SNIP_VERSION="${SNIP_VERSION}"
        )

add_subdirectory(tests)

target_link_libraries(snip ${LIBS})

# We build this as a library so we can test with it.  May eventually make it available this way also though.
add_library(snip_lib ${SOURCE_FILES})
target_compile_definitions(snip_lib
        PUBLIC SNIP_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        PUBLIC SNIP_INSTALL_CONF_DIR="${CMAKE_INSTALL_PREFIX}etc/"
        PUBLIC SNIP_INSTALL_CONF_PATH="${CMAKE_INSTALL_CONF_DIR}snip.yml"
        PUBLIC SNIP_VERSION="${SNIP_VERSION}"
        )
target_link_libraries(snip_lib ${LIBS})

if(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES) 
# If we downloaded dependencies, we should build, require, and use them.
add_dependencies(snip event)
add_dependencies(snip_lib event)
add_dependencies(snip yaml)
add_dependencies(snip_lib yaml)
endif()<commit_msg>Fix SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES to work on mac.<commit_after>cmake_minimum_required(VERSION 3.6)
project(snip)

set(SNIP_VERSION 0.1)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "/usr/lib/" "/usr/local/lib/" )
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/third_party/libevent/include" "${CMAKE_SOURCE_DIR}/third_party/libyaml/include" "/usr/include/" "/usr/local/include/" )

set(CMAKE_C_STANDARD 99)

option(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES
    "Download and build dependencies files." OFF)

if(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES)
	if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/libevent/include/event2/event.h")
		execute_process(COMMAND "git" "clone" "-b" "patches-2.1" "https://github.com/libevent/libevent.git" "${CMAKE_SOURCE_DIR}/third_party/libevent")
	endif()
	set(EVENT__DISABLE_OPENSSL ON)
	set(EVENT__DISABLE_TESTS ON)
	add_subdirectory("third_party/libevent")
	# set(LIBEVENT_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/libevent/include")

	if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/libyaml/include/yaml.h")
		execute_process(COMMAND "git" "clone" "https://github.com/yaml/libyaml.git" "${CMAKE_SOURCE_DIR}/third_party/libyaml")
	endif()
	add_subdirectory("third_party/libyaml")
	set(LibYAML_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/libyaml/include")
else ()
	find_package(LibYAML)
	include_directories(${LibYAML_INCLUDE_DIRS})
	set(LIBS ${LIBS} ${LibYAML_LIBRARIES})
	if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
		find_package(Libevent 2.1 REQUIRED libevent windows)
	else()
		find_package(Libevent 2.1 REQUIRED libevent pthreads)
	endif()
endif()




include_directories(${LIBEVENT_INCLUDE_DIRS} ${LibYAML_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBEVENT_LIBRARIES} ${LibYAML_LIBRARIES})



#find_package(OpenSSL REQUIRED)
#include_directories(${OPENSSL_INCLUDE_DIR})
#set(LIBS ${LIBS} ${OPENSSL_LIBRARIES})

set(SOURCE_FILES snip.c snip.h tls.h compat.h config.c config.h log.c log.h net_util.c net_util.h sys_util.c sys_util.h tls.c)
add_executable(snip main.c ${SOURCE_FILES})



target_compile_definitions(snip
        PUBLIC SNIP_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        PUBLIC SNIP_INSTALL_CONF_DIR="${CMAKE_INSTALL_PREFIX}etc/"
        PUBLIC SNIP_INSTALL_CONF_PATH="${CMAKE_INSTALL_CONF_DIR}snip.yml"
        PUBLIC SNIP_VERSION="${SNIP_VERSION}"
        )

add_subdirectory(tests)

target_link_libraries(snip ${LIBS})

# We build this as a library so we can test with it.  May eventually make it available this way also though.
add_library(snip_lib ${SOURCE_FILES})
target_compile_definitions(snip_lib
        PUBLIC SNIP_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        PUBLIC SNIP_INSTALL_CONF_DIR="${CMAKE_INSTALL_PREFIX}etc/"
        PUBLIC SNIP_INSTALL_CONF_PATH="${CMAKE_INSTALL_CONF_DIR}snip.yml"
        PUBLIC SNIP_VERSION="${SNIP_VERSION}"
        )
target_link_libraries(snip_lib ${LIBS})

if(SNIP__DOWNLOAD_AND_BUILD_DEPENDENCIES) 
# If we downloaded dependencies, we should build, require, and use them.
add_dependencies(snip event)
add_dependencies(snip_lib event)
add_dependencies(snip yaml)
add_dependencies(snip_lib yaml)
endif()
{'fraction_non_alphanumeric': 0.11946624803767661, 'fraction_numerical': 0.004081632653061225, 'mean_word_length': 6.8654320987654325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4282407', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2319, 'n_words': 356}