Salome HOME
cmake files
[modules/med.git] / medtool / cmake_files / FindGraphviz.cmake
1 # - Graphviz detection
2 #
3 # Output variables: GRAPHVIZ_EXECUTABLE   - where is executable 'dot' takes place.
4 #                   GRAPHVIZ_INCLUDE_DIRS - where to find headers.
5 #                   GRAPHVIZ_LIBRARIES    - where to get libraries.
6 #                   GRAPHVIZ_VERSION      - Graphviz version
7 #                   GRAPHVIZ_DEFINITIONS  - Graphviz definitions
8 #                   GRAPHVIZ_FOUND        - True if Graphviz was found.
9 #
10 ###########################################################################
11 # Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
12 #
13 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
14 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
15 #
16 # This library is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU Lesser General Public
18 # License as published by the Free Software Foundation; either
19 # version 2.1 of the License, or (at your option) any later version.
20 #
21 # This library is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24 # Lesser General Public License for more details.
25 #
26 # You should have received a copy of the GNU Lesser General Public
27 # License along with this library; if not, write to the Free Software
28 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
29 #
30 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
31 #
32
33 SET(GRAPHVIZ_ROOT_DIR $ENV{GRAPHVIZ_ROOT_DIR} CACHE PATH "Path to the Graphviz.")
34 IF(GRAPHVIZ_ROOT_DIR)
35   LIST(APPEND CMAKE_PREFIX_PATH "${GRAPHVIZ_ROOT_DIR}")
36 ENDIF(GRAPHVIZ_ROOT_DIR)
37
38 FIND_PROGRAM(GRAPHVIZ_EXECUTABLE dot)
39
40 FIND_PATH(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/cgraph.h)
41 SET(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz)
42
43 FIND_LIBRARY(GRAPHVIZ_cdt_LIBRARY      NAMES cdt PATH_SUFFIXES bin)
44 FIND_LIBRARY(GRAPHVIZ_graph_LIBRARY    NAMES cgraph PATH_SUFFIXES bin)
45 FIND_LIBRARY(GRAPHVIZ_gvc_LIBRARY      NAMES gvc PATH_SUFFIXES bin)
46 FIND_LIBRARY(GRAPHVIZ_pathplan_LIBRARY NAMES pathplan PATH_SUFFIXES bin)
47
48 SET(GRAPHVIZ_LIBRARIES
49   ${GRAPHVIZ_cdt_LIBRARY}
50   ${GRAPHVIZ_graph_LIBRARY}
51   ${GRAPHVIZ_gvc_LIBRARY}
52   ${GRAPHVIZ_pathplan_LIBRARY}
53   )
54
55 IF(GRAPHVIZ_EXECUTABLE)
56   EXECUTE_PROCESS(COMMAND ${GRAPHVIZ_EXECUTABLE} "-V" ERROR_VARIABLE GRAPHVIZ_VERSION ERROR_STRIP_TRAILING_WHITESPACE)
57   STRING(REGEX REPLACE ".* ([0-9.]+) .*" "\\1" GRAPHVIZ_VERSION "${GRAPHVIZ_VERSION}")
58 ENDIF()
59
60 SET(GRAPHVIZ_DEFINITIONS)
61 IF("${GRAPHVIZ_VERSION}" VERSION_LESS "2.36.0")
62   SET(GRAPHVIZ_DEFINITIONS -DWITH_CGRAPH)
63 ENDIF()
64
65 ## Don't detect cgraph on Windows
66 #IF(NOT WIN32)
67 #  FIND_LIBRARY(GRAPHVIZ_cgraph_LIBRARY   NAMES cgraph PATH_SUFFIXES bin)
68 #  SET(GRAPHVIZ_LIBRARIES ${GRAPHVIZ_cgraph_LIBRARY})
69 #ENDIF()
70
71 # Handle the standard arguments of the find_package() command:
72 INCLUDE(FindPackageHandleStandardArgs)
73 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Graphviz REQUIRED_VARS
74                                            GRAPHVIZ_EXECUTABLE
75                                            GRAPHVIZ_LIBRARIES
76                                            GRAPHVIZ_INCLUDE_DIRS)