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

Cory Quammen cquammen at cs.unc.edu
Sat Jan 26 09:48:05 EST 2013


Oops, I didn't know about that command. I tried it out, and it works
like a charm.

Thanks for pointing it out, Alex!

Cory

On Sat, Jan 26, 2013 at 3:25 AM, Alexander Neundorf
<a.neundorf-work at gmx.net> wrote:
> 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



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill


More information about the CMake mailing list