[CMake] CMAKE_CURRENT_SOURCE_DIR with different values: bug?

Bruno Nery bnery at isr.ist.utl.pt
Thu Jun 18 07:34:18 EDT 2009


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