]> granicus.if.org Git - graphviz/commitdiff
CMake: avoid referencing 'ZLIB_FOUND' when 'with_zlib' is not set
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Nov 2022 21:07:57 +0000 (14:07 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 8 Nov 2022 04:52:51 +0000 (20:52 -0800)
CMake when using `--warn-uninitialized -Werror=dev` notices that this variable
is being incorrectly referenced when `-Dwith_zlib=OFF`:

  CMake Error (dev) at cmake/config_checks.cmake:42 (set):
    uninitialized variable 'ZLIB_FOUND'
  Call Stack (most recent call first):
    CMakeLists.txt:197 (include)

Gitlab: #2291

cmake/config_checks.cmake

index e9a6ed6acf34e37c3fa03471e8ecca8c47c883a3..135df6b5e7a93aec57083349bba285c467c1f5b2 100644 (file)
@@ -41,7 +41,9 @@ if(with_expat AND EXPAT_FOUND)
   set(HAVE_EXPAT 1)
 endif()
 set( HAVE_LIBGD     ${GD_FOUND}         )
-set( HAVE_ZLIB      ${ZLIB_FOUND}       )
+if(with_zlib AND ZLIB_FOUND)
+  set(HAVE_ZLIB 1)
+endif()
 
 if(LTDL_FOUND)
   set(ENABLE_LTDL 1)