Killrazor
Killrazor

Reputation: 7184

where does CMAKE get environment variables?

If I type in console:

$ echo $COCOS_ROOT

I get the correct path because I have this variable defined in my .bashrc file. However, when I execute this code,

SET(COCOS_HOME "$ENV{COCOS_ROOT}")
if (COCOS_HOME)
    message( STATUS "COCOS2D installed in" ${COCOS_HOME})
else()
    message( WARNING "COCOS2D is undefined")
endif()

The environment var is not defined. If I define the ENV var in console making:

$ export COCOS_ROOT=/path/to/cocos

Then the script is correctly set with cocos2D path.

My question is: where do I need to define the env vars to be found by cmake?

Thanks

Upvotes: 4

Views: 3007

Answers (1)

Guillaume
Guillaume

Reputation: 10971

In your .bashrc file you need to export the COCOS_ROOT variable, otherwise it's not passed to child processes:

export COCOS_ROOT=/path/to/cocos

and not

COCOS_ROOT=/path/to/cocos

Your COCO_ROOT is available in your shell because the .bashrc file is loaded when your shell starts.

Upvotes: 6

Related Questions