[CMake] Relative include() calls

Robert Dailey rcdailey at gmail.com
Thu May 28 11:42:03 EDT 2009


Yeah I already knew about CMAKE_MODULE_PATH, however I had forgotten that
cmake modules are merely put in-place and then executed. So,
CMAKE_MODULE_PATH seems to be the only choice here.
The most annoying thing about this solution, though, is that every single
CMakeLists.txt that includes this module needs to make sure it has
CMAKE_MODULE_PATH setup properly. It's just a bit redundant and
tedious.

Thanks for the help guys.

On Thu, May 28, 2009 at 2:43 AM, Marcel Loose <loose at astron.nl> wrote:

> Hmm,
>
> I guess the original question referred to cmake modules (at least that's
> what I figured from the file names). Have you tried to set
> CMAKE_MODULE_PATH. Then you don't need any relative paths anymore.
>
> Best regards,
> Marcel Loose.
>
> -----Original Message-----
> From: Adolfo Rodríguez <dofo79 at gmail.com>
> To: Tyler Roscoe <tyler at cryptio.net>
> Cc: cmake <cmake at cmake.org>
> Subject: Re: [CMake] Relative include() calls
> Date: Thu, 28 May 2009 09:36:33 +0200
>
>
>
> On Thu, May 28, 2009 at 7:16 AM, Tyler Roscoe <tyler at cryptio.net> wrote:
>        On Wed, May 27, 2009 at 11:27:28PM -0500, Robert Dailey wrote:
>        > From a CMakeLists.txt in my root source dir, I am calling:
>        > include( ../cmake/common.cmake )
>        >
>        > From common.cmake, I am calling:
>        >
>        > include( BoostUtils.cmake )
>        >
>        > BoostUtils.cmake and common.cmake are side-by-side in the same
>        directory on
>        > Windows. The second call to include() fails, because the
>        working directory
>        > is still set to the directory of the CMakeLists.txt, when I
>        expect the
>
>
>        This is the behavior I would expect. include() is a lot like
>        #include
>        (or :r in vi); it's as though the contents of the included file
>        were
>        dropped into the middle of your CMakeLists.
>
>        Ergo, I would write:
>
>        > include( ../cmake/BoostUtils.cmake )
>
> have you tried using CMAKE_CURRENT_SOURCE_DIR or CMAKE_CURRENT_LIST_FILE
> +extracting the path, i.e.,
>
> include( ${CMAKE_CURRENT_SOURCE_DIR}/BoostUtils.cmake )
>
>
>
>
>
>        If you don't want to write ../cmake all the time, I'm pretty
>        sure
>        there's a variable that controls where CMake will look for
>        things to
>        include().
>
>        tyler
>        _______________________________________________
>        Powered by www.kitware.com
>
>        Visit other Kitware open-source projects at
>        http://www.kitware.com/opensource/opensource.html
>
>        Please keep messages on-topic and check the CMake FAQ at:
>        http://www.cmake.org/Wiki/CMake_FAQ
>
>        Follow this link to subscribe/unsubscribe:
>        http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
> Adolfo Rodríguez Tsouroukdissian
>
> Robotics engineer
> PAL ROBOTICS S.L
> http://www.pal-robotics.com
> Tel. +34.93.414.53.47
> Fax.+34.93.209.11.09
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090528/c23d5ee9/attachment.htm>


More information about the CMake mailing list