[CMake] variable inheritance

David Cole david.cole at kitware.com
Thu May 3 10:21:50 EDT 2012


I think it qualifies as a bug because it's somewhat unexpected. The
question is: can we fix it without disrupting people who are
accidentally depending on this behavior....

Grr.


David C.


On Thu, May 3, 2012 at 7:01 AM, Patrick Spendrin <ps_ml at gmx.de> wrote:
> Hi,
>
> I just found something new for me, and wondered if this qualifies as a bug:
>
> argv-bug.cmake
> function(testfunc1)
>    message(STATUS "testfunc1: ${ARGV0} ${ARGV1} ${ARGV2}")
>    testfunc2("${ARGV0}")
> endfunction(testfunc1)
>
> function(testfunc2)
>    message(STATUS "testfunc2: ${ARGV0} ${ARGV1} ${ARGV2}")
> endfunction(testfunc2)
>
> testfunc1(para1 para2 para3)
>
> # output:
> # L:\>cmake -P C:\kde\kde-stable\tmp\cmake-argv-bug\argv-bug.cmake
> # -- testfunc1: para1 para2 para3
> # -- testfunc2: para1 para2 para3
>
> It is clear why this happens: since ARGV1 and ARGV2 are not used, they
> do not get overwritten and thus are available in testfunc2. Since ARGVx
> are special variables though, I would think this is a bug?
>
> (I tested 2.8.4, 2.8.7 and 2.8.8, and all versions show this behaviour.)
>
> regards,
> Patrick
> --
>
> 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