From 3b567c4bd938e2e70478b22d5efae98bedf9ed8f Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Tue, 7 Feb 2017 08:02:19 +0100 Subject: [PATCH] Add lib/gvc to CMake build The dynamic library `gvc` is the core library of Graphviz. It has various dependencies, of which some are third party libraries. The DLLs of these libraries will be included in the package on Windows. Now also generating `builddate.h` on all platforms. The Windows Visual Studio build didn't generate this file. Now also defines GVPLUGIN_CONFIG_FILE, set to confg6, just like the Autotools build. Support the "enable-ltdl" option, default value is ON. Now passing the "-fPIC" to all compilers, except MSVC. The following checks have been added: - FindLTDL - FindRxSpencer (on Windows only) --- CMakeLists.txt | 22 ++- cmake/FindLTDL.cmake | 18 ++ cmake/FindRxSpencer.cmake | 20 +++ cmake/config_checks.cmake | 5 + config-cmake.h.in | 1 + lib/CMakeLists.txt | 3 + lib/gvc/CMakeLists.txt | 115 ++++++++++++ lib/gvc/gvc.def | 362 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 543 insertions(+), 3 deletions(-) create mode 100644 cmake/FindLTDL.cmake create mode 100644 cmake/FindRxSpencer.cmake create mode 100644 lib/gvc/CMakeLists.txt create mode 100644 lib/gvc/gvc.def diff --git a/CMakeLists.txt b/CMakeLists.txt index 27f1389fb..cd1b8bc95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,17 @@ cmake_minimum_required (VERSION 2.8 FATAL_ERROR) project (Graphviz) # =============================== Build options ================================ +option(enable_ltdl "Support on-demand plugin loading" ON) option(with_digcola "DIGCOLA features in neato layout engine" ON ) option(with_ipsepcola "IPSEPCOLA features in neato layout engine (disabled by default - C++ portability issues)." OFF ) option(with_ortho "ORTHO features in neato layout engine." ON ) option(with_sfdp "sfdp layout engine." ON ) option(with_smyrna "SMYRNA large graph viewer (disabled by default - experimental)" OFF) +if (enable_ltdl) + add_definitions(-DENABLE_LTDL) +endif (enable_ltdl) + if (with_digcola) add_definitions(-DDIGCOLA) endif (with_digcola) @@ -50,6 +55,9 @@ set(TOP_SOURCE_DIR "${CMAKE_SOURCE_DIR}") set(GRAPHVIZ_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib") set(WINDOWS_DEPENDENCY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/windows/dependencies/libraries") +# Name of the config file used by Graphviz +set(GVPLUGIN_CONFIG_FILE config6) + # ============================ Library dependencies ============================ if (WIN32) list(APPEND CMAKE_LIBRARY_PATH ${WINDOWS_DEPENDENCY_DIR}/lib) @@ -60,12 +68,16 @@ endif() find_package(ANN) find_package(EXPAT) +find_package(LTDL) find_package(ZLIB) -# Find DLLs on Windows if (WIN32) - find_file(EXPAT_RUNTIME_LIBRARY NAMES libexpat.dll expat.dll) - find_file(ZLIB_RUNTIME_LIBRARY NAMES zlib1.dll zlib.dll) + # Find Windows specific dependencies + find_package(RxSpencer REQUIRED) + + # Find DLLs on Windows + find_file(EXPAT_RUNTIME_LIBRARIES NAMES libexpat.dll expat.dll) + find_file(ZLIB_RUNTIME_LIBRARIES NAMES zlib1.dll zlib.dll) endif() # ============================ Set Graphviz version ============================ @@ -88,6 +100,7 @@ if(NOT git_result EQUAL 0) endif() set(GRAPHVIZ_VERSION_FULL "${GRAPHVIZ_VERSION_MAJROR}.${GRAPHVIZ_VERSION_MINOR}.${GRAPHVIZ_VERSION_BUILD}") +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/builddate.h "#define BUILDDATE \"${GRAPHVIZ_VERSION_BUILD}\"") message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION_FULL}") @@ -112,6 +125,9 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) # we suppress this warning. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") +else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() # ============================ Packaging information =========================== diff --git a/cmake/FindLTDL.cmake b/cmake/FindLTDL.cmake new file mode 100644 index 000000000..ed0ff7f87 --- /dev/null +++ b/cmake/FindLTDL.cmake @@ -0,0 +1,18 @@ +find_path(LTDL_INCLUDE_DIR ltdl.h) +find_library(LTDL_LIBRARY NAMES libtldl ltdl) +find_file(LTDL_RUNTIME_LIBRARY libltdl3.dll) + +include(FindPackageHandleStandardArgs) +if (WIN32) + find_package_handle_standard_args(LTDL DEFAULT_MSG + LTDL_LIBRARY LTDL_INCLUDE_DIR LTDL_RUNTIME_LIBRARY) +else() + find_package_handle_standard_args(LTDL DEFAULT_MSG + LTDL_LIBRARY LTDL_INCLUDE_DIR) +endif() + +mark_as_advanced(LTDL_INCLUDE_DIR LTDL_LIBRARY LTDL_RUNTIME_LIBRARY) + +set(LTDL_INCLUDE_DIRS ${LTDL_INCLUDE_DIR}) +set(LTDL_LIBRARIES ${LTDL_LIBRARY}) +set(LTDL_RUNTIME_LIBRARIES ${LTDL_RUNTIME_LIBRARY}) diff --git a/cmake/FindRxSpencer.cmake b/cmake/FindRxSpencer.cmake new file mode 100644 index 000000000..2a4df12f3 --- /dev/null +++ b/cmake/FindRxSpencer.cmake @@ -0,0 +1,20 @@ +find_path(RXSPENCER_INCLUDE_DIR regex.h) +find_library(RXSPENCER_LIBRARY NAMES rxspencer) +find_file(RXSPENCER_RUNTIME_LIBRARY rxspencer.dll) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(RXSPENCER DEFAULT_MSG + RXSPENCER_LIBRARY + RXSPENCER_INCLUDE_DIR + RXSPENCER_RUNTIME_LIBRARY +) + +mark_as_advanced( + RXSPENCER_INCLUDE_DIR + RXSPENCER_LIBRARY + RXSPENCER_RUNTIME_LIBRARY +) + +set(RXSPENCER_INCLUDE_DIRS ${RXSPENCER_INCLUDE_DIR}) +set(RXSPENCER_LIBRARIES ${RXSPENCER_LIBRARY}) +set(RXSPENCER_RUNTIME_LIBRARIES ${RXSPENCER_RUNTIME_LIBRARY}) diff --git a/cmake/config_checks.cmake b/cmake/config_checks.cmake index 5ed6f9e9f..ce3f73021 100644 --- a/cmake/config_checks.cmake +++ b/cmake/config_checks.cmake @@ -36,6 +36,11 @@ set( HAVE_ANN ${ANN_FOUND} ) set( HAVE_EXPAT ${EXPAT_FOUND} ) set( HAVE_ZLIB ${ZLIB_FOUND} ) +if (LTDL_FOUND) + set(ENABLE_LTDL 1) + set(LTDL_H 1) +endif() + # Values set(DEFAULT_DPI 96) diff --git a/config-cmake.h.in b/config-cmake.h.in index b72755887..ec6a36f7a 100644 --- a/config-cmake.h.in +++ b/config-cmake.h.in @@ -1,4 +1,5 @@ // Values +#define GVPLUGIN_CONFIG_FILE "@GVPLUGIN_CONFIG_FILE@" #define PACKAGE_VERSION "@GRAPHVIZ_VERSION_FULL@" // Include headers diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 227df0db5..3cea3a3e8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -25,3 +25,6 @@ add_subdirectory(xdot) # Dependent on: cdt add_subdirectory(cgraph) + +# Multiple dependencies +add_subdirectory(gvc) diff --git a/lib/gvc/CMakeLists.txt b/lib/gvc/CMakeLists.txt new file mode 100644 index 000000000..38215ea2e --- /dev/null +++ b/lib/gvc/CMakeLists.txt @@ -0,0 +1,115 @@ +add_definitions(-D_BLD_gvc=1 -DGVC_EXPORTS -DGVLIBDIR="${LIBRARY_INSTALL_DIR}/graphviz") + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${TOP_SOURCE_DIR} + ${GRAPHVIZ_LIB_DIR}/cdt + ${GRAPHVIZ_LIB_DIR}/cgraph + ${GRAPHVIZ_LIB_DIR}/common + ${GRAPHVIZ_LIB_DIR}/pathplan + ${LTDL_INCLUDE_DIRS} + ${RXSPENCER_INCLUDE_DIRS} +) + +add_library(gvc SHARED + # Header files + gvc.h + gvcext.h + gvcint.h + gvcjob.h + gvconfig.h + gvcommon.h + gvcproc.h + gvio.h + gvplugin.h + gvplugin_device.h + gvplugin_layout.h + gvplugin_loadimage.h + gvplugin_render.h + gvplugin_textlayout.h + + # Source files + gvc.c + gvconfig.c + gvcontext.c + gvdevice.c + gvevent.c + gvjobs.c + gvlayout.c + gvloadimage.c + gvplugin.c + gvrender.c + gvtextlayout.c + gvtool_tred.c + gvusershape.c + + # Link definition file for Windows + gvc.def +) + +target_link_libraries(gvc + cdt + cgraph + common + label + pack + pathplan + xdot + ${EXPAT_LIBRARIES} + ${LTDL_LIBRARIES} + ${RXSPENCER_LIBRARIES} + ${ZLIB_LIBRARIES} +) + +if (${with_ortho}) + target_link_libraries(gvc ortho) +endif() + +# Installation location of library files +install( + TARGETS gvc + RUNTIME DESTINATION ${BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR} +) + +# Specify headers to be installed +install( + FILES + gvc.h + gvcext.h + gvcjob.h + gvconfig.h + gvcommon.h + gvplugin.h + gvplugin_device.h + gvplugin_layout.h + gvplugin_loadimage.h + gvplugin_render.h + gvplugin_textlayout.h + DESTINATION ${HEADER_INSTALL_DIR} +) + +# Specify man pages to be installed +install( + FILES gvc.3 + DESTINATION ${MAN_INSTALL_DIR} +) + +# Specify library version and soversion +set_target_properties(gvc PROPERTIES + VERSION 6.0.0 + SOVERSION 6 +) + +# Include DLLs with this library on Windows +if (WIN32) + install( + FILES + ${EXPAT_RUNTIME_LIBRARIES} + ${LTDL_RUNTIME_LIBRARIES} + ${RXSPENCER_RUNTIME_LIBRARIES} + ${ZLIB_RUNTIME_LIBRARIES} + DESTINATION ${BINARY_INSTALL_DIR} + ) +endif() diff --git a/lib/gvc/gvc.def b/lib/gvc/gvc.def new file mode 100644 index 000000000..8b35412a5 --- /dev/null +++ b/lib/gvc/gvc.def @@ -0,0 +1,362 @@ +LIBRARY "gvc" + +EXPORTS +add_box +addPS +arrow_bb +arrow_flags +arrow_gen +arrow_length +arrowEndClip +arrowStartClip +attach_attrs +attach_attrs_and_arrows +beginpath +Bezier +bezier_clip +bind_shape +cat_libfile +ccomps +cccomps +ccwrotatep +ccwrotatepf +charsetToStr +CL_type +clearPM +clip_and_install +CmdName +common_init_edge +common_init_node +compute_bb +polyBB +Concentrate +coord +cwrotatep +cwrotatepf +Damping +dequeue +do_graph_label +dotneato_args_initialize +dotneato_closest +dotneato_postprocess +dotneato_usage +E_activefillcolor +E_activepencolor +E_arrowhead +E_arrowsz +E_arrowtail +E_color +E_comment +E_constr +E_decorate +E_deletedfillcolor +E_deletedpencolor +E_dir +E_fontcolor +E_fontname +E_fontsize +E_headclip +E_headlabel +E_label +E_xlabel +E_label_float +E_labelangle +E_labeldistance +E_labelfontcolor +E_labelfontname +E_labelfontsize +E_layer +E_minlen +E_penwidth +E_samehead +E_sametail +E_selectedfillcolor +E_selectedpencolor +E_showboxes +E_style +E_tailclip +E_taillabel +E_visitedfillcolor +E_visitedpencolor +E_weight +edgeType +elapsed_sec +emit_clusters +emit_graph +emit_label +emit_map_rect +emit_once +endpath +enqueue +epsf_define +epsf_emit_body +epsf_free +epsf_init +Epsilon +fdp_parms +Fgets +Files +find_user_shape +flip_rec_box +flip_rec_boxf +free_label +free_queue +freePM +freePS +G_activefillcolor +G_activepencolor +G_deletedfillcolor +G_deletedpencolor +G_ordering +G_penwidth +G_peripheries +G_selectedfillcolor +G_selectedpencolor +G_visitedfillcolor +G_visitedpencolor +getdouble +getPack +getPackMode +getsplinepoints +get_inputscale +gmalloc +graph_cleanup +graph_init +graphviz_errors +grealloc +gv_cleanup_edge +gv_cleanup_node +gv_free_splines +gv_nodesize +gvAddLibrary +gvcBuildDate +gvcInfo +gvContext +gvcVersion +GvExitOnUsage +Gvfilepath +gvFreeContext +gvFreeLayout +gvLayout +gvLayoutJobs +gvNEWcontext +gvNextInputGraph +gvParseArgs +gvPluginsGraph +gvprintdouble +gvprintf +gvprintpointf +gvprintpointflist +gvputc +gvputs +gvRender +gvRenderData +gvFreeRenderData +gvRenderFilename +gvRenderJobs +gvToggle +gvusershape_file_access +gvusershape_file_release +gvwrite +htmlEntityUTF8 +HTTPServerEnVar +Initial_dist +initMapData +inPS +insertPM +updatePM +insertPS +isConnected +isInPS +isPolygon +late_bool +late_double +late_int +late_nnstring +late_string +latin1ToUTF8 +Lib +line_intersect +lineToBox +lt_dladderror +lt_dladdsearchdir +lt_dlcaller_get_data +lt_dlcaller_set_data +lt_dlclose +lt_dlerror +lt_dlexit +lt_dlforeachfile +lt_dlgetinfo +lt_dlgetsearchpath +lt_dlinit +lt_dlinsertsearchdir +lt_dlisresident +lt_dlloader_add +lt_dlloader_find +lt_dlloader_next +lt_dlloader_remove +lt_dlmakeresident +lt_dlopen +lt_dlopenext +lt_dlpreload +lt_dlpreload_default +lt_dlseterror +lt_dlsetsearchpath +lt_dlsym +make_label +make_simple_label +makeSelfEdge +mapClust +mapbool +maptoken +MaxIter +MemTest +mkbox +mkboxf +N_activefillcolor +N_activepencolor +N_color +N_comment +N_deletedfillcolor +N_deletedpencolor +N_distortion +N_fillcolor +N_fixed +N_fontcolor +N_fontname +N_fontsize +N_group +N_height +N_imagescale +N_label +N_xlabel +N_layer +N_nojustify +N_ordering +N_orientation +N_penwidth +N_peripheries +N_selectedfillcolor +N_selectedpencolor +N_shape +N_showboxes +N_sides +N_skew +N_style +N_vertices +N_visitedfillcolor +N_visitedpencolor +N_width +N_z +Ndim +neato_closest +new_queue +new_spline +newPM +newPS +nodeInduce +Nop +Output_file_name +yDir +overlap_edge +overlap_label +overlap_node +packGraphs +packSubgraphs +parse_style +pccomps +place_graph_label +place_portlabel +pointsOf +pop_obj_state +processClusterEdges +ps_string +PSinputscale +ptToLine2 +push_obj_state +putGraphs +rank +rect2poly +Reduce +resolvePort +resolvePorts +round_corners +routepolylines +routesplines +routesplinesinit +routesplinesterm +safe_dcl +safefile +scanEntity +selfRightSpace +setAttr +setEdgeType +shape_clip +shapeOf +Show_boxes +Show_cnt +simpleSplineRoute +sizeOf +specificFlags +specificItems +spline_at_y +start_timer +State +strdup_and_subst_obj +Syntax_errors +test_toggle +textfont_dict_open +textfont_dict_close +textspan_size +translate_bb +UF_find +UF_remove +UF_setname +UF_singleton +UF_union +undoClusterEdges +update_bb_bz +updateBB +utf8ToLatin1 +Verbose +Version +write_plain +xml_string +xml_string0 +xml_url_string +Y_invert +zmalloc +zrealloc +strcasecmp +strncasecmp +colorxlate +fix_fc +gvContextPlugins +gvfwrite +gvferror +getPackInfo +getPackModeInfo +parsePackModeInfo +putRects +xdotBB +gvFinalize +gv_postprocess +gvRenderContext +gvflush +gvrender_ptf +setColorScheme +makePortLabels +addEdgeLabels +is_a_cluster +mapBool +drand48 +gvPluginList +EdgeLabelsDone +get_gradient_points +G_margin +openIntSet +mkClustMap +findCluster +rank2 +makeStraightEdge +makeStraightEdges -- 2.40.0