[CMake] Any portable way in CMake build tree to find Source tree path?

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Fri Jan 25 18:13:44 EST 2013


Hi Kent,

On all the platform, the build tree contains a CMakeCache.txt that will
systematically contain the following text:

     FOO_SOURCE_DIR:STATIC=/path/to/foosource

where FOO is the name of the project.

You could simply check for the existence of "CMakeCache.txt", and extact
the value using a regex.

Hth
Jc




On Fri, Jan 25, 2013 at 5:41 PM, Kent Williams <nkwmailinglists at gmail.com>wrote:

> I'm trying to write a Find<package>.cmake file for a library that doesn't
> generate a proper <package>Config.cmake file.
>
> The problem I'm trying to solve is how to build against a build tree
> instead of an install tree.  On OS X and Windows (well, probably any
> Makefile generator) CMake helpfully adds CMakeDirectoryInformation.cmake
> files to the build tree, which makes it straightforward to recover the root
> of the source tree.
>
> Come to find out, that doesn't work on Windows with Visual Studio build
> system, and probably won't work with other build systems besides Makefile
> on OS X and Linux.
>
> So the question is, given that I can't go in and fix the CMake build
> system for this package, is there a portable way to find the source tree by
> looking at the build tree?
>
> --
>
> 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
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130125/c826ae0d/attachment.htm>


More information about the CMake mailing list