<commit_before>project(Appster)
cmake_minimum_required(VERSION 2.8)

##
# Files
##

set(SRC_LIST
    src/appster.c
    src/channel.c
    src/format.c
    src/log.c
    src/redis.c
    src/schema.c
)

add_library(${PROJECT_NAME} ${SRC_LIST})

##
# Dependencies
##

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

add_subdirectory(deps)
include_directories(SYSTEM deps)
target_link_libraries(${PROJECT_NAME}
    deps
)

find_package(Hiredis)
find_package(libdill REQUIRED)
find_package(LibUV REQUIRED)

include_directories(
    ${HIREDIS_INCLUDE_DIR}
    ${LIBDILL_INCLUDE_DIRS}
    ${LIBUV_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME}
    ${HIREDIS_LIBRARIES}
    ${LIBDILL_LIBRARIES}
    ${LIBUV_LIBRARIES}
)

if(HIREDIS_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIREDIS_DEFINITIONS}")
elseif()
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_REDIS")
endif()

##
# Compiler & linker flags
##

set(CMAKE_C_FLAGS "-Wall -Wno-sign-compare")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-function")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -static-libasan")
#    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
else()
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()

##
# Examples
##

add_executable(example_read src/examples/read.c)
add_executable(example_write src/examples/write.c)
add_executable(example_redis src/examples/redis.c)

target_link_libraries(example_read ${PROJECT_NAME} deps)
target_link_libraries(example_write ${PROJECT_NAME} deps)
target_link_libraries(example_redis ${PROJECT_NAME} deps)<commit_msg>Build shared library; Add install target<commit_after>project(appster)
cmake_minimum_required(VERSION 2.8)

##
# Files
##

set(SRC_LIST
    src/appster.c
    src/channel.c
    src/format.c
    src/log.c
    src/redis.c
    src/schema.c
)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")

add_library(object_${PROJECT_NAME} OBJECT ${SRC_LIST})

set_property(TARGET object_${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE 1)

add_library(shared_${PROJECT_NAME} SHARED $<TARGET_OBJECTS:object_${PROJECT_NAME}>)
add_library(static_${PROJECT_NAME} STATIC $<TARGET_OBJECTS:object_${PROJECT_NAME}>)

##
# Dependencies
##

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

add_subdirectory(deps)
include_directories(SYSTEM deps)
target_link_libraries(static_${PROJECT_NAME}
    deps
)
target_link_libraries(shared_${PROJECT_NAME}
    deps
)

find_package(Hiredis)
find_package(libdill REQUIRED)
find_package(LibUV REQUIRED)

include_directories(
    ${HIREDIS_INCLUDE_DIR}
    ${LIBDILL_INCLUDE_DIRS}
    ${LIBUV_INCLUDE_DIRS}
)

target_link_libraries(static_${PROJECT_NAME}
    ${HIREDIS_LIBRARIES}
    ${LIBDILL_LIBRARIES}
    ${LIBUV_LIBRARIES}
)

target_link_libraries(shared_${PROJECT_NAME}
    ${HIREDIS_LIBRARIES}
    ${LIBDILL_LIBRARIES}
    ${LIBUV_LIBRARIES}
)

if(HIREDIS_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIREDIS_DEFINITIONS}")
elseif()
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_REDIS")
endif()

##
# Compiler & linker flags
##

set(CMAKE_C_FLAGS "-Wall -Wno-sign-compare")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-function")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -static-libasan")
#    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
else()
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()

##
# Examples
##

add_executable(example_read src/examples/read.c)
add_executable(example_write src/examples/write.c)
add_executable(example_redis src/examples/redis.c)

target_link_libraries(example_read static_${PROJECT_NAME} deps)
target_link_libraries(example_write static_${PROJECT_NAME} deps)
target_link_libraries(example_redis static_${PROJECT_NAME} deps)

##
# Installation
##
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")

install(TARGETS shared_${PROJECT_NAME} DESTINATION "${LIB_INSTALL_DIR}")
install(TARGETS static_${PROJECT_NAME} DESTINATION "${LIB_INSTALL_DIR}")
install(FILES src/appster.h DESTINATION ${INCLUDE_INSTALL_DIR})
{'fraction_non_alphanumeric': 0.1255890669180019, 'fraction_numerical': 0.0025918944392082943, 'mean_word_length': 6.580357142857143, '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': '1013214', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1688, 'n_words': 222}