Incorrectly ordered dependency for imported target with Ninja generator
If a dependency is added to an imported target then the Ninja generator does not appear to wire up this dependency before the dependency on the actual imported binary (IMPORTED_LOCATION
).
This means if the binary itself depends on something then that does not get evaluated, resulting in a build failure.
There are many ways this could be caused, but the provided example reproduces the issue via a symbolic link to the imported library location.
Steps:
- Create a build (binary) dir.
-
cmake <path-to-example> -G Ninja
(configure) -
ninja
(build) -
rm indirection
(remove symlink) -
ninja
(rebuild)
It can be seen in the build.ninja file that the symlink dependency follows the imported library binary dependency.
The GNU Makefiles generator does not have the same problem (the symlink is correctly re-created).
A workaround for the Ninja generator is to wire up an extra explicit rule on the imported binary (provided in example).
CMakeLists.txt