]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Allow gtest_zlib to be manually disabled
authorCameron Cawley <ccawley2011@gmail.com>
Thu, 13 Oct 2022 17:52:50 +0000 (18:52 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 9 Jan 2023 14:10:53 +0000 (15:10 +0100)
CMakeLists.txt
README.md
test/CMakeLists.txt

index 642d35f42b64798657ed3ee8501d53eb2f04c345..4400fea584d8a67b2376caee57038a3555b1cac6 100644 (file)
@@ -77,6 +77,7 @@ option(WITH_GZFILEOP "Compile with support for gzFile related functions" ON)
 option(ZLIB_COMPAT "Compile with zlib compatible API" OFF)
 option(ZLIB_ENABLE_TESTS "Build test binaries" ON)
 option(ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API" ON)
+option(WITH_GTEST "Build gtest_zlib" ON)
 option(WITH_FUZZERS "Build test/fuzz" OFF)
 option(WITH_BENCHMARKS "Build test/benchmarks" OFF)
 option(WITH_BENCHMARK_APPS "Build application benchmarks" OFF)
@@ -1187,6 +1188,7 @@ add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Compile with zlib compatible API")
 add_feature_info(ZLIB_ENABLE_TESTS ZLIB_ENABLE_TESTS "Build test binaries")
 add_feature_info(ZLIBNG_ENABLE_TESTS ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API")
 add_feature_info(WITH_SANITIZER WITH_SANITIZER "Enable sanitizer support")
+add_feature_info(WITH_GTEST WITH_GTEST "Build gtest_zlib")
 add_feature_info(WITH_FUZZERS WITH_FUZZERS "Build test/fuzz")
 add_feature_info(WITH_BENCHMARKS WITH_BENCHMARKS "Build test/benchmarks")
 add_feature_info(WITH_BENCHMARK_APPS WITH_BENCHMARK_APPS "Build application benchmarks")
index a1218d44d0f797363b7ec8bab4861bcafc0b1dd0..80b921b2c78696ed184413fffc0684f14d7f324f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -120,6 +120,7 @@ Build Options
 | WITH_NEW_STRATEGIES      | --without-new-strategies | Use new strategies                                                                    | ON      |
 | WITH_NATIVE_INSTRUCTIONS | --native                 | Compiles with full instruction set supported on this host (gcc/clang -march=native)   | OFF     |
 | WITH_SANITIZER           |                          | Build with sanitizer (memory, address, undefined)                                     | OFF     |
+| WITH_GTEST               |                          | Build gtest_zlib                                                                      | ON      |
 | WITH_FUZZERS             |                          | Build test/fuzz                                                                       | OFF     |
 | WITH_BENCHMARKS          |                          | Build test/benchmarks                                                                 | OFF     |
 | WITH_MAINTAINER_WARNINGS |                          | Build with project maintainer warnings                                                | OFF     |
index 55a3057be79fff1598578af4c3feed34d172a6c3..11cf73175e1e238dae16da4dcdd0823f6bb8f7c0 100644 (file)
@@ -92,16 +92,26 @@ if(WITH_FUZZERS)
     add_subdirectory(fuzz)
 endif()
 
-if(CMAKE_VERSION VERSION_LESS 3.12)
-    message(WARNING "Minimum cmake version of 3.12 not met for GoogleTest or benchmarks!")
-else()
-    enable_language(CXX)
+if(WITH_GTEST OR WITH_BENCHMARKS)
+    if(CMAKE_VERSION VERSION_LESS 3.12)
+        message(WARNING "Minimum cmake version of 3.12 not met for GoogleTest or benchmarks!")
 
-    include(FetchContent)
+        set(WITH_GTEST OFF)
+        set(WITH_GTEST OFF PARENT_SCOPE)
 
-    if(WITH_BENCHMARKS)
-        add_subdirectory(benchmarks)
+        set(WITH_BENCHMARKS OFF)
+        set(WITH_BENCHMARKS OFF PARENT_SCOPE)
+    else()
+        enable_language(CXX)
     endif()
+endif()
+
+if(WITH_BENCHMARKS)
+    add_subdirectory(benchmarks)
+endif()
+
+if(WITH_GTEST)
+    include(FetchContent)
 
     # Google test requires at least C++11
     set(CMAKE_CXX_STANDARD 11)