Skip to content

Commit

Permalink
chore: Refactor into vcpkg overlays
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Jan 7, 2023
1 parent 1dc88d6 commit 5b5f2c0
Show file tree
Hide file tree
Showing 40 changed files with 465 additions and 1,198 deletions.
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@
"install-emsdk": "run-script-os",
"install-emsdk:linux": "./scripts/cpp-install-emsdk.sh",
"install-emsdk:win32": "wsl -e ./scripts/cpp-install-emsdk.sh",
"install-graphviz": "run-script-os",
"install-graphviz:linux": "./scripts/cpp-install-graphviz.sh",
"install-graphviz:win32": "wsl -e ./scripts/cpp-install-graphviz.sh",
"install-vcpkg": "run-script-os",
"install-vcpkg:linux": "./scripts/cpp-install-vcpkg.sh",
"install-vcpkg:win32": "wsl -e ./scripts/cpp-install-vcpkg.sh",
"install-build-deps": "run-p install-emsdk install-graphviz install-vcpkg",
"uninstall-build-deps": "rimraf ./emsdk ./third-party/graphviz ./vcpkg ./src-expat ./src-vcpkg",
"install-build-deps": "run-p install-emsdk install-vcpkg",
"uninstall-build-deps": "rimraf ./emsdk ./vcpkg ./src-expat ./src-vcpkg",
"clean-build": "rimraf .nyc_output bin build coverage dist* lib* output-* tmp types *.tsbuildinfo",
"clean-docs": "rimraf docs/.vitepress/dist docs/classes docs/interfaces docs/modules docs/.nojekyll docs/README.md",
"clean": "run-p clean-build clean-docs",
Expand Down Expand Up @@ -170,4 +167,4 @@
"url": "https://github.com/hpcc-systems/hpcc-js-wasm/issues"
},
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/"
}
}
22 changes: 0 additions & 22 deletions scripts/cpp-install-graphviz.sh

This file was deleted.

188 changes: 119 additions & 69 deletions src-cpp/graphviz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,76 +1,126 @@
project(graphlayout)
project(graphvizlib)

# find and link libraries
find_path(Graphviz_INCLUDE_DIRS NAMES graphviz/gvc.h HINTS "${VCPKG_INSTALLED_DIR}" REQUIRED)

# display directories where Graphviz libraries and headers are found
message("Graphviz libraries: ${graphviz_LIBRARIES}")
message("Graphviz include directories: ${Graphviz_INCLUDE_DIRS}")

find_package(expat CONFIG REQUIRED)

set(GRAPHVIZ_LIB_DIR "${GRAPHVIZ_DIR}/lib")
set(GRAPHVIZ_PLUGIN_DIR "${GRAPHVIZ_DIR}/plugin")
set(GRAPHVIZ_BUILD_DIR "${GRAPHVIZ_DIR}/build")
# See: https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
string(REPLACE ";" " " CPP_FLAGS "${EM_CPP_FLAGS}")

set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-sFILESYSTEM=1"
"-sEXPORT_NAME='${CMAKE_PROJECT_NAME}'"
"-sEXPORTED_FUNCTIONS=\"['_free', '_malloc']\""
"-sEXPORTED_RUNTIME_METHODS=\"[]\""
"--post-js ${CMAKE_CURRENT_BINARY_DIR}/main_glue.js"
)
string(REPLACE ";" " " LINK_FLAGS "${EM_LINK_FLAGS}")

# Generate Glue from IDL file ---
add_custom_command(
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/main.idl
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main_glue.js ${CMAKE_CURRENT_BINARY_DIR}/main_glue.cpp
COMMAND python3 ${CMAKE_BINARY_DIR}/../emsdk/upstream/emscripten/tools/webidl_binder.py ${CMAKE_CURRENT_SOURCE_DIR}/main.idl ${CMAKE_CURRENT_BINARY_DIR}/main_glue
)
set_property(SOURCE main.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/main_glue.cpp)
# --- --- ---

set(SRCS
main.cpp
)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${VCPKG_INCLUDE_DIR}
${Graphviz_INCLUDE_DIRS}/graphviz
${CMAKE_CURRENT_BINARY_DIR}
)

# =============================== Build options ================================
option(enable_ltdl "Support on-demand plugin loading" OFF)
option(with_expat "Support HTML-like labels through expat" 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)." ON )
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)
option(with_zlib "Support raster image compression through zlib" OFF)
option(use_coverage "enables analyzing code coverage" OFF)
option(with_cxx_api "enables building the C++ API" ON)
option(with_cxx_tests "enables building the C++ tests" OFF)
option(use_win_pre_inst_libs "enables building using pre-installed Windows libraries" OFF)

if(with_digcola)
add_definitions(-DDIGCOLA)
endif()

if(with_ipsepcola)
add_definitions(-DIPSEPCOLA)
endif()

if(with_ortho)
add_definitions(-DORTHO)
endif()

if(with_sfdp)
add_definitions(-DSFDP)
endif()

# ===================== Append local CMake module directory ====================
list(APPEND CMAKE_MODULE_PATH "${GRAPHVIZ_DIR}/cmake")

# find_package(ANN)

# find_package(CAIRO)

if(with_expat)
find_package(EXPAT)
endif()

# find_package(GD)

if(enable_ltdl)
find_package(LTDL)
if(LTDL_FOUND)
add_definitions(-DENABLE_LTDL)
endif()
endif()

# find_package(PANGOCAIRO)

if(with_zlib)
find_package(ZLIB)
endif()

# if(UNIX)
# find_library(MATH_LIB m)
# link_libraries(${MATH_LIB})
# endif()
add_subdirectory(lib)
add_subdirectory(plugin)
add_subdirectory(graphvizlib)
add_executable(graphvizlib
${SRCS}
)

set_target_properties(graphvizlib PROPERTIES COMPILE_FLAGS "${CPP_FLAGS}")
set_target_properties(graphvizlib PROPERTIES LINK_FLAGS "${LINK_FLAGS}")

# link libraries
function(add_graphviz_library library)
find_library(GRAPHVIZ_${library} NAMES ${library})
if(GRAPHVIZ_${library})
target_link_libraries(graphvizlib PRIVATE ${GRAPHVIZ_${library}})
else()
message(FATAL_ERROR "Could not find library ${library}!")
endif()
endfunction()

# common gvplugin_core gvplugin_dot_layout gvplugin_neato_layout ortho gvc cdt cgraph dotgen neatogen fdpgen sfdpgen twopigen circogen label osage patchwork pack sparse pathplan xdot
add_graphviz_library(common)
add_graphviz_library(gvc)
add_graphviz_library(gvplugin_core)
add_graphviz_library(gvplugin_dot_layout)
add_graphviz_library(gvplugin_neato_layout)
add_graphviz_library(ortho)
add_graphviz_library(cdt)
add_graphviz_library(cgraph)
add_graphviz_library(dotgen)
add_graphviz_library(neatogen)
add_graphviz_library(fdpgen)
add_graphviz_library(sfdpgen)
add_graphviz_library(twopigen)
add_graphviz_library(circogen)
add_graphviz_library(label)
add_graphviz_library(osage)
add_graphviz_library(patchwork)
add_graphviz_library(pack)
add_graphviz_library(sparse)
add_graphviz_library(pathplan)
add_graphviz_library(xdot)

target_link_libraries(graphvizlib PRIVATE
${EXPAT_LIBRARIES}
)

packWasm(graphvizlib)

# add_executable(graphvizlib-web
# ${SRCS}
# )

# set_target_properties(graphvizlib-web PROPERTIES LINK_FLAGS "${LINK_FLAGS} -s ENVIRONMENT=web")

# target_link_libraries(graphvizlib-web PRIVATE
# gvplugin_core
# gvplugin_dot_layout
# gvplugin_neato_layout
# ortho
# )

# add_executable(graphvizlib-worker
# ${SRCS}
# )

# set_target_properties(graphvizlib-worker PROPERTIES LINK_FLAGS "${LINK_FLAGS} -s ENVIRONMENT=worker")

# target_link_libraries(graphvizlib-worker PRIVATE
# gvplugin_core
# gvplugin_dot_layout
# gvplugin_neato_layout
# ortho
# )

# add_executable(graphvizlib-node
# ${SRCS}
# )

# set_target_properties(graphvizlib-node PROPERTIES LINK_FLAGS "${LINK_FLAGS} -s ENVIRONMENT=node")

# target_link_libraries(graphvizlib-node PRIVATE
# gvplugin_core
# gvplugin_dot_layout
# gvplugin_neato_layout
# ortho
# )
2 changes: 0 additions & 2 deletions src-cpp/graphviz/config.h

This file was deleted.

96 changes: 0 additions & 96 deletions src-cpp/graphviz/graphvizlib/CMakeLists.txt

This file was deleted.

39 changes: 0 additions & 39 deletions src-cpp/graphviz/lib/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 5b5f2c0

Please sign in to comment.