re2/20220601¶
Using the re2 Conan Package¶
Conan integrates with different build systems. You can declare which build system you want your project to use setting in the [generators] section of the conanfile.txt or using the generators attribute in the conanfile.py. Here, there is some basic information you can use to integrate re2 in your own project. For more detailed information, please check the Conan documentation.
Using re2 with CMake¶
Conan CMake generators¶
-
CMakeDeps: generates information about where the re2 library and its dependencies are installed together with other information like version, flags, and directory data or configuration. CMake will use this files when you invoke
find_package()in your CMakeLists.txt. -
CMakeToolchain: generates a CMake toolchain file that you can later invoke with CMake in the command line using
-DCMAKE_TOOLCHAIN_FILE=conantoolchain.cmake.
Declare these generators in your conanfile.txt along with your re2 dependency like:
[requires]
re2/20220601
[generators]
CMakeDeps
CMakeToolchain
To use re2 in a simple CMake project with this structure:
.
|-- CMakeLists.txt
|-- conanfile.txt
`-- src
`-- main..cpp
Your CMakeLists.txt could look similar to this, using the global re2::re2 CMake's target:
cmake_minimum_required(VERSION 3.15)
project(re2_project CXX)
find_package(re2)
add_executable(${PROJECT_NAME} src/main.cpp)
# Use the global target
target_link_libraries(${PROJECT_NAME} re2::re2)
To install re2/20220601, its dependencies and build your project, you just have to do:
# for Linux/macOS
$ conan install . --install-folder cmake-build-release --build=missing
$ cmake . -DCMAKE_TOOLCHAIN_FILE=cmake-build-release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
$ cmake --build .
# for Windows and Visual Studio 2017
$ conan install . --output-folder cmake-build --build=missing
$ cmake . -G "Visual Studio 15 2017" -DCMAKE_TOOLCHAIN_FILE=cmake-build/conan_toolchain.cmake
$ cmake --build . --config Release
Using re2 with Visual Studio¶
Visual Studio Conan generators¶
-
MSBuildDeps: generates the conandeps.props properties file with information about where the re2 library and its dependencies are installed together with other information like version, flags, and directory data or configuration.
-
MSBuildToolchain: Generates the conantoolchain.props properties file with the current package configuration, settings, and options.
Declare these generators in your conanfile.txt along with your re2 dependency like:
[requires]
re2/20220601
[generators]
MSBuildDeps
MSBuildToolchain
Please, check the Conan documentation for more detailed information on how to add these properties files to your Visual Studio projects.
Using re2 with Autotools and pkg-config¶
Autotools Conan generators¶
-
AutotoolsToolchain: generates the conanautotoolstoolchain.sh/bat script translating information from the current package configuration, settings, and options setting some enviroment variables for Autotools like:
CPPFLAGS,CXXFLAGS,CFLAGSandLDFLAGS. It will also generate adeactivate_conanautotoolstoolchain.sh/batso you can restore your environment. -
AutotoolsDeps: generates the conanautotoolsdeps.sh/bat script with information about where the re2 library and its dependencies are installed together with other information like version, flags, and directory data or configuration. This is done setting some enviroment variables for Autotools like:
LIBS,CPPFLAGS,CXXFLAGS,CFLAGSandLDFLAGS. It will also generate adeactivate_conanautotoolsdeps.sh/batso you can restore your environment.
Declare these generators in your conanfile.txt along with your re2 dependency like:
[requires]
re2/20220601
[generators]
AutotoolsToolchain
AutotoolsDeps
Then, building your project is as easy as:
$ conan install .
# set the environment variables for Autotools
$ source conanautotoolstoolchain.sh
$ source conanautotoolsdeps.sh
$ ./configure
$ make
# restore the environment after the build is completed
$ source deactivate_conanautotoolstoolchain.sh
$ source deactivate_conanautotoolsdeps.sh
pkg-config Conan generator¶
- PkgConfigDeps: generates the re2.pc file (and the ones corresponding to re2 dependencies) with information about the dependencies that can be later used by the pkg-config tool pkg-config to collect data about the libraries Conan installed.
You can use this generator instead of the AutotoolsDeps one:
[requires]
re2/20220601
[generators]
AutotoolsToolchain
PkgConfigDeps
And then using pkg-config to set the environment variables you want, like:
$ conan install .
# set the environment variables for Autotools
$ source conanautotoolstoolchain.sh
$ export CPPFLAGS="$CPPFLAGS $(pkg-config --cflags re2)"
$ export LIBS="$LIBS $(pkg-config --libs-only-l re2)"
$ export LDFLAGS="$LDFLAGS $(pkg-config --libs-only-L --libs-only-other re2)"
$ ./configure
$ make
# restore the environment after the build is completed
$ source deactivate_conanautotoolstoolchain.sh
Other build systems¶
Please, check the Conan documentation for other integrations besides the ones listed in this document.
Exposed header files for re2¶
#include <re2/filtered_re2.h>
#include <re2/set.h>
#include <re2/stringpiece.h>
#include <re2/re2.h>
---¶
Conan 1.58.0. JFrog LTD. https://conan.io. Autogenerated 2023-02-05 17:37:10.