From f38d9daba605626b69bff26bea84f442718c836c Mon Sep 17 00:00:00 2001
From: Nehal J Wani <nehaljw.kkd1@gmail.com>
Date: Mon, 15 Feb 2021 17:02:21 -0500
Subject: [PATCH 4/7] Always link to getopt on Windows

---
 CMakeLists.txt           | 2 +-
 cmd/tools/CMakeLists.txt | 4 ++--
 lib/gvpr/CMakeLists.txt  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78081f45d..cf6850f74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,7 +176,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphviz_version.h DESTINATION ${HEADE
 message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION_FULL}")
 
 include(config_checks)
-if (NOT HAVE_GETOPT_H)
+if (WIN32 OR (NOT HAVE_GETOPT_H))
     find_package(Getopt REQUIRED)
 endif()
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/cmd/tools/CMakeLists.txt b/cmd/tools/CMakeLists.txt
index 068a7b838..a3170a9fd 100644
--- a/cmd/tools/CMakeLists.txt
+++ b/cmd/tools/CMakeLists.txt
@@ -3,9 +3,9 @@
 # - installation of executable
 # - installation of manpage
 function(tool_defaults name)
-    if(NOT HAVE_GETOPT_H)
+    if (WIN32 OR (NOT HAVE_GETOPT_H))
         target_link_libraries(${name} ${Getopt_LINK_LIBRARIES})
-    endif(NOT HAVE_GETOPT_H)
+    endif()
 
     install(
         TARGETS ${name}
diff --git a/lib/gvpr/CMakeLists.txt b/lib/gvpr/CMakeLists.txt
index 0796c86ef..92cd7da1d 100644
--- a/lib/gvpr/CMakeLists.txt
+++ b/lib/gvpr/CMakeLists.txt
@@ -59,6 +59,6 @@ target_link_libraries(gvpr
     vmalloc
 )
 
-if(NOT HAVE_GETOPT_H)
+if (WIN32 OR (NOT HAVE_GETOPT_H))
     target_link_libraries(gvpr ${Getopt_LINK_LIBRARIES})
-endif(NOT HAVE_GETOPT_H)
+endif()
-- 
2.31.1

