From: Magnus Jacobsson Date: Sun, 4 Oct 2020 12:02:32 +0000 (+0200) Subject: Replace getopt subproject with vcpkg getopt lib for cmd/tools in CMake X-Git-Tag: 2.46.0~20^2^2~47^2~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4b41a4a1bef65632d6efa94e0ae9a6ecaae1f89;p=graphviz Replace getopt subproject with vcpkg getopt lib for cmd/tools in CMake Towards https://gitlab.com/graphviz/graphviz/-/issues/1820. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4536df2d6..2ea9ba045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 000000000..17428912d --- /dev/null +++ b/cmake/FindGetopt.cmake @@ -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}) diff --git a/cmd/tools/CMakeLists.txt b/cmd/tools/CMakeLists.txt index 8ee05100d..fb6d66160 100644 --- a/cmd/tools/CMakeLists.txt +++ b/cmd/tools/CMakeLists.txt @@ -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 index 9f10fe514..000000000 --- a/windows/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(getopt)