]> granicus.if.org Git - graphviz/commitdiff
CMake: avoid use of 'GETOPT_INCLUDE_DIRS' when getopt has not been looked for
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Nov 2022 18:59:52 +0000 (11:59 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 8 Nov 2022 04:52:51 +0000 (20:52 -0800)
When running CMake with `--warn-uninitialized -Werror=dev`, this prevents the
following:

  CMake Error (dev) at cmd/mingle/CMakeLists.txt:15 (target_include_directories):
    uninitialized variable 'GETOPT_INCLUDE_DIRS'

Gitlab: #2291

cmd/mingle/CMakeLists.txt

index 3a88113491bb42678f7d1ef5687647685b2858b0..077c63a6dfc1cae7078fcdbb90ffa4281f3c3056 100644 (file)
@@ -12,10 +12,12 @@ if(with_sfdp AND ANN_FOUND)
       ../../lib/common
   )
 
-  target_include_directories(mingle
-    SYSTEM PRIVATE
-      ${GETOPT_INCLUDE_DIRS}
-  )
+  if(GETOPT_FOUND)
+    target_include_directories(mingle
+      SYSTEM PRIVATE
+        ${GETOPT_INCLUDE_DIRS}
+    )
+  endif()
 
   target_link_libraries(mingle
     cdt