Skip to content

Commit 503386b

Browse files
John DoeKondachello
authored andcommitted
DOWNLOAD_DEPENDENCIES flag change
re2 fetch not ifed reorder for gtest reorder for re2 reorder for re2 revert changes fetchcontent patch Delete CHANGES.md formatting fix formatting x2 fetch content fix
1 parent 30c1061 commit 503386b

File tree

5 files changed

+277
-292
lines changed

5 files changed

+277
-292
lines changed

CHANGES.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

cmake/BuildDependencies.cmake

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,88 @@ cmake_minimum_required(VERSION 3.19)
1616

1717
include(FetchContent)
1818

19-
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
20-
set(absl_URL https://github.com/abseil/abseil-cpp.git)
21-
set(absl_TAG d04b964d82ed5146f7e5e34701a5ba69f9514c9a)
22-
23-
set(re2_URL https://github.com/google/re2.git)
24-
set(re2_TAG 2024-07-02)
25-
26-
set(gtest_URL https://github.com/google/googletest.git)
27-
set(gtest_TAG v1.16.0)
19+
set(absl_URL https://github.com/abseil/abseil-cpp.git)
20+
set(absl_TAG d04b964d82ed5146f7e5e34701a5ba69f9514c9a)
2821

29-
set(proto_URL https://github.com/protocolbuffers/protobuf.git)
30-
set(proto_TAG v30.2)
22+
set(re2_URL https://github.com/google/re2.git)
23+
set(re2_TAG 2024-07-02)
3124

32-
set(nlohmann_json_URL https://github.com/nlohmann/json.git)
33-
set(nlohmann_json_TAG v3.11.3)
34-
35-
set(flatbuffers_URL https://github.com/google/flatbuffers.git)
36-
set(flatbuffers_TAG v25.2.10)
37-
endif()
25+
set(gtest_URL https://github.com/google/googletest.git)
26+
set(gtest_TAG v1.16.0)
3827

3928
# From https://www.antlr.org/download.html
4029
set(antlr_cpp_URL https://www.antlr.org/download/antlr4-cpp-runtime-4.12.0-source.zip)
4130
set(antlr_cpp_MD5 acf7371bd7562188712751266d8a7b90)
4231

32+
set(proto_URL https://github.com/protocolbuffers/protobuf.git)
33+
set(proto_TAG v30.2)
34+
35+
set(nlohmann_json_URL https://github.com/nlohmann/json.git)
36+
set(nlohmann_json_TAG v3.11.3)
37+
38+
set(flatbuffers_URL https://github.com/google/flatbuffers.git)
39+
set(flatbuffers_TAG v25.2.10)
40+
4341
if(POLICY CMP0135)
44-
cmake_policy(SET CMP0135 NEW)
45-
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
42+
cmake_policy(SET CMP0135 NEW)
43+
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
4644
endif()
4745

4846
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
4947
FetchContent_Declare(
50-
abseil-cpp
51-
GIT_REPOSITORY ${absl_URL}
52-
GIT_TAG ${absl_TAG}
48+
abseil-cpp
49+
GIT_REPOSITORY ${absl_URL}
50+
GIT_TAG ${absl_TAG}
5351
)
52+
else()
53+
find_package(absl QUIET)
54+
if(NOT absl_FOUND)
55+
message(WARNING "FUZZTEST_DOWNLOAD_DEPENDENCIES=OFF and absl not found via find_package.\n")
56+
endif()
57+
endif()
5458

59+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
5560
FetchContent_Declare(
56-
re2
57-
GIT_REPOSITORY ${re2_URL}
58-
GIT_TAG ${re2_TAG}
61+
re2
62+
GIT_REPOSITORY ${re2_URL}
63+
GIT_TAG ${re2_TAG}
5964
)
65+
else()
66+
if(DEFINED RE2_SOURCE_DIR)
67+
message(STATUS "FUZZTEST_DOWNLOAD_DEPENDENCIES=OFF: using local re2 source at ${RE2_SOURCE_DIR}")
68+
FetchContent_Declare(
69+
re2
70+
SOURCE_DIR ${RE2_SOURCE_DIR}
71+
GIT_REPOSITORY ${re2_URL}
72+
GIT_TAG ${re2_TAG}
73+
)
74+
else()
75+
message(FATAL_ERROR "FUZZTEST_DOWNLOAD_DEPENDENCIES=OFF but RE2_SOURCE_DIR is not set.\n")
76+
endif()
77+
endif()
6078

79+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
6180
FetchContent_Declare(
62-
googletest
63-
GIT_REPOSITORY ${gtest_URL}
64-
GIT_TAG ${gtest_TAG}
81+
googletest
82+
GIT_REPOSITORY ${gtest_URL}
83+
GIT_TAG ${gtest_TAG}
6584
)
6685
else()
67-
find_package(absl REQUIRED)
68-
find_package(re2 REQUIRED)
6986
find_package(GTest REQUIRED)
7087
endif()
7188

7289
FetchContent_Declare(
73-
antlr_cpp
74-
URL ${antlr_cpp_URL}
75-
URL_HASH MD5=${antlr_cpp_MD5}
90+
antlr_cpp
91+
URL ${antlr_cpp_URL}
92+
URL_HASH MD5=${antlr_cpp_MD5}
7693
)
7794

7895
if (FUZZTEST_BUILD_FLATBUFFERS)
7996
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
8097
FetchContent_Declare(
81-
flatbuffers
82-
GIT_REPOSITORY ${flatbuffers_URL}
83-
GIT_TAG ${flatbuffers_TAG}
98+
flatbuffers
99+
GIT_REPOSITORY ${flatbuffers_URL}
100+
GIT_TAG ${flatbuffers_TAG}
84101
)
85102
else()
86103
find_package(flatbuffers REQUIRED)
@@ -90,19 +107,21 @@ endif()
90107
if (FUZZTEST_BUILD_TESTING)
91108
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
92109
FetchContent_Declare(
93-
protobuf
94-
GIT_REPOSITORY ${proto_URL}
95-
GIT_TAG ${proto_TAG}
110+
protobuf
111+
GIT_REPOSITORY ${proto_URL}
112+
GIT_TAG ${proto_TAG}
96113
)
97114

98115
FetchContent_Declare(
99-
nlohmann_json
100-
GIT_REPOSITORY ${nlohmann_json_URL}
101-
GIT_TAG ${nlohmann_json_TAG}
116+
nlohmann_json
117+
GIT_REPOSITORY ${nlohmann_json_URL}
118+
GIT_TAG ${nlohmann_json_TAG}
102119
)
103120
else()
104121
find_package(Protobuf REQUIRED)
105-
add_library(protobuf::libprotobuf ALIAS Protobuf::protobuf)
122+
if(TARGET Protobuf::protobuf AND NOT TARGET protobuf::libprotobuf)
123+
add_library(protobuf::libprotobuf ALIAS Protobuf::protobuf)
124+
endif()
106125
find_package(nlohmann_json REQUIRED)
107126
endif()
108127
endif ()
@@ -111,10 +130,16 @@ if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
111130
set(ABSL_PROPAGATE_CXX_STD ON)
112131
set(ABSL_ENABLE_INSTALL ON)
113132
FetchContent_MakeAvailable(abseil-cpp)
133+
else()
134+
if(TARGET absl::absl)
135+
message(STATUS "Using system absl target absl::absl")
136+
endif()
137+
endif()
114138

115-
set(RE2_BUILD_TESTING OFF)
116-
FetchContent_MakeAvailable(re2)
139+
set(RE2_BUILD_TESTING OFF)
140+
FetchContent_MakeAvailable(re2)
117141

142+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
118143
set(GTEST_HAS_ABSL ON)
119144
FetchContent_MakeAvailable(googletest)
120145
endif()

0 commit comments

Comments
 (0)