<commit_before>CMAKE_MINIMUM_REQUIRED( VERSION 2.8.9 )

ENABLE_TESTING()

SET( CMAKE_CXX_FLAGS "-std=c++11 -Wall" )
SET( CMAKE_CXX_FLAGS_DEGUG "-g -Og" )
SET( CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" )
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG" )
SET( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
SET( CMAKE_C_FLAGS "-Wall -fPIC" )
SET( CMAKE_C_FLAGS_DEGUG "-g -Og -fPIC" )
SET( CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -fPIC" )
SET( CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG -fPIC" )
SET( CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -fPIC" )

IF( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
    SET( CMAKE_BUILD_TYPE "MinSizeRel" )
ELSEIF( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
    ADD_DEFINITIONS( -DDEBUG )
ENDIF()

STRING( TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER )
SET( CFLAGS ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} )

# nasm (netwide assembler)
FIND_PROGRAM( BINNASM "nasm" )
IF( "${BINNASM}" STREQUAL "BINNASM-NOTFOUND" )
    MESSAGE( FATAL_ERROR "nasm not found" )
ENDIF()

# iconv
FIND_LIBRARY( LIBICONV "iconv" )
IF( "${LIBICONV}" STREQUAL "LIBICONV-NOTFOUND" )
    SET( LIBICONV "" )
ENDIF()

# threads
FIND_LIBRARY( LIBPTHREAD "pthread" )

# crypto libs
FIND_LIBRARY( LIBSSL "ssl" )
FIND_LIBRARY( LIBCRYPTO "crypto" )

# term capabilities
FIND_LIBRARY( LIBTERMCAP "termcap" )

# X11
FIND_LIBRARY( LIBX11 "X11" )

# X11 selection lib
SET( LIBXSEL "xsel" )
SET( LIBXSEL_DIR "libs/xsel-1.2.0" )
SET( LIBXSEL_INCLUDE_DIR "${LIBXSEL_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBXSEL_DIR} )

# apg lib
SET( LIBAPG "apg" )
SET( LIBAPG_DIR "libs/apg-2.2.3" )
SET( LIBAPG_INCLUDE_DIR "${LIBAPG_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBAPG_DIR} )

# libs/scrypt
SET( LIBSCRYPT "scrypt" )
SET( LIBSCRYPT_DIR "libs/scrypt-1.2.0" )
SET( LIBSCRYPT_INCLUDE_DIR "${LIBSCRYPT_DIR}/lib/crypto" )
ADD_SUBDIRECTORY( ${LIBSCRYPT_DIR} )

# libs/gtest
SET( LIBGTEST "gtest" )
SET( LIBGTEST_MAIN "gtest_main" )
SET( LIBGTEST_DIR "libs/gtest-1.7.0" )
SET( LIBGTEST_INCLUDE_DIR "${LIBGTEST_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBGTEST_DIR} )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${CMAKE_BINARY_DIR}/${LIBGTEST_DIR}" )
# set variables normally set by FIND_PACKAGE(GTest)
SET( GTEST_FOUND "GTEST_FOUND" )
SET( GTEST_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/${LIBGTEST_INCLUDE_DIR}" )
SET( GTEST_LIBRARIES "${LIBGTEST}" )
SET( GTEST_BOTH_LIBRARIES "${LIBGTEST} ${CMAKE_LINK_LIBRARY_FLAG}${LIBGTEST_MAIN}" )

# libs/msgpack
SET( LIBMSGPACK "msgpack-static" )
SET( LIBMSGPACK_DIR "libs/msgpack-1.1.0" )
SET( LIBMSGPACK_INCLUDE_DIR "${LIBMSGPACK_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBMSGPACK_DIR} )
ADD_DEPENDENCIES( msgpack gtest gtest_main )

# libs/libtecla
SET( LIBTECLA "libtecla_r.a" )
SET( LIBTECLA_DIR "libs/libtecla-1.6.3" )
SET( LIBTECLA_INCLUDE_DIR "${LIBTECLA_DIR}" )
SET( LIBTECLA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBTECLA_DIR}" )
SET( LIBTECLA_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBTECLA_DIR}" )
ADD_CUSTOM_TARGET(
    genlibtecladir
    mkdir -p "${LIBTECLA_BINARY_DIR}"
    )
ADD_CUSTOM_TARGET(
    libtecla
    COMMAND sh -c 'if [ ! -f ${LIBTECLA} ]\; then
            cp -r ${LIBTECLA_SOURCE_DIR}/* . \;
            patch -p1 < ${LIBTECLA_SOURCE_DIR}/../libtecla.patch \;
            CFLAGS=${CFLAGS} ./configure \;
            make \;
        fi'
    DEPENDS genlibtecladir
    WORKING_DIRECTORY "${LIBTECLA_BINARY_DIR}"
    )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBTECLA_BINARY_DIR}" )

# libs/flex
SET( LIBFLEX "libfl_pic.a" )
SET( LIBFLEX_DIR "libs/flex-2.5.39" )
SET( LIBFLEX_INCLUDE_DIR "${LIBFLEX_DIR}" )
SET( LIBFLEX_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBFLEX_DIR}" )
SET( LIBFLEX_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBFLEX_DIR}" )
SET( BINFLEX "${LIBFLEX_BINARY_DIR}/flex" )
ADD_CUSTOM_TARGET(
    genlibflexdir
    mkdir -p "${LIBFLEX_BINARY_DIR}"
    )
ADD_CUSTOM_TARGET(
    libflex
    COMMAND sh -c 'if [ ! -f ${BINFLEX} -o ! -f .libs/${LIBFLEX} ]\; then
            cp -r ${LIBFLEX_SOURCE_DIR}/* . \;
            CFLAGS=${CFLAGS} ./configure \;
            make all \;
        fi'
    DEPENDS genlibflexdir
    WORKING_DIRECTORY "${LIBFLEX_BINARY_DIR}"
    )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBFLEX_BINARY_DIR}/.libs" )

# libs/libjpeg-turbo and related stuff
SET( JPEGTRANF4 "jpegtranf4" )
SET( LIBJPEG "libjpeg.a" )
SET( LIBJPEGTURBO "libturbojpeg.a" )
SET( LIBJPEGTURBO_DIR "libs/libjpeg-turbo-1.4.1" )
SET( LIBJPEGTURBO_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBJPEGTURBO_DIR}" )
SET( LIBJPEGTURBO_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBJPEGTURBO_DIR}" )
SET( LIBJPEGTURBO_INCLUDE_DIR "${LIBJPEGTURBO_SOURCE_DIR};${LIBJPEGTURBO_BINARY_DIR}" )
ADD_LIBRARY( ${JPEGTRANF4} OBJECT
    "src/sesame/crypto/jpegtranf4.c"
    "${LIBJPEGTURBO_BINARY_DIR}/config.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfig.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfigint.h"
    )
ADD_CUSTOM_TARGET(
    genlibjpegturbodir
    mkdir -p "${LIBJPEGTURBO_BINARY_DIR}"
    )
ADD_CUSTOM_COMMAND(
    OUTPUT
    "${LIBJPEGTURBO_BINARY_DIR}/config.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfig.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfigint.h"
    COMMAND sh -c 'CFLAGS=${CFLAGS} ${LIBJPEGTURBO_SOURCE_DIR}/configure'
    COMMAND make
    DEPENDS genlibjpegturbodir
    WORKING_DIRECTORY "${LIBJPEGTURBO_BINARY_DIR}"
    )
SET_PROPERTY( TARGET ${JPEGTRANF4} APPEND PROPERTY INCLUDE_DIRECTORIES "${LIBJPEGTURBO_INCLUDE_DIR}" )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBJPEGTURBO_BINARY_DIR}/.libs" )

# where to place generated sources
SET( GEN_SOURCE_DIR "${CMAKE_BINARY_DIR}/gen" )

# sesame
ADD_SUBDIRECTORY( "src" )

# test
ADD_SUBDIRECTORY( "test" )
<commit_msg>Remove shared objects to ensure static linking.<commit_after>CMAKE_MINIMUM_REQUIRED( VERSION 2.8.9 )

ENABLE_TESTING()

SET( CMAKE_CXX_FLAGS "-std=c++11 -Wall" )
SET( CMAKE_CXX_FLAGS_DEGUG "-g -Og" )
SET( CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" )
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG" )
SET( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
SET( CMAKE_C_FLAGS "-Wall -fPIC" )
SET( CMAKE_C_FLAGS_DEGUG "-g -Og -fPIC" )
SET( CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -fPIC" )
SET( CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG -fPIC" )
SET( CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -fPIC" )

IF( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
    SET( CMAKE_BUILD_TYPE "MinSizeRel" )
ELSEIF( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
    ADD_DEFINITIONS( -DDEBUG )
ENDIF()

STRING( TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER )
SET( CFLAGS ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} )

# nasm (netwide assembler)
FIND_PROGRAM( BINNASM "nasm" )
IF( "${BINNASM}" STREQUAL "BINNASM-NOTFOUND" )
    MESSAGE( FATAL_ERROR "nasm not found" )
ENDIF()

# iconv
FIND_LIBRARY( LIBICONV "iconv" )
IF( "${LIBICONV}" STREQUAL "LIBICONV-NOTFOUND" )
    SET( LIBICONV "" )
ENDIF()

# threads
FIND_LIBRARY( LIBPTHREAD "pthread" )

# crypto libs
FIND_LIBRARY( LIBSSL "ssl" )
FIND_LIBRARY( LIBCRYPTO "crypto" )

# term capabilities
FIND_LIBRARY( LIBTERMCAP "termcap" )

# X11
FIND_LIBRARY( LIBX11 "X11" )

# X11 selection lib
SET( LIBXSEL "xsel" )
SET( LIBXSEL_DIR "libs/xsel-1.2.0" )
SET( LIBXSEL_INCLUDE_DIR "${LIBXSEL_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBXSEL_DIR} )

# apg lib
SET( LIBAPG "apg" )
SET( LIBAPG_DIR "libs/apg-2.2.3" )
SET( LIBAPG_INCLUDE_DIR "${LIBAPG_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBAPG_DIR} )

# libs/scrypt
SET( LIBSCRYPT "scrypt" )
SET( LIBSCRYPT_DIR "libs/scrypt-1.2.0" )
SET( LIBSCRYPT_INCLUDE_DIR "${LIBSCRYPT_DIR}/lib/crypto" )
ADD_SUBDIRECTORY( ${LIBSCRYPT_DIR} )

# libs/gtest
SET( LIBGTEST "gtest" )
SET( LIBGTEST_MAIN "gtest_main" )
SET( LIBGTEST_DIR "libs/gtest-1.7.0" )
SET( LIBGTEST_INCLUDE_DIR "${LIBGTEST_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBGTEST_DIR} )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${CMAKE_BINARY_DIR}/${LIBGTEST_DIR}" )
# set variables normally set by FIND_PACKAGE(GTest)
SET( GTEST_FOUND "GTEST_FOUND" )
SET( GTEST_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/${LIBGTEST_INCLUDE_DIR}" )
SET( GTEST_LIBRARIES "${LIBGTEST}" )
SET( GTEST_BOTH_LIBRARIES "${LIBGTEST} ${CMAKE_LINK_LIBRARY_FLAG}${LIBGTEST_MAIN}" )

# libs/msgpack
SET( LIBMSGPACK "msgpack-static" )
SET( LIBMSGPACK_DIR "libs/msgpack-1.1.0" )
SET( LIBMSGPACK_INCLUDE_DIR "${LIBMSGPACK_DIR}/include" )
ADD_SUBDIRECTORY( ${LIBMSGPACK_DIR} )
ADD_DEPENDENCIES( msgpack gtest gtest_main )

# libs/libtecla
SET( LIBTECLA "libtecla_r.a" )
SET( LIBTECLA_DIR "libs/libtecla-1.6.3" )
SET( LIBTECLA_INCLUDE_DIR "${LIBTECLA_DIR}" )
SET( LIBTECLA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBTECLA_DIR}" )
SET( LIBTECLA_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBTECLA_DIR}" )
ADD_CUSTOM_TARGET(
    genlibtecladir
    mkdir -p "${LIBTECLA_BINARY_DIR}"
    )
ADD_CUSTOM_TARGET(
    libtecla
    COMMAND sh -c 'if [ ! -f ${LIBTECLA} ]\; then
            cp -r ${LIBTECLA_SOURCE_DIR}/* . \;
            patch -p1 < ${LIBTECLA_SOURCE_DIR}/../libtecla.patch \;
            CFLAGS=${CFLAGS} ./configure \;
            make \;
        fi'
    DEPENDS genlibtecladir
    WORKING_DIRECTORY "${LIBTECLA_BINARY_DIR}"
    )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBTECLA_BINARY_DIR}" )

# libs/flex
SET( LIBFLEX "libfl_pic.a" )
SET( LIBFLEX_DIR "libs/flex-2.5.39" )
SET( LIBFLEX_INCLUDE_DIR "${LIBFLEX_DIR}" )
SET( LIBFLEX_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBFLEX_DIR}" )
SET( LIBFLEX_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBFLEX_DIR}" )
SET( BINFLEX "${LIBFLEX_BINARY_DIR}/flex" )
ADD_CUSTOM_TARGET(
    genlibflexdir
    mkdir -p "${LIBFLEX_BINARY_DIR}"
    )
ADD_CUSTOM_TARGET(
    libflex
    COMMAND sh -c 'if [ ! -f ${BINFLEX} -o ! -f .libs/${LIBFLEX} ]\; then
            cp -r ${LIBFLEX_SOURCE_DIR}/* . \;
            CFLAGS=${CFLAGS} ./configure \;
            make all \;
            rm -f .libs/*.so .libs/*.so.* \;
        fi'
    DEPENDS genlibflexdir
    WORKING_DIRECTORY "${LIBFLEX_BINARY_DIR}"
    )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBFLEX_BINARY_DIR}/.libs" )

# libs/libjpeg-turbo and related stuff
SET( JPEGTRANF4 "jpegtranf4" )
SET( LIBJPEG "libjpeg.a" )
SET( LIBJPEGTURBO "libturbojpeg.a" )
SET( LIBJPEGTURBO_DIR "libs/libjpeg-turbo-1.4.1" )
SET( LIBJPEGTURBO_SOURCE_DIR "${CMAKE_SOURCE_DIR}/${LIBJPEGTURBO_DIR}" )
SET( LIBJPEGTURBO_BINARY_DIR "${CMAKE_BINARY_DIR}/${LIBJPEGTURBO_DIR}" )
SET( LIBJPEGTURBO_INCLUDE_DIR "${LIBJPEGTURBO_SOURCE_DIR};${LIBJPEGTURBO_BINARY_DIR}" )
ADD_LIBRARY( ${JPEGTRANF4} OBJECT
    "src/sesame/crypto/jpegtranf4.c"
    "${LIBJPEGTURBO_BINARY_DIR}/config.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfig.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfigint.h"
    )
ADD_CUSTOM_TARGET(
    genlibjpegturbodir
    mkdir -p "${LIBJPEGTURBO_BINARY_DIR}"
    )
ADD_CUSTOM_COMMAND(
    OUTPUT
    "${LIBJPEGTURBO_BINARY_DIR}/config.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfig.h"
    "${LIBJPEGTURBO_BINARY_DIR}/jconfigint.h"
    COMMAND sh -c 'CFLAGS=${CFLAGS} ${LIBJPEGTURBO_SOURCE_DIR}/configure'
    COMMAND make
    COMMAND rm -f .libs/*.so .libs/*.so.*
    DEPENDS genlibjpegturbodir
    WORKING_DIRECTORY "${LIBJPEGTURBO_BINARY_DIR}"
    )
SET_PROPERTY( TARGET ${JPEGTRANF4} APPEND PROPERTY INCLUDE_DIRECTORIES "${LIBJPEGTURBO_INCLUDE_DIR}" )
SET_PROPERTY( DIRECTORY APPEND PROPERTY LINK_DIRECTORIES "${LIBJPEGTURBO_BINARY_DIR}/.libs" )

# where to place generated sources
SET( GEN_SOURCE_DIR "${CMAKE_BINARY_DIR}/gen" )

# sesame
ADD_SUBDIRECTORY( "src" )

# test
ADD_SUBDIRECTORY( "test" )

{'fraction_non_alphanumeric': 0.1387105286304864, 'fraction_numerical': 0.00809218049080834, 'mean_word_length': 4.8881408596582085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2169755', 'n_tokens_mistral': 5216, 'n_tokens_neox': 4853, 'n_words': 809}