<commit_before>set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

FUNCTION(CHECK_OQGRAPH)
MESSAGE(STATUS "Configuring OQGraph")
FIND_PACKAGE(Boost 1.40.0)
IF(NOT Boost_FOUND)
  MESSAGE(STATUS "Boost not found. OQGraph will not be compiled")
  SET(OQGRAPH_OK 0 CACHE INTERNAL "")
  RETURN()
ENDIF()
INCLUDE_DIRECTORIES(BEFORE ${Boost_INCLUDE_DIRS})

FIND_PACKAGE(Judy)
IF(NOT Judy_FOUND)
  MESSAGE(STATUS "Judy not found. OQGraph will not be compiled")
  SET(OQGRAPH_OK 0 CACHE INTERNAL "")
  RETURN()
ENDIF()
INCLUDE_DIRECTORIES(${Judy_INCLUDE_DIR})

IF(MSVC)
#  # lp:756966 OQGRAPH on Win64 does not compile
#  IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
#    SET(OQGRAPH_OK 0 CACHE INTERNAL "")
#  ELSE()
    SET(OQGRAPH_OK 1 CACHE INTERNAL "")
#  ENDIF()
ELSE()
# See if that works. On old gcc it'll fail because of -fno-rtti
SET(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
CHECK_CXX_SOURCE_COMPILES(
"
#define BOOST_NO_RTTI 1
#define BOOST_NO_TYPEID 1
#include <boost/config.hpp>
#include <boost/property_map/property_map.hpp>
int main() { return 0; }
" OQGRAPH_OK)
ENDIF()

IF(OQGRAPH_OK)
  ADD_DEFINITIONS(-DHAVE_OQGRAPH)
  IF(MSVC)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" PARENT_SCOPE)
    # Fix problem with judy not finding inttypes.h on Windows:
    ADD_DEFINITIONS(-DJU_WIN)
  ELSE(MSVC)
    # Fix lp bug 1221555 with -fpermissive, so that errors in gcc 4.7 become warnings for the time being
    STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
    STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive" PARENT_SCOPE)
  ENDIF(MSVC)

  ADD_DEFINITIONS(-DBOOST_NO_RTTI=1 -DBOOST_NO_TYPEID=1 -DBOOST_DISABLE_ASSERTS=1)
  MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc
                   oqgraph_shim.cc oqgraph_thunk.cc oqgraph_judy.cc
                   STORAGE_ENGINE
                   MODULE_ONLY
                   RECOMPILE_FOR_EMBEDDED
                   COMPONENT oqgraph-engine
                   LINK_LIBRARIES ${Judy_LIBRARIES})
ELSE(OQGRAPH_OK)
  MESSAGE(STATUS "Requisites for OQGraph not met. OQGraph will not be compiled")
ENDIF(OQGRAPH_OK)
ENDFUNCTION()

IF(NOT DEFINED OQGRAPH_OK)
  CHECK_OQGRAPH()
ENDIF()
<commit_msg>Move MYSQL_ADD_PLUGIN outside of IF(OQGRAPH_OK) condition, otherwise the plugin does not get compiled if cmake is called multiple times.<commit_after>set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

FUNCTION(CHECK_OQGRAPH)
MESSAGE(STATUS "Configuring OQGraph")
FIND_PACKAGE(Boost 1.40.0)
IF(NOT Boost_FOUND)
  MESSAGE(STATUS "Boost not found. OQGraph will not be compiled")
  SET(OQGRAPH_OK 0 CACHE INTERNAL "")
  RETURN()
ENDIF()
INCLUDE_DIRECTORIES(BEFORE ${Boost_INCLUDE_DIRS})

FIND_PACKAGE(Judy)
IF(NOT Judy_FOUND)
  MESSAGE(STATUS "Judy not found. OQGraph will not be compiled")
  SET(OQGRAPH_OK 0 CACHE INTERNAL "")
  RETURN()
ENDIF()
INCLUDE_DIRECTORIES(${Judy_INCLUDE_DIR})

IF(MSVC)
#  # lp:756966 OQGRAPH on Win64 does not compile
#  IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
#    SET(OQGRAPH_OK 0 CACHE INTERNAL "")
#  ELSE()
    SET(OQGRAPH_OK 1 CACHE INTERNAL "")
#  ENDIF()
ELSE()
# See if that works. On old gcc it'll fail because of -fno-rtti
SET(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
CHECK_CXX_SOURCE_COMPILES(
"
#define BOOST_NO_RTTI 1
#define BOOST_NO_TYPEID 1
#include <boost/config.hpp>
#include <boost/property_map/property_map.hpp>
int main() { return 0; }
" OQGRAPH_OK)
ENDIF()
ENDFUNCTION()

IF(NOT DEFINED OQGRAPH_OK)
  CHECK_OQGRAPH()
  IF (NOT OQGRAPH_OK)
    MESSAGE(STATUS "Requisites for OQGraph not met. OQGraph will not be compiled")
  ENDIF()
ENDIF()

IF(NOT OQGRAPH_OK)
  RETURN()
ENDIF()

ADD_DEFINITIONS(-DHAVE_OQGRAPH)
IF(MSVC)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
  # Fix problem with judy not finding inttypes.h on Windows:
  ADD_DEFINITIONS(-DJU_WIN)
ELSE(MSVC)
  # Fix lp bug 1221555 with -fpermissive, so that errors in gcc 4.7 become warnings for the time being
  STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive" PARENT_SCOPE)
ENDIF(MSVC)

ADD_DEFINITIONS(-DBOOST_NO_RTTI=1 -DBOOST_NO_TYPEID=1 -DBOOST_DISABLE_ASSERTS=1)
MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc
                 oqgraph_shim.cc oqgraph_thunk.cc oqgraph_judy.cc
                 STORAGE_ENGINE
                 MODULE_ONLY
                 RECOMPILE_FOR_EMBEDDED
                 COMPONENT oqgraph-engine
                 LINK_LIBRARIES ${Judy_LIBRARIES})

{'fraction_non_alphanumeric': 0.09732462607962925, 'fraction_numerical': 0.013482199283758163, 'mean_word_length': 4.489017341040462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1857981', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1836, 'n_words': 396}