Resolve CMake Dependency Circle
pasbi opened this issue · 0 comments
omm has quite a few custom CMake-targets, some of which strongly depend on others.
For example:
The main application ommpfritt
depends on libommpfritt
and resources
.
resources
contains icons, which are built by ommpfritt itself. Hence, there is a intermediate target ommpfritt-cli
, that does not require resources
, but can build the icons.
ommpfritt-cli
depends on resources-cli
(like resources
, but without icons) and libommpfritt
.
resources
depends i.a. on compiled translation files (*.qm
), which are built in other targets.
A valid build order would be (just an incomplete illustration)
resources
libommpfritt
ommpfritt-cli
resources
ommpfritt
install
andpackage
You can use GraphViz to visualize the full target dependency graph, I recommend options GRAPHVIZ_CUSTOM_TARGETS=TRUE
and GRAPHVIZ_EXTERNAL_LIBS=FALSE
.
This works fine when configuring and building the project for the first time.
However, once the build has started (and it is aborted after few seconds or finishes), it's not possible to configure it (i.e., call cmake
) again, because cmake
will report a depdency cycle.
I don't understand how building the project introduces cycles.
Removing some files is a workaround, but it is time-consuming (not as much as doing a complete rebuild, though) and not very elegant.
cd $build_directory
rm -rf libommpfritt_autogen \
qm qrc_resources_cli.cpp libommpfritt_autogen \
ommpfritt-cli_autogen ommpfritt_unit_tests_autogen \
ommpfritt_autogen qrc_resources.cpp