Skip to content

Commit 30c1061

Browse files
author
John Doe
committed
fetch content issue
1 parent ccaaf92 commit 30c1061

4 files changed

Lines changed: 90 additions & 144 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
cmake_minimum_required(VERSION 3.19)
1616
project(fuzztest)
1717

18+
option(FUZZTEST_DOWNLOAD_DEPENDENCIES "Download dependencies using FetchContent." ON)
1819
option(FUZZTEST_BUILD_TESTING "Building the tests." OFF)
1920
option(FUZZTEST_BUILD_FLATBUFFERS "Building the flatbuffers support." OFF)
2021
option(FUZZTEST_FUZZING_MODE "Building the fuzztest in fuzzing mode." OFF)

cmake/BuildDependencies.cmake

Lines changed: 89 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,105 +16,125 @@ cmake_minimum_required(VERSION 3.19)
1616

1717
include(FetchContent)
1818

19-
set(absl_URL https://github.com/abseil/abseil-cpp.git)
20-
set(absl_TAG d04b964d82ed5146f7e5e34701a5ba69f9514c9a)
19+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
20+
set(absl_URL https://github.com/abseil/abseil-cpp.git)
21+
set(absl_TAG d04b964d82ed5146f7e5e34701a5ba69f9514c9a)
2122

23+
set(re2_URL https://github.com/google/re2.git)
24+
set(re2_TAG 2024-07-02)
2225

23-
if(FUZZTEST_USE_SYSTEM_RE2)
24-
find_package(re2 REQUIRED)
25-
set(FUZZTEST_BUILD_REGEXP_DFA OFF CACHE BOOL
26-
"Build regexp_dfa (needs private RE2 headers)" FORCE)
27-
message(WARNING "System RE2 detected: regexp_dfa will NOT be built")
28-
else()
29-
set(FUZZTEST_BUILD_REGEXP_DFA ON CACHE BOOL
30-
"Build regexp_dfa (needs private RE2 headers)" FORCE)
31-
endif()
26+
set(gtest_URL https://github.com/google/googletest.git)
27+
set(gtest_TAG v1.16.0)
3228

29+
set(proto_URL https://github.com/protocolbuffers/protobuf.git)
30+
set(proto_TAG v30.2)
3331

34-
set(gtest_URL https://github.com/google/googletest.git)
35-
set(gtest_TAG v1.16.0)
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()
3638

3739
# From https://www.antlr.org/download.html
3840
set(antlr_cpp_URL https://www.antlr.org/download/antlr4-cpp-runtime-4.12.0-source.zip)
3941
set(antlr_cpp_MD5 acf7371bd7562188712751266d8a7b90)
4042

41-
set(proto_URL https://github.com/protocolbuffers/protobuf.git)
42-
set(proto_TAG v30.2)
43-
44-
set(nlohmann_json_URL https://github.com/nlohmann/json.git)
45-
set(nlohmann_json_TAG v3.11.3)
46-
47-
set(flatbuffers_URL https://github.com/google/flatbuffers.git)
48-
set(flatbuffers_TAG v25.2.10)
49-
5043
if(POLICY CMP0135)
51-
cmake_policy(SET CMP0135 NEW)
52-
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
44+
cmake_policy(SET CMP0135 NEW)
45+
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
5346
endif()
5447

55-
FetchContent_Declare(
56-
abseil-cpp
57-
GIT_REPOSITORY ${absl_URL}
58-
GIT_TAG ${absl_TAG}
59-
)
60-
61-
FetchContent_Declare(
62-
googletest
63-
GIT_REPOSITORY ${gtest_URL}
64-
GIT_TAG ${gtest_TAG}
65-
)
66-
67-
FetchContent_Declare(
68-
antlr_cpp
69-
URL ${antlr_cpp_URL}
70-
URL_HASH MD5=${antlr_cpp_MD5}
71-
)
72-
73-
if (FUZZTEST_BUILD_FLATBUFFERS)
48+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
7449
FetchContent_Declare(
75-
flatbuffers
76-
GIT_REPOSITORY ${flatbuffers_URL}
77-
GIT_TAG ${flatbuffers_TAG}
50+
abseil-cpp
51+
GIT_REPOSITORY ${absl_URL}
52+
GIT_TAG ${absl_TAG}
7853
)
79-
endif()
80-
81-
if (FUZZTEST_BUILD_TESTING)
8254

8355
FetchContent_Declare(
84-
protobuf
85-
GIT_REPOSITORY ${proto_URL}
86-
GIT_TAG ${proto_TAG}
56+
re2
57+
GIT_REPOSITORY ${re2_URL}
58+
GIT_TAG ${re2_TAG}
8759
)
8860

8961
FetchContent_Declare(
90-
nlohmann_json
91-
GIT_REPOSITORY ${nlohmann_json_URL}
92-
GIT_TAG ${nlohmann_json_TAG}
62+
googletest
63+
GIT_REPOSITORY ${gtest_URL}
64+
GIT_TAG ${gtest_TAG}
9365
)
66+
else()
67+
find_package(absl REQUIRED)
68+
find_package(re2 REQUIRED)
69+
find_package(GTest REQUIRED)
70+
endif()
71+
72+
FetchContent_Declare(
73+
antlr_cpp
74+
URL ${antlr_cpp_URL}
75+
URL_HASH MD5=${antlr_cpp_MD5}
76+
)
9477

78+
if (FUZZTEST_BUILD_FLATBUFFERS)
79+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
80+
FetchContent_Declare(
81+
flatbuffers
82+
GIT_REPOSITORY ${flatbuffers_URL}
83+
GIT_TAG ${flatbuffers_TAG}
84+
)
85+
else()
86+
find_package(flatbuffers REQUIRED)
87+
endif()
88+
endif()
89+
90+
if (FUZZTEST_BUILD_TESTING)
91+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
92+
FetchContent_Declare(
93+
protobuf
94+
GIT_REPOSITORY ${proto_URL}
95+
GIT_TAG ${proto_TAG}
96+
)
97+
98+
FetchContent_Declare(
99+
nlohmann_json
100+
GIT_REPOSITORY ${nlohmann_json_URL}
101+
GIT_TAG ${nlohmann_json_TAG}
102+
)
103+
else()
104+
find_package(Protobuf REQUIRED)
105+
add_library(protobuf::libprotobuf ALIAS Protobuf::protobuf)
106+
find_package(nlohmann_json REQUIRED)
107+
endif()
95108
endif ()
96109

97-
set(ABSL_PROPAGATE_CXX_STD ON)
98-
set(ABSL_ENABLE_INSTALL ON)
99-
FetchContent_MakeAvailable(abseil-cpp)
110+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
111+
set(ABSL_PROPAGATE_CXX_STD ON)
112+
set(ABSL_ENABLE_INSTALL ON)
113+
FetchContent_MakeAvailable(abseil-cpp)
100114

101-
set(GTEST_HAS_ABSL ON)
102-
FetchContent_MakeAvailable(googletest)
115+
set(RE2_BUILD_TESTING OFF)
116+
FetchContent_MakeAvailable(re2)
117+
118+
set(GTEST_HAS_ABSL ON)
119+
FetchContent_MakeAvailable(googletest)
120+
endif()
103121

104122
FetchContent_MakeAvailable(antlr_cpp)
105123

106124
if (FUZZTEST_BUILD_TESTING)
125+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
126+
set(protobuf_BUILD_TESTS OFF)
127+
set(protobuf_INSTALL OFF)
128+
FetchContent_MakeAvailable(protobuf)
107129

108-
set(protobuf_BUILD_TESTS OFF)
109-
set(protobuf_INSTALL OFF)
110-
FetchContent_MakeAvailable(protobuf)
111-
112-
FetchContent_MakeAvailable(nlohmann_json)
113-
130+
FetchContent_MakeAvailable(nlohmann_json)
131+
endif()
114132
endif ()
115133

116134
if (FUZZTEST_BUILD_FLATBUFFERS)
117-
set(FLATBUFFERS_BUILD_TESTS OFF)
118-
set(FLATBUFFERS_BUILD_INSTALL OFF)
119-
FetchContent_MakeAvailable(flatbuffers)
135+
if(FUZZTEST_DOWNLOAD_DEPENDENCIES)
136+
set(FLATBUFFERS_BUILD_TESTS OFF)
137+
set(FLATBUFFERS_BUILD_INSTALL OFF)
138+
FetchContent_MakeAvailable(flatbuffers)
139+
endif()
120140
endif()

fuzztest/CMakeLists.txt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,25 +234,3 @@ fuzztest_cc_library(
234234
fuzztest::io
235235
fuzztest::core_domains_impl
236236
)
237-
238-
if (FUZZTEST_BUILD_REGEXP_DFA)
239-
fuzztest_cc_library(
240-
NAME
241-
regexp_dfa
242-
HDRS
243-
"regexp_dfa.h"
244-
SRCS
245-
"regexp_dfa.cc"
246-
DEPS
247-
absl::flat_hash_map
248-
absl::random_bit_gen_ref
249-
absl::random_distributions
250-
absl::status
251-
absl::statusor
252-
absl::strings
253-
absl::string_view
254-
fuzztest::common_logging
255-
fuzztest::logging
256-
re2::re2
257-
)
258-
endif ()

fuzztest/internal/domains/CMakeLists.txt

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ fuzztest_cc_library(
117117
fuzztest::type_support
118118
)
119119

120-
if(FUZZTEST_BUILD_REGEXP_DFA)
121-
set(EXTRA_REGEXP_DFA_DEPS fuzztest::regexp_dfa)
122-
else()
123-
set(EXTRA_REGEXP_DFA_DEPS "")
124-
endif()
125-
126120
fuzztest_cc_library(
127121
NAME
128122
in_grammar_impl
@@ -133,7 +127,6 @@ fuzztest_cc_library(
133127
DEPS
134128
fuzztest::core_domains_impl
135129
fuzztest::in_regexp_impl
136-
${EXTRA_REGEXP_DFA_DEPS}
137130
absl::flat_hash_map
138131
absl::random_bit_gen_ref
139132
absl::random_distributions
@@ -156,7 +149,6 @@ fuzztest_cc_library(
156149
"in_regexp_impl.cc"
157150
DEPS
158151
fuzztest::core_domains_impl
159-
${EXTRA_REGEXP_DFA_DEPS}
160152
absl::random_bit_gen_ref
161153
absl::random_distributions
162154
absl::status
@@ -198,29 +190,6 @@ fuzztest_cc_library(
198190
fuzztest::type_support
199191
)
200192

201-
if(FUZZTEST_BUILD_REGEXP_DFA)
202-
fuzztest_cc_library(
203-
NAME
204-
regexp_dfa
205-
HDRS
206-
"regexp_dfa.h"
207-
SRCS
208-
"regexp_dfa.cc"
209-
DEPS
210-
absl::flat_hash_map
211-
absl::random_bit_gen_ref
212-
absl::random_distributions
213-
absl::status
214-
absl::statusor
215-
absl::strings
216-
absl::string_view
217-
fuzztest::common_logging
218-
fuzztest::logging
219-
re2::re2
220-
)
221-
endif()
222-
223-
224193
fuzztest_cc_library(
225194
NAME
226195
utf
@@ -233,25 +202,3 @@ fuzztest_cc_library(
233202
DEPS
234203
absl::string_view
235204
)
236-
237-
if(FUZZTEST_BUILD_REGEXP_DFA)
238-
fuzztest_cc_library(
239-
NAME
240-
regexp_dfa
241-
HDRS
242-
"regexp_dfa.h"
243-
SRCS
244-
"regexp_dfa.cc"
245-
DEPS
246-
absl::flat_hash_map
247-
absl::random_bit_gen_ref
248-
absl::random_distributions
249-
absl::status
250-
absl::statusor
251-
absl::strings
252-
absl::string_view
253-
fuzztest::common_logging
254-
fuzztest::logging
255-
re2::re2
256-
)
257-
endif()

0 commit comments

Comments
 (0)