2021-11-21 15:27:33 +00:00
|
|
|
# Copyright 2015 The RE2 Authors. All Rights Reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# This file was edited for ClickHouse
|
|
|
|
|
2022-01-17 18:45:54 +00:00
|
|
|
string(FIND ${CMAKE_CURRENT_BINARY_DIR} " " _have_space)
|
|
|
|
if(_have_space GREATER 0)
|
|
|
|
message(FATAL_ERROR "Using spaces in build path [${CMAKE_CURRENT_BINARY_DIR}] highly not recommended. Library re2st will be disabled.")
|
|
|
|
endif()
|
|
|
|
|
2021-11-21 15:27:33 +00:00
|
|
|
set(SRC_DIR "${ClickHouse_SOURCE_DIR}/contrib/re2")
|
|
|
|
|
|
|
|
set(RE2_SOURCES
|
2023-06-22 16:31:01 +00:00
|
|
|
${SRC_DIR}/re2/bitmap256.cc
|
2021-11-21 15:27:33 +00:00
|
|
|
${SRC_DIR}/re2/bitstate.cc
|
|
|
|
${SRC_DIR}/re2/compile.cc
|
|
|
|
${SRC_DIR}/re2/dfa.cc
|
|
|
|
${SRC_DIR}/re2/filtered_re2.cc
|
|
|
|
${SRC_DIR}/re2/mimics_pcre.cc
|
|
|
|
${SRC_DIR}/re2/nfa.cc
|
|
|
|
${SRC_DIR}/re2/onepass.cc
|
|
|
|
${SRC_DIR}/re2/parse.cc
|
|
|
|
${SRC_DIR}/re2/perl_groups.cc
|
|
|
|
${SRC_DIR}/re2/prefilter.cc
|
|
|
|
${SRC_DIR}/re2/prefilter_tree.cc
|
|
|
|
${SRC_DIR}/re2/prog.cc
|
|
|
|
${SRC_DIR}/re2/re2.cc
|
|
|
|
${SRC_DIR}/re2/regexp.cc
|
|
|
|
${SRC_DIR}/re2/set.cc
|
|
|
|
${SRC_DIR}/re2/simplify.cc
|
|
|
|
${SRC_DIR}/re2/tostring.cc
|
|
|
|
${SRC_DIR}/re2/unicode_casefold.cc
|
|
|
|
${SRC_DIR}/re2/unicode_groups.cc
|
2023-06-22 16:31:01 +00:00
|
|
|
${SRC_DIR}/util/pcre.cc
|
2021-11-21 15:27:33 +00:00
|
|
|
${SRC_DIR}/util/rune.cc
|
|
|
|
${SRC_DIR}/util/strutil.cc
|
|
|
|
)
|
|
|
|
add_library(re2 ${RE2_SOURCES})
|
|
|
|
target_include_directories(re2 PUBLIC "${SRC_DIR}")
|
2023-06-22 16:31:01 +00:00
|
|
|
target_link_libraries(re2 ch_contrib::abseil_str_format)
|
2021-11-21 15:27:33 +00:00
|
|
|
|
2016-12-01 22:44:59 +00:00
|
|
|
# Building re2 which is thread-safe and re2_st which is not.
|
|
|
|
# re2 changes its state during matching of regular expression, e.g. creates temporary DFA.
|
|
|
|
# It uses RWLock to process the same regular expression object from different threads.
|
|
|
|
# In order to avoid redundant locks in some cases, we use not thread-safe version of the library (re2_st).
|
2017-01-16 19:47:11 +00:00
|
|
|
|
2021-11-21 15:27:33 +00:00
|
|
|
add_library(re2_st ${RE2_SOURCES})
|
2018-01-22 13:47:00 +00:00
|
|
|
target_compile_definitions (re2_st PRIVATE NDEBUG NO_THREADS re2=re2_st)
|
2018-08-10 02:24:10 +00:00
|
|
|
target_include_directories (re2_st PRIVATE .)
|
2022-01-17 18:45:54 +00:00
|
|
|
target_include_directories (re2_st SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_include_directories (re2_st SYSTEM BEFORE PUBLIC ${SRC_DIR})
|
2023-06-22 16:31:01 +00:00
|
|
|
target_link_libraries (re2_st ch_contrib::abseil_str_format)
|
2017-08-09 20:52:55 +00:00
|
|
|
|
2016-11-02 09:29:39 +00:00
|
|
|
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/re2_st)
|
2018-01-22 13:47:00 +00:00
|
|
|
foreach (FILENAME filtered_re2.h re2.h set.h stringpiece.h)
|
2018-07-30 18:11:31 +00:00
|
|
|
add_custom_command (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/re2_st/${FILENAME}"
|
2021-11-21 15:27:33 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -DSOURCE_FILENAME="${SRC_DIR}/re2/${FILENAME}"
|
2018-07-30 18:11:31 +00:00
|
|
|
-DTARGET_FILENAME="${CMAKE_CURRENT_BINARY_DIR}/re2_st/${FILENAME}"
|
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/re2_transform.cmake"
|
|
|
|
COMMENT "Creating ${FILENAME} for re2_st library.")
|
|
|
|
add_custom_target (transform_${FILENAME} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/re2_st/${FILENAME}")
|
|
|
|
add_dependencies (re2_st transform_${FILENAME})
|
2016-11-02 09:29:39 +00:00
|
|
|
endforeach ()
|
2018-02-12 02:41:50 +00:00
|
|
|
|
2022-02-17 11:59:47 +00:00
|
|
|
# NOTE: you should not change name of library here, since it is used to generate required header (see above)
|
2022-01-17 18:45:54 +00:00
|
|
|
add_library(ch_contrib::re2 ALIAS re2)
|
|
|
|
add_library(ch_contrib::re2_st ALIAS re2_st)
|