<commit_before>CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
PROJECT(libtins)

# Compile in release mode by default
IF(NOT CMAKE_BUILD_TYPE)
    MESSAGE(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
    SET(CMAKE_BUILD_TYPE RelWithDebInfo) 
ELSE(NOT CMAKE_BUILD_TYPE)
    MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.")
ENDIF(NOT CMAKE_BUILD_TYPE)

# Compilation flags.
IF(MSVC)
    # Don't always use Wall, since VC's /Wall is ridiculously verbose.
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
    # Disable VC secure checks, since these are not really issues.
    ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
    ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS=1")
    ADD_DEFINITIONS("-DNOGDI=1")
ELSE()
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ENDIF()

IF(APPLE)
    # This is set to ON as of policy CMP0042 
    SET(CMAKE_MACOSX_RPATH ON)
ENDIF()

# Build output checks
OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON)
IF(LIBTINS_BUILD_SHARED)
    MESSAGE(
        STATUS 
        "Build will generate a shared library. "
        "Use LIBTINS_BUILD_SHARED=0 to perform a static build"
    )
    SET(LIBTINS_TYPE SHARED)
ELSE(LIBTINS_BUILD_SHARED)
    MESSAGE(STATUS "Build will generate a static library.")
    SET(LIBTINS_TYPE STATIC)
    ADD_DEFINITIONS("-DTINS_STATIC=1")
ENDIF(LIBTINS_BUILD_SHARED)

# The version number.
SET(LIBTINS_VERSION_MAJOR 3)
SET(LIBTINS_VERSION_MINOR 3)
SET(LIBTINS_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")

# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

# Look for libpcap
FIND_PACKAGE(PCAP REQUIRED)

# Set some Windows specific flags
IF(WIN32)
    # We need to link against these libs
    SET(LIBTINS_OS_LIBS Ws2_32.lib Iphlpapi.lib)

    # Add the NOMINMAX macro to avoid Windows' min and max macros.
    ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(WIN32)

INCLUDE(ExternalProject)

# *******************
# Compilation options
# *******************

# Always check for C++ features
INCLUDE(CheckCXXFeatures)

IF(HAS_GCC_BUILTIN_SWAP)
    SET(TINS_HAVE_GCC_BUILTIN_SWAP ON)
ENDIF()

# C++11 support
OPTION(LIBTINS_ENABLE_CXX11 "Compile libtins with c++11 features" ON)
IF(LIBTINS_ENABLE_CXX11)
    # We only use declval and decltype on gcc/clang as VC fails to build that code,
    # at least on VC2013
    IF(HAS_CXX11_RVALUE_REFERENCES AND HAS_CXX11_FUNCTIONAL AND HAS_CXX11_CHRONO AND
       ((HAS_CXX11_DECLVAL AND HAS_CXX11_DECLTYPE) OR MSVC))
        SET(TINS_HAVE_CXX11 ON)
        MESSAGE(STATUS "Enabling C++11 features")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
    ELSE()
        MESSAGE(WARNING "The compiler doesn't support the necessary C++11 features. "
                        "Disabling C++11 on this build")
    ENDIF()
ELSE(LIBTINS_ENABLE_CXX11)
    MESSAGE(
        WARNING 
        "Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them. "
        "Unless you are using an old compiler, you should enable this option, "
        "as it increases the library's performance")
ENDIF(LIBTINS_ENABLE_CXX11)

# IEEE 802.11 and WPA2 decryption support
OPTION(LIBTINS_ENABLE_DOT11 "Compile libtins with IEEE 802.11 support" ON)
OPTION(LIBTINS_ENABLE_WPA2 "Compile libtins with WPA2 decryption features (requires OpenSSL)" ON)
IF(LIBTINS_ENABLE_DOT11)
    SET(TINS_HAVE_DOT11 ON)
    MESSAGE(STATUS "Enabling IEEE 802.11 support.")
    IF(LIBTINS_ENABLE_WPA2)
        FIND_PACKAGE(OpenSSL)
        IF(OPENSSL_FOUND)
            SET(TINS_HAVE_WPA2_DECRYPTION ON)
            MESSAGE(STATUS "Enabling WPA2 decryption support.")
        ELSE()
            MESSAGE(WARNING "Disabling WPA2 decryption support since OpenSSL was not found")
        ENDIF()
    ELSE(LIBTINS_ENABLE_WPA2)
        MESSAGE(STATUS "Disabling WPA2 decryption support.")
    ENDIF(LIBTINS_ENABLE_WPA2)
ENDIF(LIBTINS_ENABLE_DOT11)

OPTION(LIBTINS_ENABLE_ACK_TRACKER "Enable TCP ACK tracking support" ON)
IF(LIBTINS_ENABLE_ACK_TRACKER AND TINS_HAVE_CXX11)<commit_msg>Set OPENSSL_* variables to empty string if not found<commit_after>CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
PROJECT(libtins)

# Compile in release mode by default
IF(NOT CMAKE_BUILD_TYPE)
    MESSAGE(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
    SET(CMAKE_BUILD_TYPE RelWithDebInfo) 
ELSE(NOT CMAKE_BUILD_TYPE)
    MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.")
ENDIF(NOT CMAKE_BUILD_TYPE)

# Compilation flags.
IF(MSVC)
    # Don't always use Wall, since VC's /Wall is ridiculously verbose.
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
    # Disable VC secure checks, since these are not really issues.
    ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
    ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS=1")
    ADD_DEFINITIONS("-DNOGDI=1")
ELSE()
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ENDIF()

IF(APPLE)
    # This is set to ON as of policy CMP0042 
    SET(CMAKE_MACOSX_RPATH ON)
ENDIF()

# Build output checks
OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON)
IF(LIBTINS_BUILD_SHARED)
    MESSAGE(
        STATUS 
        "Build will generate a shared library. "
        "Use LIBTINS_BUILD_SHARED=0 to perform a static build"
    )
    SET(LIBTINS_TYPE SHARED)
ELSE(LIBTINS_BUILD_SHARED)
    MESSAGE(STATUS "Build will generate a static library.")
    SET(LIBTINS_TYPE STATIC)
    ADD_DEFINITIONS("-DTINS_STATIC=1")
ENDIF(LIBTINS_BUILD_SHARED)

# The version number.
SET(LIBTINS_VERSION_MAJOR 3)
SET(LIBTINS_VERSION_MINOR 3)
SET(LIBTINS_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")

# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

# Look for libpcap
FIND_PACKAGE(PCAP REQUIRED)

# Set some Windows specific flags
IF(WIN32)
    # We need to link against these libs
    SET(LIBTINS_OS_LIBS Ws2_32.lib Iphlpapi.lib)

    # Add the NOMINMAX macro to avoid Windows' min and max macros.
    ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(WIN32)

INCLUDE(ExternalProject)

# *******************
# Compilation options
# *******************

# Always check for C++ features
INCLUDE(CheckCXXFeatures)

IF(HAS_GCC_BUILTIN_SWAP)
    SET(TINS_HAVE_GCC_BUILTIN_SWAP ON)
ENDIF()

# C++11 support
OPTION(LIBTINS_ENABLE_CXX11 "Compile libtins with c++11 features" ON)
IF(LIBTINS_ENABLE_CXX11)
    # We only use declval and decltype on gcc/clang as VC fails to build that code,
    # at least on VC2013
    IF(HAS_CXX11_RVALUE_REFERENCES AND HAS_CXX11_FUNCTIONAL AND HAS_CXX11_CHRONO AND
       ((HAS_CXX11_DECLVAL AND HAS_CXX11_DECLTYPE) OR MSVC))
        SET(TINS_HAVE_CXX11 ON)
        MESSAGE(STATUS "Enabling C++11 features")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
    ELSE()
        MESSAGE(WARNING "The compiler doesn't support the necessary C++11 features. "
                        "Disabling C++11 on this build")
    ENDIF()
ELSE(LIBTINS_ENABLE_CXX11)
    MESSAGE(
        WARNING 
        "Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them. "
        "Unless you are using an old compiler, you should enable this option, "
        "as it increases the library's performance")
ENDIF(LIBTINS_ENABLE_CXX11)

# IEEE 802.11 and WPA2 decryption support
OPTION(LIBTINS_ENABLE_DOT11 "Compile libtins with IEEE 802.11 support" ON)
OPTION(LIBTINS_ENABLE_WPA2 "Compile libtins with WPA2 decryption features (requires OpenSSL)" ON)
IF(LIBTINS_ENABLE_DOT11)
    SET(TINS_HAVE_DOT11 ON)
    MESSAGE(STATUS "Enabling IEEE 802.11 support.")
    IF(LIBTINS_ENABLE_WPA2)
        FIND_PACKAGE(OpenSSL)
        IF(OPENSSL_FOUND)
            SET(TINS_HAVE_WPA2_DECRYPTION ON)
            MESSAGE(STATUS "Enabling WPA2 decryption support.")
        ELSE()
            MESSAGE(WARNING "Disabling WPA2 decryption support since OpenSSL was not found")
            # Default this to empty strings
            SET(OPENSSL_INCLUDE_DIR "")
            SET(OPENSSL_LIBRARIES "")
        ENDIF()
    ELSE(LIBTINS_ENABLE_WPA2)
        MESSAGE(STATUS "Disabling WPA2 decryption support.")
    ENDIF(LIBTINS_ENABLE_WPA2)
ENDIF(LIBTINS_ENABLE_DOT11)

OPTION(LIBTINS_ENABLE_ACK_TRACKER "Enable TCP ACK tracking support" ON)
IF(LIBTINS_ENABLE_ACK_TRACKER AND TINS_HAVE_CXX11)
{'fraction_non_alphanumeric': 0.08993369499698614, 'fraction_numerical': 0.02362869198312236, 'mean_word_length': 4.253958201393287, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4959414', 'n_tokens_mistral': 3225, 'n_tokens_neox': 2913, 'n_words': 712}