-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathFindre2.cmake
More file actions
52 lines (46 loc) · 1.26 KB
/
Findre2.cmake
File metadata and controls
52 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
find_package(re2 QUIET CONFIG)
if(re2_FOUND)
message(STATUS "Found RE2 via CMake.")
return()
endif()
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_RE2 QUIET re2)
endif()
if(PC_RE2_FOUND)
set(re2_FOUND true)
add_library(re2::re2 INTERFACE IMPORTED)
if(PC_RE2_INCLUDE_DIRS)
set_property(
TARGET re2::re2 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${PC_RE2_INCLUDE_DIRS}"
)
endif()
if(PC_RE2_CFLAGS_OTHER)
# Filter out the -std flag, which is handled by CMAKE_CXX_STANDARD.
foreach(flag IN LISTS PC_RE2_CFLAGS_OTHER)
if("${flag}" MATCHES "^-std=")
list(REMOVE_ITEM PC_RE2_CFLAGS_OTHER "${flag}")
endif()
endforeach()
set_property(
TARGET re2::re2 PROPERTY
INTERFACE_COMPILE_OPTIONS "${PC_RE2_CFLAGS_OTHER}"
)
endif()
if(PC_RE2_LDFLAGS)
set_property(
TARGET re2::re2 PROPERTY
INTERFACE_LINK_LIBRARIES "${PC_RE2_LDFLAGS}"
)
endif()
message(STATUS "Found RE2 via pkg-config.")
return()
endif()
if(re2_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find RE2.")
endif()