infra icon indicating copy to clipboard operation
infra copied to clipboard

Add google RE2

Open jmarrec opened this issue 8 months ago • 2 comments

It depends on abseil, not sure if this is going to work as is.

  • Companion PR: https://github.com/compiler-explorer/compiler-explorer/pull/7594

jmarrec avatar Apr 22 '25 20:04 jmarrec

Thanks for the PR! I will take a look at this next week probably

partouf avatar Apr 22 '25 20:04 partouf

Locally I checked out abseil-cpp and re2 into a google subdirectory.

I build abseil-cpp.

cmake -G Ninja -DCMAKE_BUILD_TYPE:String=Release -DBUILD_TESTING:BOOL=OFF \
      -DCMAKE_INSTALL_PREFIX=$(pwd)/install ..
ninja install

I build re2.

cmake -G Ninja -DCMAKE_BUILD_TYPE:String=Release -DBUILD_TESTING:BOOL=OFF \
      -DCMAKE_INSTALL_PREFIX=$(pwd)/install \
      -Dabsl_DIR=$HOME/google/abseil-cpp/build/install/lib/cmake/absl/ ..
ninja install

Test program

#include <re2/re2.h>
#include <cassert>

int main() {
  assert(RE2::FullMatch("hello", "h.*o"));
}

A CMakeLists.txt if needed:

cmake_minimum_required(VERSION 3.31)

project(test)

find_package(re2 REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE re2::re2)

I build it via

cmake -G Ninja -DCMAKE_BUILD_TYPE:String=Release -DBUILD_TESTING:BOOL=OFF \
      -DCMAKE_INSTALL_PREFIX=$(pwd)/install \
      -Dabsl_DIR=$HOME/google/abseil-cpp/build/install/lib/cmake/absl/ \
      -Dre2_DIR=$HOME/google/re2/build/install/lib/cmake/re ..

jmarrec avatar Apr 22 '25 22:04 jmarrec

Sorry for the delay, im putting this on my todo list for next week

partouf avatar Jul 22 '25 23:07 partouf