]> granicus.if.org Git - graphviz/commit
fix inability to include and use gvc.h from a parent CMake project
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 15 Sep 2021 00:46:30 +0000 (17:46 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 21 Sep 2021 00:01:39 +0000 (17:01 -0700)
commitdcc5ed93775b66339c14f297e35c91f1cf3dd43a
tree3d341d720a73521627119ed61e2b7862e12ad0dd
parent3fc055b2070a413e90442912c554cadbef83c829
fix inability to include and use gvc.h from a parent CMake project

When attempting to declare a dependency on gvc when using Graphviz as a CMake
subproject, the include path necessary to compile gvc headers would not be
propagated to dependent targets. The result would be a compilation error when
the transitive includes of gvc.h could not be found.

To validate this change, create an empty directory and add the following
CMakeLists.txt:

  project(foo)
  add_subdirectory(graphviz)
  add_executable(bar main.c)
  target_link_libraries(bar gvc)

Add the following main.c:

  #include <gvc/gvc.h>
  int main(void) { return 0; }

Clone Graphviz into the subdirectory 'graphviz'. Then the standard CMake steps:

  mkdir build
  cd build
  cmake ..
  make

Note that Graphviz dependencies and then 'bar' are correctly built.

I am not a CMake expert; this was written based on my best guess of what
Graphviz should be doing according to the CMake docs. Assuming this is correct,
other Graphviz targets probably need similar fixes.

Fixes #1477, #2109.
CHANGELOG.md
lib/gvc/CMakeLists.txt