|
| 1 | +# - Try to find Graphviz |
| 2 | +# Once done this will define |
| 3 | +# |
| 4 | +# GRAPHVIZ_FOUND - system has Graphviz |
| 5 | +# GRAPHVIZ_INCLUDE_DIRS - Graphviz include directories |
| 6 | +# GRAPHVIZ_CDT_LIBRARY - Graphviz CDT library |
| 7 | +# GRAPHVIZ_GVC_LIBRARY - Graphviz GVC library |
| 8 | +# GRAPHVIZ_CGRAPH_LIBRARY - Graphviz CGRAPH library |
| 9 | +# GRAPHVIZ_PATHPLAN_LIBRARY - Graphviz PATHPLAN library |
| 10 | +# GRAPHVIZ_VERSION - Graphviz version |
| 11 | +# |
| 12 | +# This module reads hints about search locations from the following cmake variables: |
| 13 | +# GRAPHVIZ_ROOT - Graphviz installation prefix |
| 14 | +# (containing bin/, include/, etc.) |
| 15 | + |
| 16 | +# Copyright (c) 2009, Adrien Bustany, <[email protected]> |
| 17 | +# Copyright (c) 2013-2014 Kevin Funk <[email protected]> |
| 18 | + |
| 19 | +# Version computation and some cleanups by Allen Winter <[email protected]> |
| 20 | +# Copyright (c) 2012-2014 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> |
| 21 | + |
| 22 | +# Simplified script by Dogan Can <[email protected]> |
| 23 | +# Copyright (c) 2014 University of Southern California |
| 24 | + |
| 25 | +# Redistribution and use is allowed according to the terms of the GPLv3+ license. |
| 26 | +# Source: https://github.com/usc-sail/barista/blob/master/cmake/FindGraphviz.cmake |
| 27 | + |
| 28 | +if(GRAPHVIZ_ROOT) |
| 29 | + set(_GRAPHVIZ_INCLUDE_DIR ${GRAPHVIZ_ROOT}/include) |
| 30 | + set(_GRAPHVIZ_LIBRARY_DIR ${GRAPHVIZ_ROOT}/lib) |
| 31 | +endif() |
| 32 | + |
| 33 | +find_path(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/cgraph.h |
| 34 | + HINTS ${_GRAPHVIZ_INCLUDE_DIR}) |
| 35 | +find_library(GRAPHVIZ_CDT_LIBRARY NAMES cdt |
| 36 | + HINTS ${_GRAPHVIZ_LIBRARY_DIR}) |
| 37 | +find_library(GRAPHVIZ_GVC_LIBRARY NAMES gvc |
| 38 | + HINTS ${_GRAPHVIZ_LIBRARY_DIR}) |
| 39 | +find_library(GRAPHVIZ_CGRAPH_LIBRARY NAMES cgraph |
| 40 | + HINTS ${_GRAPHVIZ_LIBRARY_DIR}) |
| 41 | +find_library(GRAPHVIZ_PATHPLAN_LIBRARY NAMES pathplan |
| 42 | + HINTS ${_GRAPHVIZ_LIBRARY_DIR}) |
| 43 | + |
| 44 | +if(GRAPHVIZ_INCLUDE_DIR AND GRAPHVIZ_CDT_LIBRARY AND GRAPHVIZ_GVC_LIBRARY |
| 45 | + AND GRAPHVIZ_CGRAPH_LIBRARY AND GRAPHVIZ_PATHPLAN_LIBRARY) |
| 46 | + set(GRAPHVIZ_FOUND TRUE) |
| 47 | +else() |
| 48 | + set(GRAPHVIZ_FOUND FALSE) |
| 49 | +endif() |
| 50 | + |
| 51 | +# Ok, now compute the version |
| 52 | +if(GRAPHVIZ_FOUND) |
| 53 | + set(FIND_GRAPHVIZ_VERSION_SOURCE |
| 54 | + "#include <graphviz/graphviz_version.h>\n#include <stdio.h>\n int main()\n {\n printf(\"%s\",PACKAGE_VERSION);return 1;\n }\n") |
| 55 | + set(FIND_GRAPHVIZ_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindGRAPHVIZ.cxx) |
| 56 | + file(WRITE "${FIND_GRAPHVIZ_VERSION_SOURCE_FILE}" "${FIND_GRAPHVIZ_VERSION_SOURCE}") |
| 57 | + |
| 58 | + set(FIND_GRAPHVIZ_VERSION_ADD_INCLUDES |
| 59 | + "-DINCLUDE_DIRECTORIES:STRING=${GRAPHVIZ_INCLUDE_DIR}") |
| 60 | + |
| 61 | + try_run(RUN_RESULT COMPILE_RESULT |
| 62 | + ${CMAKE_BINARY_DIR} |
| 63 | + ${FIND_GRAPHVIZ_VERSION_SOURCE_FILE} |
| 64 | + CMAKE_FLAGS "${FIND_GRAPHVIZ_VERSION_ADD_INCLUDES}" |
| 65 | + RUN_OUTPUT_VARIABLE GRAPHVIZ_VERSION) |
| 66 | + |
| 67 | + if(COMPILE_RESULT AND RUN_RESULT EQUAL 1) |
| 68 | + message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION}") |
| 69 | + else() |
| 70 | + message(FATAL_ERROR "Unable to compile or run the graphviz version detection program.") |
| 71 | + endif() |
| 72 | + |
| 73 | + set(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz) |
| 74 | + |
| 75 | + if(NOT Graphviz_FIND_QUIETLY) |
| 76 | + message(STATUS "Graphviz include: ${GRAPHVIZ_INCLUDE_DIRS}") |
| 77 | + message(STATUS "Graphviz libraries: ${GRAPHVIZ_CDT_LIBRARY} ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY} ${GRAPHVIZ_PATHPLAN_LIBRARY}") |
| 78 | + endif() |
| 79 | +endif() |
| 80 | + |
| 81 | +if(Graphviz_FIND_REQUIRED AND NOT GRAPHVIZ_FOUND) |
| 82 | + message(FATAL_ERROR "Could not find GraphViz.") |
| 83 | +endif() |
0 commit comments