<commit_before>cmake_minimum_required (VERSION 2.6)
project (LuaGumbo C)

set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_C_STANDARD 99)

if(UNIX)
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

# Lua
if(WIN32)
  find_package (Lua REQUIRED)
else()
  # Only the include dir matters on UNIX
  find_package (Lua)
  if(NOT LUA_INCLUDE_DIR)
    message( FATAL_ERROR "Variable `LUA_INCLUDE_DIR' expected to be defined.")
  endif()
endif()

# Gumbo
set(LIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/lib)
set(WINDOWS_LIB_INCLUDE_DIR ${LIB_INCLUDE_DIR}/visualc/include)

set ( LIBGUMBO_SRC
  lib/attribute.c lib/attribute.h lib/char_ref.c lib/char_ref.h
  lib/error.c lib/error.h lib/gumbo.h lib/insertion_mode.h lib/macros.h
  lib/parser.c lib/parser.h lib/replacement.h lib/string_buffer.c
  lib/string_buffer.h lib/string_piece.c lib/svg_attrs.c lib/svg_tags.c
  lib/tag.c lib/tag_lookup.c lib/tag_lookup.h lib/tokenizer.c
  lib/tokenizer.h lib/tokenizer_states.h lib/token_type.h lib/utf8.c
  lib/utf8.h lib/util.c lib/util.h lib/vector.c lib/vector.h
)

include_directories( ${LIB_INCLUDE_DIR} )
if (WIN32)
  include_directories( ${WINDOWS_LIB_INCLUDE_DIR} )
endif()

# Lua-Gumbo
add_library( parse MODULE gumbo/parse.c ${LIBGUMBO_SRC} )
set_target_properties( parse PROPERTIES PREFIX "" )
target_include_directories( parse PRIVATE ${LUA_INCLUDE_DIR} )
if(WIN32)
  target_compile_definitions( parse PRIVATE _CRT_SECURE_NO_WARNINGS )
endif()

# Only link against the Lua library on Windows
if(WIN32)
  target_link_libraries( parse ${LUA_LIBRARIES} )
endif()

# Needed to avoid getting undefined references to liblua
if(APPLE)
  set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
endif()

# avoid 'Invalid escape sequence \X' errors from backslashes in the path
FUNCTION(win32_safe_slashes var)
  if(WIN32)
    string(REPLACE "\\" "/" safe "${${var}}")<commit_msg>Minor style fixes in CMakeLists.txt<commit_after>cmake_minimum_required (VERSION 2.6)
project (LuaGumbo C)

set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_C_STANDARD 99)

if(UNIX)
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

# Lua
if(WIN32)
  find_package (Lua REQUIRED)
else()
  # Only the include dir matters on UNIX
  find_package (Lua)
  if(NOT LUA_INCLUDE_DIR)
    message( FATAL_ERROR "Variable `LUA_INCLUDE_DIR' expected to be defined.")
  endif()
endif()

# Gumbo
set(LIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/lib)
set(WINDOWS_LIB_INCLUDE_DIR ${LIB_INCLUDE_DIR}/visualc/include)

set ( LIBGUMBO_SRC
  lib/attribute.c lib/attribute.h lib/char_ref.c lib/char_ref.h
  lib/error.c lib/error.h lib/gumbo.h lib/insertion_mode.h lib/macros.h
  lib/parser.c lib/parser.h lib/replacement.h lib/string_buffer.c
  lib/string_buffer.h lib/string_piece.c lib/svg_attrs.c lib/svg_tags.c
  lib/tag.c lib/tag_lookup.c lib/tag_lookup.h lib/tokenizer.c
  lib/tokenizer.h lib/tokenizer_states.h lib/token_type.h lib/utf8.c
  lib/utf8.h lib/util.c lib/util.h lib/vector.c lib/vector.h
)

include_directories( ${LIB_INCLUDE_DIR} )
if (WIN32)
  include_directories( ${WINDOWS_LIB_INCLUDE_DIR} )
endif()

# Lua-Gumbo
add_library( parse MODULE gumbo/parse.c ${LIBGUMBO_SRC} )
set_target_properties( parse PROPERTIES PREFIX "" )
target_include_directories( parse PRIVATE ${LUA_INCLUDE_DIR} )

if(WIN32)
  target_compile_definitions( parse PRIVATE _CRT_SECURE_NO_WARNINGS )
  # Only link against the Lua library on Windows
  target_link_libraries( parse ${LUA_LIBRARIES} )
endif()

# Needed to avoid getting undefined references to liblua
if(APPLE)
  set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
endif()

# avoid 'Invalid escape sequence \X' errors from backslashes in the path
FUNCTION(win32_safe_slashes var)
  if(WIN32)
    string(REPLACE "\\" "/" safe "${${var}}")
{'fraction_non_alphanumeric': 0.10555264536406496, 'fraction_numerical': 0.00890518596123625, 'mean_word_length': 5.429292929292929, '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': '5580413', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1453, 'n_words': 299}