Hi Saad. I can't comment on whether the behaviour is correct or expectable, but to get it working the way you want, you can specify the path fully:
include(${CMAKE_CURRENT_LIST_DIR}/Bar.cmake) Petr On 13 December 2017 at 01:34, Saad Khattak <saadrus...@gmail.com> wrote: > 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 > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/ > opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake