[CMake] CMAKE_CURRENT_SOURCE_DIR with different values: bug?

Bruno Nery bnery at isr.ist.utl.pt
Thu Jun 18 10:18:04 EDT 2009


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?

    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.

thanks,

--
Bruno Nery



On Thu, Jun 18, 2009 at 12:34 PM, Bruno Nery<bnery at isr.ist.utl.pt> wrote:
> Hello Alex,
>
>    thanks for the help - it works now. :)
>
> []s,
>
> --
> Bruno Nery
>
>
>
> 2009/6/17 Alexander Neundorf <a.neundorf-work at gmx.net>:
>> On Monday 15 June 2009, Bruno Nery wrote:
>>> Hello,
>>>
>>>    This problem happens when I need to use ${CMAKE_CURRENT_SOURCE_DIR}
>>> inside a script, but for an out-of-source build. When echoed from the
>>> CMakeLists.txt file, it outputs the right value (i.e., the source
>>> folder) However, when echoed from inside the script, it outputs the
>>> build folder name (source folder/build). Attached is a "Hello World"
>>> project that reproduces the bug (if it's really a bug) - could anyone
>>> please verify it? CMake version is 2.4.6.
>>
>> It's not a bug, it's a feature.
>> No, seriously, it's exptected behaviour.
>> The script is executed by another cmake, and for that cmake
>> CMAKE_CURRENT_SOURCE_DIR is independent from the CMAKE_CURRENT_SOURCE_DIR in
>> the cmake which is processing the CMakeLists.txt.
>> You can set variables for the script:
>> add_custom_command(OUTPUT ...
>>  COMMAND
>> ${CMAKE_COMMAND} -DMY_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -Pmyscript.cmake )
>>
>> and then use MY_CURRENT_SOURCE_DIR in myscript.cmake
>>
>> Alex
>> _______________________________________________
>> 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
>


More information about the CMake mailing list