Using environment variables in settings

Answered

 Hi,

 

I have two questions both related to environment variables:

- Is there a way to use environment variables in variables passed to CMake (from Settings/CMake panel) eg -DMY_CMAKE_VARIABLE=$MY_ENVIRONMENT_VARIABLE/lib

- Is there a way to point Clion to a CMake binary via environment variable (Settings/Tools../Toolchain) eg $MY_ENVIRONMENT_VARIABLE/bin/cmake

Thank you!

 

3
3 comments

Hi,

I would like to support the question. Run into the same problem when I add something like

-DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,${TOOLCHAIN_HOME}/lib -L${TOOLCHAIN_HOME}/lib"

to CMake options. Each variable remains in CMakeCache unexpanded - consequently, build fails.

 

When you need to specify a lot of CMake variables with long, sometimes intersecting paths, it gets inconvenient to type it as a plain text and hard to comprehend what the command does.

0
Avatar
Permanently deleted user

Yupp, CLion is very limited because it doesn't support these in the CMake settings.

I cannot even figure why this isn't implemented: we have the environment variable settings, we can add different profiles, not only debug, release or relWithDebInfo but anything. Yet this super easy to implement feature to replace each occurence of a ${BLA} in the CMake settings with a getenv("BLA") or what is defined in the environment setting is not implemented! I cannot believe it!

This feature alone would make cross compilation possible without hassle. The next thing CLion is not able to do is to find which compiler is used with the current CMake settings if it's not in a standard location, though everything is there inside CMake itself.

Then this half-baked approach with the toolchains: there is no possibility to say where the root filesystem of the used compiler is and it doesn't take the -I includes into account, when statically checking the c++ files: cannot find <vector> ??

Sigh, I use CLion since years. These things are really annoying me since years as well.

0

Please sign in to leave a comment.