[CMake] Any portable way in CMake build tree to find Source tree path?
Alexander Neundorf
a.neundorf-work at gmx.net
Sat Jan 26 03:25:25 EST 2013
On Saturday 26 January 2013, Cory Quammen wrote:
> Kent,
>
> I have a CMake function that may be of interest to you (see attached file).
>
> For your purposes, use it as follows:
>
> GetCMakeCacheValue( "${ABC_BUILD_DIR}" ABC_SOURCE_DIR )
>
> where the project against which you want to build is named "ABC".
>
> The first argument must always be the build directory of a project
> configured with CMake. The second (and an arbitrary number of
> subsequent arguments) are variables whose values you want to retrieve
> from the CMakeCache.txt file.
>
> Assuming everything goes well, two new variables will be defined in
> the scope in which you called GetCMakeCacheValue:
>
> ABC_SOURCE_DIR
> ABC_SOURCE_DIR_TYPE
>
> If there is no entry for ABC_SOURCE_DIR, then the above variables will
> take on the values
>
> ABC_SOURCE_DIR-NOT_FOUND
> ABC_SOURCE_DIR_TYPE-NOT_FOUND
>
> I hope this is useful to you and others. It would be great if CMake
> had similar functionality built in.
Have you tried the load_cache() command ?
According to the documentation it does that, but I haven't used it myself yet.
Alex
More information about the CMake
mailing list