View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009851CMakeCMakepublic2009-11-06 03:142010-11-05 12:13
ReporterMarcel Loose 
Assigned ToDavid Cole 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in VersionCMake 2.8.3 
Summary0009851: string(RANDOM) does not produce random string within a CMake run
DescriptionI 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
Additional InformationAccording to David Cole this is caused by the fact that the random generator is seeded on every call to string(RANDOM...) using a one-second resolution time value as seed.

Solution: only seed the random generator once.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0018362)
David Cole (manager)
2009-11-06 10:20

Fix issue 0009851 - only seed the random number generator on the first call to STRING(RANDOM or if given the new RANDOM_SEED argument. Add test and documentation of new argument.

Source/cmStringCommand.cxx Revision: 1.32
Source/cmStringCommand.h Revision: 1.31
Tests/CMakeTests/StringTestScript.cmake Revision: 1.3
(0022899)
Marcel Loose (developer)
2010-11-05 12:13

I verified that this is now OK with 2.8.3.

 Issue History
Date Modified Username Field Change
2009-11-06 03:14 Marcel Loose New Issue
2009-11-06 09:27 Bill Hoffman Status new => assigned
2009-11-06 09:27 Bill Hoffman Assigned To => David Cole
2009-11-06 10:20 David Cole Note Added: 0018362
2009-11-06 10:20 David Cole Status assigned => resolved
2009-11-06 10:20 David Cole Resolution open => fixed
2010-11-05 12:13 Marcel Loose Note Added: 0022899
2010-11-05 12:13 Marcel Loose Status resolved => closed
2010-11-05 12:13 Marcel Loose Fixed in Version => CMake 2.8.3


Copyright © 2000 - 2018 MantisBT Team