[CMake] Help Accommodating Ninja when including CMAKE_CURRENT_BINARY_DIR

Stephen McDowell sjm324 at cornell.edu
Fri Apr 27 05:19:45 EDT 2018


Upon further inspection, it seems more related to PRE_BUILD.  The step to generating the files is through a add_custom_command call, which from the docs apparently may end up being PRE_LINK.

I tried generating into the ${CMAKE_CURRENT_SOURCE}/include/nanogui, which will work for Makefiles but not for Ninja.

So it seems that maybe this is not a pathing issue at all, but instead an order of operations issue.  If the Ninja generator ends up having this as PRE_LINK, the files haven’t been generated yet.

That doesn’t quite explain why it worked previously, but perhaps the original setup was inherently flawed by relying on PRE_BUILD which is not a guaranteed order.

Does anybody have thoughts on how to change things?  The files cannot be compiled on their own, but maybe I should instead create a fake target and make it a dependency of the real (object) library that needs them.  I keep messing that up, but this seems the most promising.

-Stephen



More information about the CMake mailing list