[CMake] Help Accommodating Ninja when including CMAKE_CURRENT_BINARY_DIR

Stephen McDowell sjm324 at cornell.edu
Fri Apr 27 03:49:23 EDT 2018


Hello,

I have looked around and seen a few issues discussing this, but have not seen any solutions.

It seems related to this: https://gitlab.kitware.com/cmake/cmake/issues/17450 <https://gitlab.kitware.com/cmake/cmake/issues/17450>

In the sense that absolute paths are desired.

1. Previously, we were generating a file called `${CMAKE_CURRENT_BINARY_DIR}/nanogui_resources.h` and performing `include_directories(${CMAKE_CURRENT_BINARY_DIR})`.

    This **works correctly**.

2. The setup was changed to generate the file `${CMAKE_CURRENT_BINARY_DIR}/nanogui/resources.h`.  That is, the introduction of a new folder `nanogui`.  With the same `include_directories(${CMAKE_CURRENT_BINARY_DIR})`, there is now a failure being unable to find `<nanogui/resources.h>`.

    Strangely, building with `ninja || ninja` (just building again after first failure) will succeed.

I was reading this discussion: https://public.kitware.com/pipermail/cmake-developers/2013-March/018398.html <https://public.kitware.com/pipermail/cmake-developers/2013-March/018398.html>

and the underlying cause seems to be the that Ninja wants relative paths.

Why is creating this sub-directory causing this issue?  Is there a way to keep generating ${CMAKE_CURRENT_BINARY_DIR}/nanogui and be able to include it with Ninja?  I tried forcing a add_definitions(-I${CMAKE_CURRENT_BINARY_DIR}) just for shiggles, but that resulted in the same scenario.  So it seems like I need a way to force a verbatim include path “after” the Ninja generator makes things relative?

Reverting to the old version is not ideal, since it creates installation problems (the reason the subdirectory nanogui was created).

Thank you for any advice!

-Stephen

P.S. This is with CMake 3.11.1 and ninja 1.8.2 if it matters.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180427/94fe098a/attachment.html>


More information about the CMake mailing list