]> granicus.if.org Git - graphviz/commitdiff
CMake: avoid referencing 'EXPAT_INCLUDE_DIRS' unless Expat has been sought
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Nov 2022 21:09:04 +0000 (14:09 -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_expat=OFF`:

  CMake Error (dev) at lib/common/CMakeLists.txt:111
    (target_include_directories):
    uninitialized variable 'EXPAT_INCLUDE_DIRS'

Gitlab: #2291

lib/common/CMakeLists.txt

index 3a167d483a916d47888d0b2afb0aac13bd799097..796ed42974058b58db06b2e9830ae3a3a508f04f 100644 (file)
@@ -108,9 +108,11 @@ target_include_directories(common_obj PRIVATE
   ../xdot
 )
 
-target_include_directories(common_obj SYSTEM PRIVATE
-  ${EXPAT_INCLUDE_DIRS}
-)
+if(EXPAT_FOUND)
+  target_include_directories(common_obj SYSTEM PRIVATE
+    ${EXPAT_INCLUDE_DIRS}
+  )
+endif()
 
 if(WIN32)
   target_include_directories(common_obj