<commit_before># Copyright(C) 2012-2013 Brazil
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

cmake_minimum_required(VERSION 2.6.4)
set(GRN_PROJECT_NAME "groonga")
project("${GRN_PROJECT_NAME}")

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/base_version" VERSION)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/version.sh")
  file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.sh" GRN_VERSION)
else()
  if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/version.sh")
    if(WIN32)
      set(GRN_VERSION "${VERSION}")
    else()
      execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/version-gen.sh")
      file(READ "${CMAKE_CURRENT_BINARY_DIR}/version.sh" GRN_VERSION)
    endif()
  endif()
endif()
string(REGEX REPLACE "(^.*=|\n)" "" GRN_VERSION "${GRN_VERSION}")

include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(FindPkgConfig)
include(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake)

set(BIN_DIR "bin")
set(SBIN_DIR "sbin")
set(LIB_DIR "lib")
set(INCLUDE_DIR "include")
set(GRN_INCLUDE_DIR "include/groonga")
set(DATA_DIR "share")
set(GRN_DATA_DIR "${DATA_DIR}/${GRN_PROJECT_NAME}")
set(CONFIG_DIR "etc")
set(GRN_CONFIG_DIR "${CONFIG_DIR}/${GRN_PROJECT_NAME}")

set(GRN_LOG_PATH
  "${CMAKE_INSTALL_PREFIX}/var/log/${GRN_PROJECT_NAME}/${GRN_PROJECT_NAME}.log"
  CACHE FILEPATH "log file path")
set(GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD
  0
  CACHE STRING "groonga default match escalation threshold")
set(GRN_DEFAULT_DOCUMENT_ROOT_BASE
  "html/admin"
  CACHE PATH "groonga default document root base path")
set(GRN_DEFAULT_RELATIVE_DOCUMENT_ROOT
  "share/${GRN_PROJECT_NAME}/${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
  CACHE PATH "groonga default relative document root")
set(GRN_DEFAULT_DOCUMENT_ROOT
  "${CMAKE_INSTALL_PREFIX}/${GRN_DATA_DIR}/${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
  CACHE PATH "groonga default document root")
set(GRN_STACK_SIZE
  1024
  CACHE STRING
  "DANGER!!! groonga stack size. Normarlly, you should not change this variable.")
set(GRN_JA_SEGREGATE_THRESHOLD
  7
  CACHE STRING
  "DANGER!!! This option breaks database compatibility.
   You can't use the same database with different
   GRN_JA_SEGREGATE_THRESHOLD Groongas.
   This option changes data management threshold for variable size columns
   such as ShortText type column and COLUMN_VECTOR column.
   (default=7)

   If you don't delete/update variable size column values, you don't need to
   change it. If you delete/update variable size column values with
   [128, 65535] size data, GRN_JA_SEGREGATE_THRESHOLD=16 will better
   database size.
   In the case, your database size will be increased unlimitedly with
   the default GRN_JA_SEGREGATE_THRESHOLD (= 7).
   Your database size will not be increased unlimitedly with
   GRN_JA_SEGREGATE_THRESHOLD=16.")
set(GRN_LOCK_TIMEOUT
  10000000
  CACHE STRING
  "timeout to acquire a lock.")
set(GRN_LOCK_WAIT_TIME_NANOSECOND
  1000000
  CACHE STRING
  "wait time in nanosecond to acquire a lock.")
set(GRN_RELATIVE_PLUGINS_DIR
  "${LIB_DIR}/${GRN_PROJECT_NAME}/plugins")
set(GRN_PLUGINS_DIR
  "${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_PLUGINS_DIR}")
set(GRN_PLUGIN_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}")
set(GRN_DLL_FILENAME
  "${CMAKE_SHARED_LIBRARY_PREFIX}groonga${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE "synonyms.tsv")
set(GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE
  "${CMAKE_INSTALL_PREFIX}/${GRN_DATA_DIR}/${GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE}")
set(GRN_RELATIVE_RUBY_SCRIPTS_DIR
  "${LIB_DIR}/${GRN_PROJECT_NAME}/scripts/ruby")
set(GRN_RUBY_SCRIPTS_DIR
  "${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_RUBY_SCRIPTS_DIR}")

macro(check_cflag flag)
  set(checking_message "checking for C flag '${flag}' -")
  check_c_compiler_flag(${flag} is_available)
  if(${is_available})
    message(STATUS "${checking_message} available")
    set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} ${flag}")
  else()
    message(STATUS "${checking_message} not available")
  endif()
endmacro()

macro(check_cxxflag flag)
  set(checking_message "checking for CXX flag '${flag}' - ")
  check_cxx_compiler_flag(${flag} is_available)
  if(${is_available})
    message(STATUS "${checking_message} available")
    set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} ${flag}")
  else()
    message(STATUS "${checking_message} not available")
  endif()
endmacro()

macro(check_build_flag flag)
  check_cflag(${flag})
  check_cxxflag(${flag})
endmacro()

if(CMAKE_COMPILER_IS_GNUCXX)
  check_build_flag("-Wall")
  check_build_flag("-Wextra")
  check_build_flag("-Wno-unused-but-set-variable")
  check_build_flag("-Wno-unused-parameter")
  check_build_flag("-Wno-sign-compare")
  check_cflag("-Wno-pointer-sign")
  check_build_flag("-Wno-missing-field-initializers")
  check_build_flag("-Wformat=2")
  check_build_flag("-Wstrict-aliasing=2")
  check_build_flag("-fno-strict-aliasing")
  check_build_flag("-Wdisabled-optimization")
  check_build_flag("-Wfloat-equal")
  check_build_flag("-Wpointer-arith")
  check_cflag("-Wdeclaration-after-statement")
  check_cflag("-Wbad-function-cast")
  check_build_flag("-Wcast-align")
  check_build_flag("-Wredundant-decls")
  check_build_flag("-Wwrite-strings")<commit_msg>cmake: remove needless spaces<commit_after># Copyright(C) 2012-2013 Brazil
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

cmake_minimum_required(VERSION 2.6.4)
set(GRN_PROJECT_NAME "groonga")
project("${GRN_PROJECT_NAME}")

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/base_version" VERSION)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/version.sh")
  file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.sh" GRN_VERSION)
else()
  if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/version.sh")
    if(WIN32)
      set(GRN_VERSION "${VERSION}")
    else()
      execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/version-gen.sh")
      file(READ "${CMAKE_CURRENT_BINARY_DIR}/version.sh" GRN_VERSION)
    endif()
  endif()
endif()
string(REGEX REPLACE "(^.*=|\n)" "" GRN_VERSION "${GRN_VERSION}")

include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(FindPkgConfig)
include(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake)

set(BIN_DIR "bin")
set(SBIN_DIR "sbin")
set(LIB_DIR "lib")
set(INCLUDE_DIR "include")
set(GRN_INCLUDE_DIR "include/groonga")
set(DATA_DIR "share")
set(GRN_DATA_DIR "${DATA_DIR}/${GRN_PROJECT_NAME}")
set(CONFIG_DIR "etc")
set(GRN_CONFIG_DIR "${CONFIG_DIR}/${GRN_PROJECT_NAME}")

set(GRN_LOG_PATH
  "${CMAKE_INSTALL_PREFIX}/var/log/${GRN_PROJECT_NAME}/${GRN_PROJECT_NAME}.log"
  CACHE FILEPATH "log file path")
set(GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD
  0
  CACHE STRING "groonga default match escalation threshold")
set(GRN_DEFAULT_DOCUMENT_ROOT_BASE
  "html/admin"
  CACHE PATH "groonga default document root base path")
set(GRN_DEFAULT_RELATIVE_DOCUMENT_ROOT
  "share/${GRN_PROJECT_NAME}/${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
  CACHE PATH "groonga default relative document root")
set(GRN_DEFAULT_DOCUMENT_ROOT
  "${CMAKE_INSTALL_PREFIX}/${GRN_DATA_DIR}/${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
  CACHE PATH "groonga default document root")
set(GRN_STACK_SIZE
  1024
  CACHE STRING
  "DANGER!!! groonga stack size. Normarlly, you should not change this variable.")
set(GRN_JA_SEGREGATE_THRESHOLD
  7
  CACHE STRING
  "DANGER!!! This option breaks database compatibility.
   You can't use the same database with different
   GRN_JA_SEGREGATE_THRESHOLD Groongas.
   This option changes data management threshold for variable size columns
   such as ShortText type column and COLUMN_VECTOR column.
   (default=7)

   If you don't delete/update variable size column values, you don't need to
   change it. If you delete/update variable size column values with
   [128, 65535] size data, GRN_JA_SEGREGATE_THRESHOLD=16 will better
   database size.
   In the case, your database size will be increased unlimitedly with
   the default GRN_JA_SEGREGATE_THRESHOLD (= 7).
   Your database size will not be increased unlimitedly with
   GRN_JA_SEGREGATE_THRESHOLD=16.")
set(GRN_LOCK_TIMEOUT
  10000000
  CACHE STRING
  "timeout to acquire a lock.")
set(GRN_LOCK_WAIT_TIME_NANOSECOND
  1000000
  CACHE STRING
  "wait time in nanosecond to acquire a lock.")
set(GRN_RELATIVE_PLUGINS_DIR
  "${LIB_DIR}/${GRN_PROJECT_NAME}/plugins")
set(GRN_PLUGINS_DIR
  "${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_PLUGINS_DIR}")
set(GRN_PLUGIN_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}")
set(GRN_DLL_FILENAME
  "${CMAKE_SHARED_LIBRARY_PREFIX}groonga${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE "synonyms.tsv")
set(GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE
  "${CMAKE_INSTALL_PREFIX}/${GRN_DATA_DIR}/${GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE}")
set(GRN_RELATIVE_RUBY_SCRIPTS_DIR
  "${LIB_DIR}/${GRN_PROJECT_NAME}/scripts/ruby")
set(GRN_RUBY_SCRIPTS_DIR
  "${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_RUBY_SCRIPTS_DIR}")

macro(check_cflag flag)
  set(checking_message "checking for C flag '${flag}")
  check_c_compiler_flag(${flag} is_available)
  if(${is_available})
    message(STATUS "${checking_message} - available")
    set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} ${flag}")
  else()
    message(STATUS "${checking_message} - not available")
  endif()
endmacro()

macro(check_cxxflag flag)
  set(checking_message "checking for CXX flag '${flag}'")
  check_cxx_compiler_flag(${flag} is_available)
  if(${is_available})
    message(STATUS "${checking_message} - available")
    set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} ${flag}")
  else()
    message(STATUS "${checking_message} - not available")
  endif()
endmacro()

macro(check_build_flag flag)
  check_cflag(${flag})
  check_cxxflag(${flag})
endmacro()

if(CMAKE_COMPILER_IS_GNUCXX)
  check_build_flag("-Wall")
  check_build_flag("-Wextra")
  check_build_flag("-Wno-unused-but-set-variable")
  check_build_flag("-Wno-unused-parameter")
  check_build_flag("-Wno-sign-compare")
  check_cflag("-Wno-pointer-sign")
  check_build_flag("-Wno-missing-field-initializers")
  check_build_flag("-Wformat=2")
  check_build_flag("-Wstrict-aliasing=2")
  check_build_flag("-fno-strict-aliasing")
  check_build_flag("-Wdisabled-optimization")
  check_build_flag("-Wfloat-equal")
  check_build_flag("-Wpointer-arith")
  check_cflag("-Wdeclaration-after-statement")
  check_cflag("-Wbad-function-cast")
  check_build_flag("-Wcast-align")
  check_build_flag("-Wredundant-decls")
  check_build_flag("-Wwrite-strings")
{'fraction_non_alphanumeric': 0.11114887831407207, 'fraction_numerical': 0.01070700203942896, 'mean_word_length': 6.46290424857324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6089881', 'n_tokens_mistral': 4368, 'n_tokens_neox': 4218, 'n_words': 862}