Establish `conda` environment

All the documentation I could find about using a `conda` environment is related to `python`.

I am using `conda` to install C++ tooling like `cmake` and `conan`.
I want to be able to select `conda` environments in `CLion` when doing C++ development.
It seems the approach is to use a script to configure the environment.

The example script referenced is buried in the yocto system.

I found the ticket where the capability was added but I am not finding an example.

I presumed the script is something like the following:

#!/bin/bash -e
conda activate cts
export CMAKE=$(type -p cmake)

...but that does not appear to work.
Could you provide a sample script?



Comment actions Permalink

You can create a symlink for the actual CMake location in the script to a known location, and specify this path to this CMake symlink in CLion's toolchain panel. Does this work?

Comment actions Permalink --
"You can point CLion to the script that initializes the environment for your project without the need to set the variables manually.
This is helpful, for example, when you need to initialize compiler variables, add custom ones, or modify the PATH."

"a toolchain is a set of all the necessary tools required for building and running your application:

  • the CMake executable (CMake projects),
  • the build tool,
  • the C/C++ compilers,
  • the debugger binary, and
  • the working environment."

You are saying the script only directly sets the working environment? 
That is, the other objects in the toolchain may only be indirectly modified by the environment script?

How does Intellij / CLion go about detecting the other elements of the toolchain? It looks like CMake and the debugger must be fully specified (or use the bundled version) and then `cmake` is used to detect the build-tool, c-compiler, c++compiler.
Is this correct?

Comment actions Permalink

Thanks, with a slight modification to your approach I got the desired behavior.
Rather than a symlink I use a ``.

${CMAKE_EXEC} "$@"

In conjunction with the following environment script.

#!/bin/bash --login

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE="/home/me/.local/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/me/micromamba";
__mamba_setup="$('/home/me/.local/bin/micromamba' shell hook --shell bash --prefix '/home/me/micromamba' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
if [ -f "/home/me/micromamba/etc/profile.d/" ]; then
. "/home/me/micromamba/etc/profile.d/"
export PATH="/home/me/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
unset __mamba_setup
# <<< mamba initialize <<<

micromamba activate cts

export CMAKE_EXEC=$(type -p cmake)

I can probably simplify this second script, but you get the idea.
It would be nice if this `cmake-wrapper` behavior were added to the list of options {Bundled, Custom, Env-Variable}.


Please sign in to leave a comment.