[CMake] Using CMake include does not seem to work intuatively

Saad Khattak saadrustam at gmail.com
Tue Dec 12 19:34:35 EST 2017


Hi,

Let's say I have the following directory structure:
~/Repos/MyRepo/CMakeLists.txt
~/CMakeFiles/Foo.cmake
~/CMakeFiles/Bar.cmake

In the CMakeLists.txt I have the following command:

include(~/CMakeFiles/Foo.cmake)

And in Foo.cmake I have the following command:

include(Bar.cmake)

Turns out that he `include(Bar.cmake)` from `Foo.cmake` fails. This is
counter to what I would expect (e.g. how #include works in C).

Is this a bug or is this behavior expected? If it's expected, what is the
workaround? We have a lot of common cmake files which in turn include files
relative to each other and not the calling CMakeLists.txt.

Thank you,
Saad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171213/dc81881c/attachment.html>


More information about the CMake mailing list