Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload re2 cmakelists to fix cmake/threads detection issue on conda-forge mac builds, and pin C++ dependency versions #1634

Merged
merged 8 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ parameters:
yarn
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))

- bash: yarn --frozen-lockfile
displayName: "Install Deps"
Expand Down
2 changes: 1 addition & 1 deletion cmake/Pybind.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(pybind11-download NONE)
include(ExternalProject)
ExternalProject_Add(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG master
GIT_TAG v2.8.1
SOURCE_DIR "${CMAKE_BINARY_DIR}/pybind11-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/pybind11-build"
CONFIGURE_COMMAND ""
Expand Down
5 changes: 5 additions & 0 deletions cmake/arrow.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.7.2)

project(arrow-download NONE)

# *******************************************************************
# NOTE: this depedency's CMakeLists.txt is overloaded, make sure to
# adjust if you update the tag
# *******************************************************************

include(ExternalProject)
ExternalProject_Add(apachearrow
GIT_REPOSITORY https://github.com/apache/arrow.git
Expand Down
2 changes: 1 addition & 1 deletion cmake/double-conversion.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(double-conversion-download NONE)
include(ExternalProject)
ExternalProject_Add(double-conversion
GIT_REPOSITORY https://github.com/google/double-conversion.git
GIT_TAG master
GIT_TAG v3.1.5
SOURCE_DIR "${CMAKE_BINARY_DIR}/double-conversion-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/double-conversion-build"
CONFIGURE_COMMAND ""
Expand Down
2 changes: 1 addition & 1 deletion cmake/hopscotch.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(hopscotch-download NONE)
include(ExternalProject)
ExternalProject_Add(hopscotch
GIT_REPOSITORY https://github.com/Tessil/hopscotch-map.git
GIT_TAG master
GIT_TAG v2.3.0
SOURCE_DIR "${CMAKE_BINARY_DIR}/hopscotch-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/hopscotch-build"
CONFIGURE_COMMAND ""
Expand Down
2 changes: 1 addition & 1 deletion cmake/ordered-map.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(ordered-map-download NONE)
include(ExternalProject)
ExternalProject_Add(ordered-map
GIT_REPOSITORY https://github.com/Tessil/ordered-map.git
GIT_TAG master
GIT_TAG v1.0.0
SOURCE_DIR "${CMAKE_BINARY_DIR}/ordered-map-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/ordered-map-build"
CONFIGURE_COMMAND ""
Expand Down
4 changes: 2 additions & 2 deletions cmake/rapidjson.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ project(rapidjson-download NONE)
include(ExternalProject)
ExternalProject_Add(rapidjson
GIT_REPOSITORY https://github.com/tencent/rapidjson.git
GIT_TAG master
GIT_TAG v1.1.0
SOURCE_DIR "${CMAKE_BINARY_DIR}/rapidjson-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/rapidjson-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DRAPIDJSON_BUILD_DOC=off -DRAPIDJSON_BUILD_EXAMPLES=off -DRAPIDJSON_BUILD_TESTS=off"
)
7 changes: 6 additions & 1 deletion cmake/re2.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ cmake_minimum_required(VERSION 3.7.2)

project(re2-download NONE)

# *******************************************************************
# NOTE: this depedency's CMakeLists.txt is overloaded, make sure to
# adjust if you update the tag
# *******************************************************************

include(ExternalProject)
ExternalProject_Add(re2
GIT_REPOSITORY https://github.com/google/re2.git
GIT_TAG 2021-09-01
GIT_TAG 2021-11-01
SOURCE_DIR "${CMAKE_BINARY_DIR}/re2-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/re2-build"
CONFIGURE_COMMAND ""
Expand Down
175 changes: 175 additions & 0 deletions cmake/re2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# 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.

# Old enough to support Ubuntu Xenial.
cmake_minimum_required(VERSION 3.5.1)

project(RE2 CXX)
include(CTest)
include(GNUInstallDirs)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

option(BUILD_SHARED_LIBS "build shared libraries" OFF)
option(USEPCRE "use PCRE in tests and benchmarks" OFF)

# CMake seems to have no way to enable/disable testing per subproject,
# so we provide an option similar to BUILD_TESTING, but just for RE2.
option(RE2_BUILD_TESTING "enable testing for RE2" ON)

# ABI version
# http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
set(SONAME 9)

set(EXTRA_TARGET_LINK_LIBRARIES)

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(MSVC_VERSION LESS 1900)
message(FATAL_ERROR "you need Visual Studio 2015 or later")
endif()
if(BUILD_SHARED_LIBS)
# See http://www.kitware.com/blog/home/post/939 for details.
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
# CMake defaults to /W3, but some users like /W4 (or /Wall) and /WX,
# so we disable various warnings that aren't particularly helpful.
add_compile_options(/wd4100 /wd4201 /wd4456 /wd4457 /wd4702 /wd4815)
# Without a byte order mark (BOM), Visual Studio assumes that the source
# file is encoded using the current user code page, so we specify UTF-8.
add_compile_options(/utf-8)
endif()

if(WIN32)
add_definitions(-DUNICODE -D_UNICODE -DSTRICT -DNOMINMAX)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
# ************************************
# TKP NOTE: THIS SECTION IS CUSTOM
# ************************************
elseif(APPLE)
# assume built-in pthreads on MacOS
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# ************************************
elseif(UNIX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
endif()

if(USEPCRE)
add_definitions(-DUSEPCRE)
list(APPEND EXTRA_TARGET_LINK_LIBRARIES pcre)
endif()

set(RE2_SOURCES
re2/bitstate.cc
re2/compile.cc
re2/dfa.cc
re2/filtered_re2.cc
re2/mimics_pcre.cc
re2/nfa.cc
re2/onepass.cc
re2/parse.cc
re2/perl_groups.cc
re2/prefilter.cc
re2/prefilter_tree.cc
re2/prog.cc
re2/re2.cc
re2/regexp.cc
re2/set.cc
re2/simplify.cc
re2/stringpiece.cc
re2/tostring.cc
re2/unicode_casefold.cc
re2/unicode_groups.cc
util/rune.cc
util/strutil.cc
)

add_library(re2 ${RE2_SOURCES})
target_include_directories(re2 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
set_target_properties(re2 PROPERTIES SOVERSION ${SONAME} VERSION ${SONAME}.0.0)
add_library(re2::re2 ALIAS re2)

if(UNIX)
target_link_libraries(re2 PUBLIC Threads::Threads)
endif()

if(RE2_BUILD_TESTING)
set(TESTING_SOURCES
re2/testing/backtrack.cc
re2/testing/dump.cc
re2/testing/exhaustive_tester.cc
re2/testing/null_walker.cc
re2/testing/regexp_generator.cc
re2/testing/string_generator.cc
re2/testing/tester.cc
util/pcre.cc
)

add_library(testing STATIC ${TESTING_SOURCES})
target_link_libraries(testing PUBLIC re2)

set(TEST_TARGETS
charclass_test
compile_test
filtered_re2_test
mimics_pcre_test
parse_test
possible_match_test
re2_test
re2_arg_test
regexp_test
required_prefix_test
search_test
set_test
simplify_test
string_generator_test

dfa_test
exhaustive1_test
exhaustive2_test
exhaustive3_test
exhaustive_test
random_test
)

set(BENCHMARK_TARGETS
regexp_benchmark
)

foreach(target ${TEST_TARGETS})
add_executable(${target} re2/testing/${target}.cc util/test.cc)
target_link_libraries(${target} testing ${EXTRA_TARGET_LINK_LIBRARIES})
add_test(NAME ${target} COMMAND ${target})
endforeach()

foreach(target ${BENCHMARK_TARGETS})
add_executable(${target} re2/testing/${target}.cc util/benchmark.cc)
target_link_libraries(${target} testing ${EXTRA_TARGET_LINK_LIBRARIES})
endforeach()
endif()

set(RE2_HEADERS
re2/filtered_re2.h
re2/re2.h
re2/set.h
re2/stringpiece.h
)

install(FILES ${RE2_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/re2)
install(TARGETS re2 EXPORT re2Config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT re2Config
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/re2 NAMESPACE re2::)
Loading