[CMake] Using cache in -P scripts?
Abe Stephens
abe at sci.utah.edu
Thu Oct 23 14:05:08 EDT 2008
Hi, Thanks for the reply. But perhaps I should clarify--I'd like to
avoid using lots and lots of -D arguments. So instead of doing
something like this:
add_custom_command(
output file1.cc
command ${CMAKE_COMMAND}
args -D var0="${cached0}"
-D var1="${cached1}"
...
-D var127="${cached127}"
-P myscript.cmake
)
It would be great if there was a simple way to just load the cache
within myscript.cmake. I think it would be possible to write a macro
to read in the cache file and parse it, but I'm curious if there is an
existing mechanism.
--Thanks
Abe
On Oct 23, 2008, at 2:19 AM, Mathieu Malaterre wrote:
> On Thu, Oct 23, 2008 at 5:53 AM, Abe Stephens <abe at sci.utah.edu>
> wrote:
>> Hi, Is it possible for a script executed during build (via custom
>> command of
>> cmake -P) to load and read values from the project's CMakeCache.txt
>> file? I
>> tried using load_cache in the script, but apparently that isn't
>> allowed.
>>
>
> You are looking for "-D", warning it needs to be passed *before* -P
>
> -P <file>
> Process script mode.
>
> Process the given cmake file as a script written in
> the CMake
> language. No configure or generate step is
> performed and the
> cache is not modified. If variables are defined using -
> D, this
> must be done before the -P argument.
>
> 2cts
> --
> Mathieu
More information about the CMake
mailing list