<commit_before># Copyright (c) 2016 <NAME>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

cmake_minimum_required(VERSION 2.8)
project(string_theory)

set(ST_MAJOR_VERSION 1)
set(ST_MINOR_VERSION 0)
set(ST_VERSION ${ST_MAJOR_VERSION}.${ST_MINOR_VERSION})

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang")
    set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")

    include(CheckCXXCompilerFlag)
    check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX11)
    check_cxx_compiler_flag("-std=c++0x" HAVE_STD_CXX0X)
    if(HAVE_STD_CXX11)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    elseif(HAVE_STD_CXX0X)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
    endif()

    if(APPLE AND (HAVE_STD_CXX11 OR HAVE_STD_CXX0X))
        set(CMAKE_CXX_FLAGS "-stdlib=libc++")
    endif()
endif()

try_compile(ST_HAVE_NOEXCEPT "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_noexcept.cpp")
try_compile(ST_HAVE_OVERRIDE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_override.cpp")
try_compile(ST_HAVE_NULLPTR "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_nullptr.cpp")
try_compile(ST_HAVE_STATIC_ASSERT "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_static_assert.cpp")
try_compile(ST_HAVE_RVALUE_MOVE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_rvalue_move.cpp")
try_compile(ST_HAVE_CHAR_TYPES "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_char_types.cpp")
try_compile(ST_HAVE_USER_LITERALS "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_user_literals.cpp")
try_compile(ST_HAVE_INT64 "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_int64.cpp")
try_compile(ST_HAVE_DELETED_FUNC "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_deleted_func.cpp")
try_compile(ST_HAVE_VARARG_TEMPLATE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_vararg_template.cpp")
try_compile(ST_HAVE_TYPE_TRAITS "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_type_traits.cpp")
try_compile(ST_HAVE_CONSTEXPR "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp")
try_compile(ST_INT64_IS_NOT_LONG "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_int64_is_long.cpp")

if(NOT ST_INT64_IS_NOT_LONG)
    set(ST_INT64_IS_LONG TRUE)
endif()

include(CheckTypeSize)
if(NOT ST_WCHAR_BYTES)
    check_type_size("wchar_t" ST_WCHAR_BYTES)
    if(NOT ST_WCHAR_BYTES)
        message(FATAL_ERROR "Could not determine sizeof(wchar_t)")
        set(ST_WCHAR_BYTES 0)
    endif()
endif()

if(NOT ST_SIZET_BYTES)
    check_type_size("size_t" ST_SIZET_BYTES)
    if(NOT ST_SIZET_BYTES)
        message(FATAL_ERROR "Could not determine sizeof(size_t)")
        set(ST_SIZET_BYTES 0)
    endif()
endif()

option(ST_BUILD_STATIC "Build string_theory as a static library" OFF)
if(ST_BUILD_STATIC)
    set(ST_LIB_TYPE STATIC)
    set(ST_BUILD_SHARED FALSE)
else()
    set(ST_LIB_TYPE SHARED)
    set(ST_BUILD_SHARED TRUE)
    add_definitions(-DST_BUILD_EXPORTS)
endif()

configure_file("${PROJECT_SOURCE_DIR}/include/st_config.h.in"
               "${PROJECT_BINARY_DIR}/include/st_config.h")
include_directories("${PROJECT_BINARY_DIR}/include")

set(ST_HEADERS_PRIV
    include/st_assert.h
    include/st_charbuffer.h
    include/st_string.h
    include/st_stringstream.h
    "${PROJECT_BINARY_DIR}/include/st_config.h"
)
set(ST_HEADERS_PUB
    include/string_theory/assert
    include/string_theory/char_buffer
    include/string_theory/exceptions
    include/string_theory/string
    include/string_theory/string_stream
)
include_directories("${PROJECT_SOURCE_DIR}/include")

set(ST_SOURCES
    src/st_assert.cpp
    src/st_charbuffer.cpp
    src/st_format_priv.h
    src/st_string.cpp
    src/st_stringstream.cpp
)

if(ST_HAVE_VARARG_TEMPLATE AND ST_HAVE_TYPE_TRAITS)
    set(ST_HEADERS_PRIV ${ST_HEADERS_PRIV}
        include/st_formatter.h
        include/st_format.h
        include/st_stlformatter.h
        include/st_stdio.h
    )
    set(ST_HEADERS_PUB ${ST_HEADERS_PUB}
        include/string_theory/formatter
        include/string_theory/format
        include/string_theory/stl_formatter
        include/string_theory/stdio
    )
    set(ST_SOURCES ${ST_SOURCES}
        src/st_format.cpp
    )
    set(ST_HAVE_FORMAT TRUE)
endif()

set(ST_INSTALL_BIN_DIR "bin" CACHE PATH "Path to install DLLs on Windows")
set(ST_INSTALL_LIB_DIR "lib" CACHE PATH "Path to install shared libraries")
set(ST_INSTALL_INCLUDE_DIR "include" CACHE PATH "Path to install headers")
set(ST_INSTALL_CMAKE_DIR "${ST_INSTALL_LIB_DIR}/cmake" CACHE PATH "Path to install CMake files")

foreach(path LIB INCLUDE CMAKE)
    set(var ST_INSTALL_${path}_DIR)
    if(NOT IS_ABSOLUTE "${${var}}")
        set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
    endif()
endforeach()

add_library(string_theory ${ST_LIB_TYPE}
            ${ST_HEADERS_PRIV} ${ST_SOURCES})

set_target_properties(string_theory PROPERTIES
    VERSION ${ST_VERSION}
    SOVERSION ${ST_MAJOR_VERSION}
)

install(TARGETS string_theory
        EXPORT string_theory-targets
        RUNTIME DESTINATION "${ST_INSTALL_BIN_DIR}" COMPONENT shlib
        LIBRARY DESTINATION "${ST_INSTALL_LIB_DIR}" COMPONENT shlib
        ARCHIVE DESTINATION "${ST_INSTALL_LIB_DIR}" COMPONENT staticlib
)
install(FILES ${ST_HEADERS_PRIV} ${ST_HEADERS_PUB}
        DESTINATION "${ST_INSTALL_INCLUDE_DIR}/string_theory" COMPONENT devel)<commit_msg>Fix missing variable in absolute install-path generation<commit_after># Copyright (c) 2016 <NAME>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

cmake_minimum_required(VERSION 2.8)
project(string_theory)

set(ST_MAJOR_VERSION 1)
set(ST_MINOR_VERSION 0)
set(ST_VERSION ${ST_MAJOR_VERSION}.${ST_MINOR_VERSION})

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang")
    set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")

    include(CheckCXXCompilerFlag)
    check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX11)
    check_cxx_compiler_flag("-std=c++0x" HAVE_STD_CXX0X)
    if(HAVE_STD_CXX11)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    elseif(HAVE_STD_CXX0X)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
    endif()

    if(APPLE AND (HAVE_STD_CXX11 OR HAVE_STD_CXX0X))
        set(CMAKE_CXX_FLAGS "-stdlib=libc++")
    endif()
endif()

try_compile(ST_HAVE_NOEXCEPT "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_noexcept.cpp")
try_compile(ST_HAVE_OVERRIDE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_override.cpp")
try_compile(ST_HAVE_NULLPTR "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_nullptr.cpp")
try_compile(ST_HAVE_STATIC_ASSERT "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_static_assert.cpp")
try_compile(ST_HAVE_RVALUE_MOVE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_rvalue_move.cpp")
try_compile(ST_HAVE_CHAR_TYPES "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_char_types.cpp")
try_compile(ST_HAVE_USER_LITERALS "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_user_literals.cpp")
try_compile(ST_HAVE_INT64 "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_int64.cpp")
try_compile(ST_HAVE_DELETED_FUNC "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_deleted_func.cpp")
try_compile(ST_HAVE_VARARG_TEMPLATE "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_vararg_template.cpp")
try_compile(ST_HAVE_TYPE_TRAITS "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_type_traits.cpp")
try_compile(ST_HAVE_CONSTEXPR "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp")
try_compile(ST_INT64_IS_NOT_LONG "${PROJECT_BINARY_DIR}"
            "${PROJECT_SOURCE_DIR}/cmake/check_int64_is_long.cpp")

if(NOT ST_INT64_IS_NOT_LONG)
    set(ST_INT64_IS_LONG TRUE)
endif()

include(CheckTypeSize)
if(NOT ST_WCHAR_BYTES)
    check_type_size("wchar_t" ST_WCHAR_BYTES)
    if(NOT ST_WCHAR_BYTES)
        message(FATAL_ERROR "Could not determine sizeof(wchar_t)")
        set(ST_WCHAR_BYTES 0)
    endif()
endif()

if(NOT ST_SIZET_BYTES)
    check_type_size("size_t" ST_SIZET_BYTES)
    if(NOT ST_SIZET_BYTES)
        message(FATAL_ERROR "Could not determine sizeof(size_t)")
        set(ST_SIZET_BYTES 0)
    endif()
endif()

option(ST_BUILD_STATIC "Build string_theory as a static library" OFF)
if(ST_BUILD_STATIC)
    set(ST_LIB_TYPE STATIC)
    set(ST_BUILD_SHARED FALSE)
else()
    set(ST_LIB_TYPE SHARED)
    set(ST_BUILD_SHARED TRUE)
    add_definitions(-DST_BUILD_EXPORTS)
endif()

configure_file("${PROJECT_SOURCE_DIR}/include/st_config.h.in"
               "${PROJECT_BINARY_DIR}/include/st_config.h")
include_directories("${PROJECT_BINARY_DIR}/include")

set(ST_HEADERS_PRIV
    include/st_assert.h
    include/st_charbuffer.h
    include/st_string.h
    include/st_stringstream.h
    "${PROJECT_BINARY_DIR}/include/st_config.h"
)
set(ST_HEADERS_PUB
    include/string_theory/assert
    include/string_theory/char_buffer
    include/string_theory/exceptions
    include/string_theory/string
    include/string_theory/string_stream
)
include_directories("${PROJECT_SOURCE_DIR}/include")

set(ST_SOURCES
    src/st_assert.cpp
    src/st_charbuffer.cpp
    src/st_format_priv.h
    src/st_string.cpp
    src/st_stringstream.cpp
)

if(ST_HAVE_VARARG_TEMPLATE AND ST_HAVE_TYPE_TRAITS)
    set(ST_HEADERS_PRIV ${ST_HEADERS_PRIV}
        include/st_formatter.h
        include/st_format.h
        include/st_stlformatter.h
        include/st_stdio.h
    )
    set(ST_HEADERS_PUB ${ST_HEADERS_PUB}
        include/string_theory/formatter
        include/string_theory/format
        include/string_theory/stl_formatter
        include/string_theory/stdio
    )
    set(ST_SOURCES ${ST_SOURCES}
        src/st_format.cpp
    )
    set(ST_HAVE_FORMAT TRUE)
endif()

set(ST_INSTALL_BIN_DIR "bin" CACHE PATH "Path to install DLLs on Windows")
set(ST_INSTALL_LIB_DIR "lib" CACHE PATH "Path to install shared libraries")
set(ST_INSTALL_INCLUDE_DIR "include" CACHE PATH "Path to install headers")
set(ST_INSTALL_CMAKE_DIR "${ST_INSTALL_LIB_DIR}/cmake" CACHE PATH "Path to install CMake files")

foreach(path BIN LIB INCLUDE CMAKE)
    set(var ST_INSTALL_${path}_DIR)
    if(NOT IS_ABSOLUTE "${${var}}")
        set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
    endif()
endforeach()

add_library(string_theory ${ST_LIB_TYPE}
            ${ST_HEADERS_PRIV} ${ST_SOURCES})

set_target_properties(string_theory PROPERTIES
    VERSION ${ST_VERSION}
    SOVERSION ${ST_MAJOR_VERSION}
)

install(TARGETS string_theory
        EXPORT string_theory-targets
        RUNTIME DESTINATION "${ST_INSTALL_BIN_DIR}" COMPONENT shlib
        LIBRARY DESTINATION "${ST_INSTALL_LIB_DIR}" COMPONENT shlib
        ARCHIVE DESTINATION "${ST_INSTALL_LIB_DIR}" COMPONENT staticlib
)
install(FILES ${ST_HEADERS_PRIV} ${ST_HEADERS_PUB}
        DESTINATION "${ST_INSTALL_INCLUDE_DIR}/string_theory" COMPONENT devel)
{'fraction_non_alphanumeric': 0.09914671902136978, 'fraction_numerical': 0.005587857736162501, 'mean_word_length': 4.775839511556913, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '452530', 'n_tokens_mistral': 4877, 'n_tokens_neox': 4601, 'n_words': 868}