]> granicus.if.org Git - graphviz/commitdiff
Replace getopt subproject with vcpkg getopt lib for cmd/tools in CMake
authorMagnus Jacobsson <magnus.jacobsson@berotec.se>
Sun, 4 Oct 2020 12:02:32 +0000 (14:02 +0200)
committerMagnus Jacobsson <magnus.jacobsson@berotec.se>
Thu, 8 Oct 2020 19:10:23 +0000 (21:10 +0200)
Towards https://gitlab.com/graphviz/graphviz/-/issues/1820.

CMakeLists.txt
cmake/FindGetopt.cmake [new file with mode: 0644]
cmd/tools/CMakeLists.txt
windows/CMakeLists.txt [deleted file]

index 4536df2d69c233b35536bfa4be8b585f2c75a90e..2ea9ba045663e09a1445dcb0dd21df2df54418b2 100644 (file)
@@ -158,6 +158,9 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/builddate.h "#define BUILDDATE \"${GRAPHV
 message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION_FULL}")
 
 include(config_checks)
+if (NOT HAVE_GETOPT_H)
+    find_package(Getopt REQUIRED)
+endif()
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 # ==================== Custom target for `make uninstall` ======================
@@ -188,7 +191,6 @@ include(package_info)
 include(CPack)
 
 # ======================= Specify subdirectories to build ======================
-add_subdirectory(windows)
 add_subdirectory(lib)
 add_subdirectory(plugin)
 add_subdirectory(cmd)
diff --git a/cmake/FindGetopt.cmake b/cmake/FindGetopt.cmake
new file mode 100644 (file)
index 0000000..1742891
--- /dev/null
@@ -0,0 +1,23 @@
+include(FindPackageHandleStandardArgs)
+
+find_path(Getopt_INCLUDE_DIR getopt.h)
+find_library(Getopt_LIBRARY NAMES getopt)
+find_program(Getopt_RUNTIME_LIBRARY NAMES getopt.dll)
+
+if (WIN32)
+    find_package_handle_standard_args(Getopt DEFAULT_MSG
+        Getopt_INCLUDE_DIR
+        Getopt_LIBRARY
+        Getopt_RUNTIME_LIBRARY
+    )
+else()
+    find_package_handle_standard_args(Getopt DEFAULT_MSG
+        Getopt_INCLUDE_DIR
+        Getopt_LIBRARY
+    )
+endif()
+
+set(Getopt_INCLUDE_DIRS ${Getopt_INCLUDE_DIR})
+set(Getopt_LIBRARIES ${Getopt_LIBRARY})
+set(Getopt_LINK_LIBRARIES ${Getopt_LIBRARY})
+set(Getopt_RUNTIME_LIBRARIES ${Getopt_RUNTIME_LIBRARY})
index 8ee05100d28266c3e9213ef72f0a591711bd9137..fb6d66160993f59e739132f51ee06c395640c445 100644 (file)
@@ -4,7 +4,7 @@
 # - installation of manpage
 function(tool_defaults name)
     if(NOT HAVE_GETOPT_H)
-        target_link_libraries(${name} getopt)
+        target_link_libraries(${name} ${Getopt_LINK_LIBRARIES})
     endif(NOT HAVE_GETOPT_H)
 
     install(
@@ -29,7 +29,6 @@ function(add_simple_tool name)
         ${GRAPHVIZ_LIB_DIR}
         ${CMAKE_CURRENT_SOURCE_DIR}
         ${CMAKE_CURRENT_BINARY_DIR}
-        ${TOP_SOURCE_DIR}/windows/getopt
         ${GRAPHVIZ_LIB_DIR}/cdt
         ${GRAPHVIZ_LIB_DIR}/cgraph
         ${GRAPHVIZ_LIB_DIR}/common
@@ -37,6 +36,7 @@ function(add_simple_tool name)
         ${GRAPHVIZ_LIB_DIR}/pack
         ${GRAPHVIZ_LIB_DIR}/pathplan
         ${EXPAT_INCLUDE_DIRS}
+        ${Getopt_INCLUDE_DIRS}
     )
 
     target_link_libraries(${name}
@@ -70,7 +70,6 @@ target_include_directories(dijkstra PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -78,6 +77,7 @@ target_include_directories(dijkstra PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(dijkstra
@@ -106,7 +106,6 @@ target_include_directories(gml2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -114,6 +113,7 @@ target_include_directories(gml2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(gml2gv
@@ -135,7 +135,6 @@ target_include_directories(graphml2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -143,6 +142,7 @@ target_include_directories(graphml2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(graphml2gv
@@ -170,7 +170,6 @@ target_include_directories(gvcolor PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -178,6 +177,7 @@ target_include_directories(gvcolor PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(gvcolor
@@ -198,7 +198,6 @@ target_include_directories(gvgen PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -206,6 +205,7 @@ target_include_directories(gvgen PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(gvgen cgraph)
@@ -231,7 +231,6 @@ target_include_directories(gvpack PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -239,6 +238,7 @@ target_include_directories(gvpack PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(gvpack
@@ -265,7 +265,6 @@ target_include_directories(gxl2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -273,6 +272,7 @@ target_include_directories(gxl2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(gxl2gv
@@ -298,7 +298,6 @@ target_include_directories(mm2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -306,6 +305,7 @@ target_include_directories(mm2gv PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(mm2gv
@@ -330,7 +330,6 @@ target_include_directories(sccmap PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${TOP_SOURCE_DIR}/windows/getopt
     ${GRAPHVIZ_LIB_DIR}/cdt
     ${GRAPHVIZ_LIB_DIR}/cgraph
     ${GRAPHVIZ_LIB_DIR}/common
@@ -338,6 +337,7 @@ target_include_directories(sccmap PRIVATE
     ${GRAPHVIZ_LIB_DIR}/pack
     ${GRAPHVIZ_LIB_DIR}/pathplan
     ${EXPAT_INCLUDE_DIRS}
+    ${Getopt_INCLUDE_DIRS}
 )
 
 target_link_libraries(sccmap
@@ -358,3 +358,10 @@ if (WIN32 AND EXPAT_FOUND)
         DESTINATION ${BINARY_INSTALL_DIR}
     )
 endif(WIN32 AND EXPAT_FOUND)
+
+if (WIN32)
+    install(
+        FILES ${Getopt_RUNTIME_LIBRARIES}
+        DESTINATION ${BINARY_INSTALL_DIR}
+    )
+endif()
diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt
deleted file mode 100644 (file)
index 9f10fe5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(getopt)