Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5d89c8faae729d8860a64f37684bb66edef62b31
[simgrid.git] / buildtools / Cmake / Modules / FindGraphviz.cmake
1 find_path(HAVE_CGRAPH_H cgraph.h
2     HINTS
3     $ENV{LD_LIBRARY_PATH}
4     PATH_SUFFIXES include/graphviz include
5     PATHS
6     /opt
7     /opt/local
8     /opt/csw
9     /sw
10     /usr
11 )
12
13 find_path(HAVE_AGRAPH_H agraph.h
14     HINTS
15     $ENV{LD_LIBRARY_PATH}
16     PATH_SUFFIXES include/graphviz include
17     PATHS
18     /opt
19     /opt/local
20     /opt/csw
21     /sw
22     /usr
23 )
24
25 find_path(HAVE_GRAPH_H graph.h
26     HINTS
27     $ENV{LD_LIBRARY_PATH}
28     PATH_SUFFIXES include/graphviz include
29     PATHS
30     /opt
31     /opt/local
32     /opt/csw
33     /sw
34     /usr
35 )
36
37 find_library(HAVE_CGRAPH_LIB
38     NAME cgraph
39     HINTS
40     $ENV{LD_LIBRARY_PATH}
41     PATH_SUFFIXES lib/graphviz lib
42     PATHS
43     /opt
44     /opt/local
45     /opt/csw
46     /sw
47     /usr
48 )  
49
50 find_library(HAVE_AGRAPH_LIB
51     NAME agraph
52     HINTS
53     $ENV{LD_LIBRARY_PATH}
54     PATH_SUFFIXES lib/graphviz lib
55     PATHS
56     /opt
57     /opt/local
58     /opt/csw
59     /sw
60     /usr
61
62
63 find_library(HAVE_GRAPH_LIB
64     NAME graph
65     HINTS
66     $ENV{LD_LIBRARY_PATH}
67     PATH_SUFFIXES lib/graphviz lib
68     PATHS
69     /opt
70     /opt/local
71     /opt/csw
72     /sw
73     /usr
74 )
75
76 find_library(HAVE_CDT_LIB
77     NAME cdt
78     HINTS
79     $ENV{LD_LIBRARY_PATH}
80     PATH_SUFFIXES lib/graphviz lib
81     PATHS
82     /opt
83     /opt/local
84     /opt/csw
85     /sw
86     /usr
87 )
88
89 mark_as_advanced(HAVE_AGRAPH_H)
90 mark_as_advanced(HAVE_CGRAPH_H)                                                                                
91 mark_as_advanced(HAVE_GRAPH_H)                                                                                  
92 mark_as_advanced(HAVE_GRAPH_LIB)
93 mark_as_advanced(HAVE_CGRAPH_LIB)
94 mark_as_advanced(HAVE_AGRAPH_LIB)
95 mark_as_advanced(HAVE_CDT_LIB)
96
97 ### Initialize of cgraph
98 if(HAVE_CDT_LIB)
99 if(HAVE_CGRAPH_LIB OR HAVE_AGRAPH_LIB)
100
101     if(HAVE_AGRAPH_LIB)
102         string(REGEX REPLACE "/libagraph.*" "" lib_graphviz ${HAVE_AGRAPH_LIB})   
103     else(HAVE_AGRAPH_LIB)
104         if(HAVE_CGRAPH_LIB)
105             string(REGEX REPLACE "/libcgraph.*" "" lib_graphviz ${HAVE_CGRAPH_LIB})   
106         endif(HAVE_CGRAPH_LIB)
107     endif(HAVE_AGRAPH_LIB)
108       
109     if(HAVE_GRAPH_H OR HAVE_AGRAPH_H OR HAVE_CGRAPH_H)
110     
111         if(HAVE_GRAPH_H)
112                 string(REPLACE "/graphviz/graph.h" "" file_graphviz_h ${HAVE_GRAPH_H})
113                 string(REPLACE "/graphviz" "" file_graphviz_h ${file_graphviz_h})
114                 set(GRAPH_H 1)
115         endif(HAVE_GRAPH_H)
116         
117         if(HAVE_AGRAPH_H)
118                 string(REPLACE "/graphviz/agraph.h" "" file_graphviz_h ${HAVE_AGRAPH_H})
119                 string(REPLACE "/graphviz" "" file_graphviz_h ${file_graphviz_h})
120                 set(AGRAPH_H 1)
121         endif(HAVE_AGRAPH_H)
122         
123         if(HAVE_CGRAPH_H)
124                 string(REPLACE "/graphviz/cgraph.h" "" file_graphviz_h ${HAVE_CGRAPH_H})
125                 string(REPLACE "/graphviz" "" file_graphviz_h ${file_graphviz_h})
126                 set(CGRAPH_H 1)
127         endif(HAVE_CGRAPH_H)  
128          
129         string(REGEX MATCH "-I${file_graphviz_h} " operation "${CMAKE_C_FLAGS}")
130         if(NOT operation)
131                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${file_graphviz_h} ")
132         endif(NOT operation)
133         
134         string(REGEX MATCH "-I${file_graphviz_h}/graphviz " operation "${CMAKE_C_FLAGS}")
135         if(NOT operation)
136                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${file_graphviz_h}/graphviz ")
137         endif(NOT operation)
138         
139         string(REGEX MATCH "-L${lib_graphviz} " operation "${CMAKE_C_FLAGS}")
140         if(NOT operation)
141                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${lib_graphviz} ")
142         endif(NOT operation)
143         
144         set(HAVE_GRAPHVIZ "1")
145     else(HAVE_GRAPH_H OR HAVE_AGRAPH_H OR HAVE_CGRAPH_H)
146         set(HAVE_GRAPHVIZ "0")
147     endif(HAVE_GRAPH_H OR HAVE_AGRAPH_H OR HAVE_CGRAPH_H)
148     
149 else(HAVE_CGRAPH_LIB OR HAVE_AGRAPH_LIB)
150         set(HAVE_GRAPHVIZ "0")
151 endif(HAVE_CGRAPH_LIB OR HAVE_AGRAPH_LIB)
152
153 endif(HAVE_CDT_LIB)
154
155 mark_as_advanced(HAVE_GRAPHVIZ)
156
157 message(STATUS "Looking for agraph.h")
158 if(HAVE_AGRAPH_H)
159 message(STATUS "Looking for agraph.h - found")
160 else(HAVE_AGRAPH_H)
161 message(STATUS "Looking for agraph.h - not found")
162 endif(HAVE_AGRAPH_H)
163
164 message(STATUS "Looking for cgraph.h")
165 if(HAVE_CGRAPH_H)
166 message(STATUS "Looking for cgraph.h - found")
167 else(HAVE_CGRAPH_H)
168 message(STATUS "Looking for cgraph.h - not found")
169 endif(HAVE_CGRAPH_H)
170
171 message(STATUS "Looking for graph.h")
172 if(HAVE_GRAPH_H)
173 message(STATUS "Looking for graph.h - found")
174 else(HAVE_GRAPH_H)
175 message(STATUS "Looking for graph.h - not found")
176 endif(HAVE_GRAPH_H)
177
178 message(STATUS "Looking for lib agraph")
179 if(HAVE_AGRAPH_LIB)
180 message(STATUS "Looking for lib agraph - found")
181 else(HAVE_AGRAPH_LIB)
182 message(STATUS "Looking for lib agraph - not found")
183 endif(HAVE_AGRAPH_LIB)
184
185 message(STATUS "Looking for lib cgraph")
186 if(HAVE_CGRAPH_LIB)
187 message(STATUS "Looking for lib cgraph - found")
188 else(HAVE_CGRAPH_LIB)
189 message(STATUS "Looking for lib cgraph - not found")
190 endif(HAVE_CGRAPH_LIB)
191
192 message(STATUS "Looking for lib graph")
193 if(HAVE_GRAPH_LIB)
194 message(STATUS "Looking for lib graph - found")
195 else(HAVE_GRAPH_LIB)
196 message(STATUS "Looking for lib graph - not found")
197 endif(HAVE_GRAPH_LIB)
198
199 message(STATUS "Looking for lib cdt")
200 if(HAVE_CDT_LIB)
201 message(STATUS "Looking for lib cdt - found")
202 else(HAVE_CDT_LIB)
203 message(STATUS "Looking for lib cdt - not found")
204 endif(HAVE_CDT_LIB)