Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Support for Docker Toolchain #98

Open
andreya108 opened this issue Oct 8, 2021 · 2 comments
Open

[feature] Support for Docker Toolchain #98

andreya108 opened this issue Oct 8, 2021 · 2 comments

Comments

@andreya108
Copy link

Please add support for the new Docker Toolchain feature introduced in CLion 2021.3.
It is currently not possible to use the Conan plugin with it because the Conan setup step must be done inside the Docker container, not on the host.

@Thomspoon
Copy link

I second this, support for this would be great!

@cmasdf
Copy link

cmasdf commented Apr 8, 2022

As far is i understand, this problem is caused by the Jetbrains Docker Toolchain Plugin and has nothing to do with conan itself.

I tried to get conan and docker working without the conan plugin and failed as well due to the steps the docker toolchain is executing for a build. The cmake files are generated in a different execution step, than the actual build AND new containers are used for every step. This means, the conan dependencies are installed into the first container, which is used for cmake file generation. In the second step, a new container is used to build the cmake project from the project dir, but now the dependencies from the first step are missing, since it is a new container.

To verify this, i attached myself to a persistent container and build the project manually inside the container, which worked as expected. Unfortunately it's really hard to debug this, since there is no way to configure how the docker plugin is dealing with its containers. It's probably worth to have a look into the Jetbrains Issue tracker.

In general the CLion port of the Docker Plugin still looks pretty alpha, since only a few options are actually working, so i guess there is a good chance this will be fixed soon.

EDIT//

I just found a more or less dirty workaround which might not work for every use case. After noodling around a bit, i came to the conclusion that you just need to make your conan cache persistent - and since the cmake binary folder is used by all docker containers used during build, it seems like a good location for it, depending how one is using conan inside the project. Since i configure everything using cmake files it works pretty well for me. Minimal viable example attached:

PROJECT(MVP)

# search cmake files in cmake binary dir, since conan will be installed there
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

# change the conan user home (containing the cache) to cmake binary dir as well, to make it persistent
set(ENV{CONAN_USER_HOME} ${CMAKE_BINARY_DIR})

# use conan cmake wrapper
include(bin/conan.cmake)

conan_add_remote(<your remote options>)

conan_cmake_configure()

# set user
# for this to work the user password must be set to env var CONAN_PASSWORD_<your remote>
execute_process(COMMAND conan user <youruser> -p -r <your remote>)

# install deps
conan_cmake_install(
    PATH_OR_REFERENCE <path to your conanfile.py, relative to cmake binary dir>
    BUILD <your build polilcy>
    REMOTE <your remote>
)

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants