KDAB / KDStateMachineEditor

A framework for creating Qt State Machine metacode using a graphical user interface
https://kdab.github.io/KDStateMachineEditor/
167 stars 32 forks source link

could only build with change in /usr/include/graphviz/types.h #33

Open cg-pasdzierny opened 1 year ago

cg-pasdzierny commented 1 year ago

hello, I am pretty sure my fix is wrong but without changing

 line 49 #include <cgraph.h>

to line 49 #include <graphviz/cgraph.h>

my build stopped with "cgraph.h not found".

I am using red hat rhel 7 with gcc 11.2.1 and graphviz-devel 2.30.1

Thanks, Martin.

winterz commented 1 year ago

which branch are you using? please try master

cg-pasdzierny commented 1 year ago

thanks for the reply. I was using master via git.

cg-pasdzierny commented 1 year ago

git clone https://github.com/KDAB/KDStateMachineEditor.git

winterz commented 1 year ago

strange. I don't see any files in the master branch that contain the line '#include ' which file do you see with that line?

cg-pasdzierny commented 1 year ago

hello, as the title of this thread indicates it was /usr/include/graphviz/types.h which is a graphviz file.

I guess sth went wrong with the include paths passed to the compiler when it happened:

In file included from .../kdab-state-machine-editor/KDStateMachineEditor/src/core/layout/graphvizlayout/gvutils.h:19,
                 from .../kdab-state-machine-editor/KDStateMachineEditor/src/core/layout/graphvizlayout/gvutils.cpp:17:
/usr/include/graphviz/types.h:49:10: fatal error: cgraph.h: No such file or directory
   49 | #include <cgraph.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [src/core/CMakeFiles/kdstatemachineeditor_core.dir/build.make:398: src/core/CMakeFiles/kdstatemachineeditor_core.dir/layout/graphvizlayout/gvutils.cpp.o] Error 1

I attach both the cmake log and the complete make log file. kdab-make-230823-030341.log kdab-cmake-230823-030326.log

As written I managed to sucessfully build by changing the referred graphviz file, but of course that is wrong as it would break other graphviz based builds expecting graphviz devel files as they are ;)

winterz commented 1 year ago

you're right. sorry.

maybe we need to increase the minimum required graphviz version beyond 2.30.1 ?

another possibility is to pass -DWITH_INTERNAL_GRAPHVIZ=True to CMake, which will download and build version 2.48 for you. no idea if that still works

and yet another possibility is to add vcpkg support

ferdnyc commented 8 months ago

@winterz @cg-pasdzierny

It looks to me like the FindGraphviz.cmake discovery code is just wrong.

As written, it will discover the include path for a /usr/include/graphviz/cgraph.h as /usr/include/:

https://github.com/KDAB/KDStateMachineEditor/blob/2567f49288575d837fe7273557fa099a814e274f/cmake/FindGraphviz.cmake#L76-L80

...But the Graphviz pkg-config data has the include path as /usr/include/graphviz. IOW, it expects that the graphviz subdirectory will be on the include path, as @cg-pasdzierny discovered:

$ pkg-config --cflags libcgraph        
-I/usr/include/graphviz

(This is with Graphviz 8.1.0 installed on Fedora 39, but I doubt it's changed anytime recently.)

ferdnyc commented 8 months ago

Looks to me like it should be,

find_path( 
  GRAPHVIZ_INCLUDE_DIR 
  NAMES cgraph.h graph.h 
  HINTS ${_GRAPHVIZ_INCLUDE_DIR}
  PATH_SUFFIXES graphviz
  ${_GRAPHVIZ_FIND_OPTS} 
)

(EDIT: Changed to look for cgraph.h first, as the less generic name.)