I have the need to access a bash associative array element via cmake. So assume that my declaration and access was something like the following in bash:
~ declare -x someText=124 ~ echo $someText 124 ~ declare -A mymap=( [foo]=bar [baz]=quux) ~ echo ${mymap[foo]} bar Access in CMakeLists.txt would be:
message(STATUS "$ENV{someText}) message(STATUS "$ENV{mymap}) when I run cmake I get the following:
-- 124 -- So, the associative array cannot be accessed via the $ENV{} cmake command. Any ideas how to access it? To be specific, I don't care about the complete associative array, just one element in it.
bash -copens a sub-shell, the arraymymapdefined in the first command won't be available in the secondechobash -copens a chid process, its not a sub-shell. A sub-shell is where existing variables (and other resources) are copied to the child whether they are exported or not. Since the parent (cmake) is not bash then it can't create a bash sub-shell.