[CMake] string(RANDOM) bug?
David Cole
david.cole at kitware.com
Thu Nov 5 11:14:58 EST 2009
The problem is that srand is called *each* time that STRING(RANDOM is
invoked... And it is based on the current time stamp to the nearest second.
(Not exactly random if it's exactly correlated to what second it currently
is...)
I agree, this is a bug.
Would you submit a bug report in the bug tracker?
Would anyone object to changing this to call srand only on the very first
call to STRING(RANDOM in a given invocation of cmake? (Or does somebody have
a better suggestion? Perhaps passing the seed value in as an optional
parameter...?)
Thx,
David
On Thu, Nov 5, 2009 at 8:41 AM, Marcel Loose <loose at astron.nl> wrote:
> Hi all,
>
> I expected that string(RANDOM...) would produce a different string each
> time it is invoked. Turns out that this string is only different between
> different cmake runs. This is not what I expected. IMHO this is a bug,
> either in the code, or in the documentation.
>
> $ cat ../CMakeLists.txt
> project(Dummy NONE)
> cmake_minimum_required(VERSION 2.6)
> string(RANDOM a)
> string(RANDOM b)
> message(STATUS "a=${a}")
> message(STATUS "b=${b}")
>
> $ cmake ..
> -- a=PgDGb
> -- b=PgDGb
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /tmp/loose/cmake/build
>
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091105/0deff94c/attachment.htm>
More information about the CMake
mailing list