4

I'm working in an Xcode project created using CMake. I would like to be able to automatically create an environment variable in Xcode using CMake commands, but it doesn't appear to work.

In my .profile I have

export WORKDIR=$HOME/temp/working

and I would like to have it appear in Xcode as an environment variable such as the follow picture (or equivalent)

screenshot

so that I can load it in C++ using the following:

auto workdir  = std::getenv("WORKDIR");

I tried using the following command:

set($ENV{WORKDIR} ${WORKDIR}) 

but it didn't seem to help. Any ideas?

1 Answer 1

2

Set it as the following in an initial cache file

set(CMAKE_XCODE_SCHEME_ENVIRONMENT
  ASAN_OPTIONS=$ENV{ASAN_OPTIONS}
  LSAN_OPTIONS=$ENV{LSAN_OPTIONS} CACHE STRING "" FORCE)

to be used as cmake -C thefile.cmake -G Xcode ..

or

-DCMAKE_XCODE_SCHEME_ENVIRONMENT="ASAN_OPTIONS=${ASAN_OPTIONS};LSAN_OPTIONS=${LSAN_OPTIONS}"

to be used by passing it to cmake directly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.