[CMake] Best way to Generate String
Mateusz Loskot
mateusz at loskot.net
Sat Mar 6 12:39:27 EST 2010
Aaron_Wright at selinc.com wrote:
> Is this the best way to generate a comment bar, such as this:
>
> ////////////////////////////////////////////////////////////////////////////////
>
> or this:
>
> --------------------------------------------------------------------------------
>
> or this:
>
> ################################################################################
>
> IF(OUTPUT_FILE_EXT MATCHES "^\\.h|\\.cpp$")
> SET(COMMENT_CHARACTER "/")
> ELSEIF(OUTPUT_FILE_EXT MATCHES "^\\.sql$")
> SET(COMMENT_CHARACTER "-")
> ELSEIF(OUTPUT_FILE_EXT MATCHES "^\\.nsi|\\.nsh$")
> SET(COMMENT_CHARACTER "#")
> ELSE()
> MESSAGE(WARNING "Unknown file type")
> ENDIF()
>
> STRING(RANDOM LENGTH 80 ALPHABET "${COMMENT_CHARACTER}" COMMENT_BAR)
IMHO, it looks OK.
> The only reason I ask is that is seems weird to use the STRING(RANDOM
> function to get this done.
The RANDOM is just a generalized generator.
In your case, you specify one-character alphabet
and it is still a random string of values from one element interval.
I don't see anything strange here myself.
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
More information about the CMake
mailing list