<commit_before>cmake_minimum_required(VERSION 2.8)

project(lua-http-parser C)

set(BUILD_SHARED_LIBS TRUE)

include(FindPkgConfig)

#
# Find system libraries
#
set(COMMON_CFLAGS "${CFLAGS}")

## Lua 5.1.x
pkg_search_module(LUA REQUIRED lua lua5.1 lua-5.1)
set(COMMON_CFLAGS "${COMMON_CFLAGS} ${LUA_CFLAGS}")

## setup git submodules
execute_process(COMMAND git submodule init)
execute_process(COMMAND git submodule update)

include_directories(
				${CMAKE_CURRENT_SOURCE_DIR}
				${CMAKE_CURRENT_SOURCE_DIR}/http-parser
				)
add_library(parser MODULE lua-http-parser.c http-parser/http_parser.c)
set_target_properties(parser PROPERTIES
				COMPILE_FLAGS "${COMMON_CFLAGS}"
				PREFIX "")
install(TARGETS parser
				LIBRARY DESTINATION ${INSTALL_LIBDIR}/http
				)
<commit_msg>CMake fix for my env.<commit_after>cmake_minimum_required(VERSION 2.8)

project(lua-http-parser C)

set(BUILD_SHARED_LIBS TRUE)

set(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules (configure lua via LUA_CPATH)")

## Lua 5.1.x
include(FindLua51)
if(!${LUA51_FOUND})
    message(FATAL_ERROR "The FindLua51 module could not find lua :-(")
endif()


## setup git submodules
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                COMMAND git submodule init)
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                COMMAND git submodule update)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/http-parser
                    ${LUA_INCLUDE_DIR})

add_library(parser MODULE lua-http-parser.c http-parser/http_parser.c)
set_target_properties(parser PROPERTIES PREFIX "")
set_target_properties(parser PROPERTIES OUTPUT_NAME parser)

target_link_libraries(parser ${LUA_LIBRARIES})

install(TARGETS parser
        DESTINATION "${INSTALL_CMOD}/http")


## Setup test stuff
include(CTest)
add_test(test ${LUA} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/)
add_test(benchmark ${LUA} ${CMAKE_CURRENT_SOURCE_DIR}/benchmark.lua ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/)
set_tests_properties(test
                     PROPERTIES
                     FAIL_REGULAR_EXPRESSION
                     "not ok")
{'fraction_non_alphanumeric': 0.09743135518157661, 'fraction_numerical': 0.007971656333038087, 'mean_word_length': 4.7774936061381075, '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': '2430319', 'n_tokens_mistral': 823, 'n_tokens_neox': 757, 'n_words': 141}