[CMake] map structure on cmake script

2007-12-17 Thread Rodolfo Schulz de Lima

Alexander Neundorf escreveu:


Yes, you can get map-like behaviour by using just variables:
SET(MY_MAP_${KEY} myValue)


That's fine if ${KEY} doesn't have spaces nor characters that aren't 
allowed in variable names. As I'm using a string containing compiler 
flags and stuff, this solution isn't possible. A workaround would be 
computing a hash from the string and using it as a key, but once again, 
it'd be a pain in the *** to do it in cmake script.


Regards,
rod

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] map structure on cmake script

2007-12-17 Thread Brandon Van Every
On Dec 17, 2007 2:29 PM, Rodolfo Schulz de Lima [EMAIL PROTECTED] wrote:
 A workaround would be
 computing a hash from the string and using it as a key, but once again,
 it'd be a pain in the *** to do it in cmake script.

I wouldn't shy away from trying it though.  I wrote a regex negation
operator in CMake script to work around CMake's limitations.  The
algorithm for negation construction had some complications, but it
wasn't rocket science.  The code wasn't that long in the scheme of
things, and the speed was just fine.  You might not expect acceptable
performance from a mere scripting language, but on a 2 GHz machine it
mostly doesn't matter.  I've also been surprised at how many regexes I
can throw at a variable over and over and over again, without
degrading performance too badly.  You can use a homebrew hash as a
prototypical basis for a more official CMake capability someday.  In
my case, because I wrote the regex negation operator and other
string handling extensions, I have a pretty good idea what a
PCRE-based regex interface should look like.


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] map structure on cmake script

2007-12-17 Thread Alexander Neundorf
On Monday 17 December 2007, Rodolfo Schulz de Lima wrote:
 Alexander Neundorf escreveu:
  Yes, you can get map-like behaviour by using just variables:
  SET(MY_MAP_${KEY} myValue)

 That's fine if ${KEY} doesn't have spaces nor characters that aren't
 allowed in variable names. As I'm using a string containing compiler
 flags and stuff, this solution isn't possible. A workaround would be

The following code works for me:

# create a  strange variable name and put it into tmp
set(tmp - - / ' hallo welt)
#assign a value to that strange var
set(${tmp} blub)
# print the value
message(STATUS value: -${${tmp}}-)
#assign it to another var
set(tmp2 ${${tmp}})
message(STATUS tmp2: -${tmp2}-)

After all, inside cmake the variables are simple a std::mapstd::string, 
std::string .

Alex
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake