[CMake] CMAKE_CURRENT_SOURCE_DIR with different values: bug?

Alexander Neundorf a.neundorf-work at gmx.net
Thu Jun 18 15:29:30 EDT 2009


On Thursday 18 June 2009, Bruno Nery wrote:
> Hello again,
>
>     in fact I thought it worked, but it doesn't. :(
>
>     The thing is that with INSTALL(SCRIPT myscript.cmake) I run a
> script AND install the other files (specified with INSTALL(FILES ...),
> for example). With add_custom_command(...), I'm able to call the
> script with the MY_CURRENT_SOURCE_DIR variable but the custom command
> is not called when I "make install". Is there a way to run a script
> along with other installation procedures and at the same time passing
> a MY_CURRENT_SOURCE_DIR variable?

You mean you need to set some variables for the script executed via 
INSTALL(SCRIPT) ?
I think this is currently not possible.
You can file a feature request for this in the cmake bug tracker:
http://public.kitware.com/Bug/

But what you can do, is you can either use configure_file() to generate the 
script which will be executed by install(SCRIPT), and by doing this set some 
variables, or you make the script include an additional small cmake script 
file, and you use configure_file() to create this small file (which would 
basically only contain set() commands I guess).

>     I also tried with "SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
> CACHE STRING "SOURCE_DIR")" but MY_CURRENT_SOURCE_DIR doesn't appear
> on the script.

Yes, in script mode cmake doesn't read any cache. It's more or less like a 
normal interpreter then.

Alex


More information about the CMake mailing list