0

I am new with CMake, and am using Visual Studio Code with SSH to Linux. In my ~/.bashrc file I have an environment variable exported to a directory path. I have checked it with PRINTENV, and the path is correct. In CMake however the path is undefined. What am I doing wrong? Thanks

    IF(DEFINED ENV{ALPHA_DIR})
        SET(ALPHA_DIR $ENV{ALPHA_DIR})
    ELSEIF(NOT DEFINED ALPHA_DIR OR ALPHA_DIR STREQUAL "NOT-SET")
        SET(ALPHA_DIR "NOT-SET" CACHE PATH "ALPHA_DIR directory")
        MESSAGE( FATAL_ERROR "** Please add the variable 'ALPHA_DIR'")
    ENDIF()

with the output generated:

CMake Error at CMakeLists.txt:37 (MESSAGE): ** Please add the variable 'ALPHA_DIR'
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
marc6h
  • 1
  • 1
  • Welcome to Stack Overflow! What happens when your CMake runs? Does it print `** Please add the variable 'ALPHA_DIR'`? Or is there an error? – Kevin Apr 13 '20 at 15:33
  • Hi, thanks. I get "CMake Error at CMakeLists.txt:37 (MESSAGE): ** Please add the variable 'ALPHA_DIR'" – marc6h Apr 13 '20 at 15:49
  • What version of CMake are you using? And please show the commands you use to call CMake. Are you running from the command line? Or from within VS Code? – Kevin Apr 13 '20 at 15:50
  • CMake version is 3.14.5. It's called from within VS Code. It's just "cmake " – marc6h Apr 13 '20 at 16:04
  • You may need to set the environment variable in your `launch.json` config file. See this [response](https://stackoverflow.com/a/48609350/3987854). – Kevin Apr 13 '20 at 16:15

0 Answers0