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

How can you pass conan command line options when using CLion's conan plugin? #565

Open
rturrado opened this issue Sep 19, 2023 · 6 comments
Assignees

Comments

@rturrado
Copy link

Hi all,

Sorry if this question doesn't belong here. I believe the CLion's conan plugin uses cmake-conan (as stated here), but this may well be more an issue of the plugin than of cmake-conan.

Let's say I have a conan command line such as:

conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:build_tests=True -b missing

Is there a way to pass all or some of those options to the plugin?

At the moment, I can only think of setting them directly as CMake flags. One of the problems with that is that, for example, if I'm requiring gtest in the conanfile.py depending on the command line option build_tests, that check will always be false.

Thanks!

@memsharded
Copy link
Member

Hi @rturrado

We have pending the "customization" feature for cmake-conan. It will work mostly by allowing to inject custom profiles to the build, @jcar87 will be contributing it soon, please keep tuned

@jcar87
Copy link
Contributor

jcar87 commented Sep 25, 2023

Hi @rturrado - thanks for your questions.

We have recently merged: #567
with documentation here: https://github.com/conan-io/cmake-conan/tree/develop2#customizing-conan-profiles

Which allows you to customise the Conan profiles. While this does not let you customize the command line invocation, most of the settings/options you have in your example:

-s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:build_tests=True

can be set in a profile file (with the exception of the --build flag, which currently is set to --build=missing in CMake-Conan).
The new option supports profile composition, so you could have a profile file somewhere with the following contents:

[settings]
 libqasm/*:build_type=Debug
[options]
 libqasm/*:build_tests=True

if this file is saved in /path/to/my_overrides
then you could pass -DCONAN_HOST_PROFILE=default;auto-cmake;/path/to/my_overrides, to achieve the result you want.

Please let us know if this helps!

@rturrado
Copy link
Author

Hi @jcar87,

Many thanks to you for your great work and support!

A couple of questions:

  1. Can I also set compiler.cppstd=20 as a setting in my custom Conan profile?
  2. Do you know when will this change be available for the CLion's plugin? I am using version 2.0.2 of the plugin and it seems it is the latest.

Many thanks!

@jcar87
Copy link
Contributor

jcar87 commented Sep 25, 2023

Hi @rturrado -

  1. Yes, you should be able to set this as well. Bear in mind that this is currently autodetected based on whether CMAKE_CXX_STANDARD is defined (if you define it and set it to 20, it will have the same effect).

  2. In the CLion plugin you can refresh to pull the latest version of cmake-conan:
    image

@rturrado
Copy link
Author

rturrado commented Sep 26, 2023

Wow! Many thanks for your answer!

  1. Knowing this is highly valuable. I was using at the moment target_compile_features(<target> PUBLIC cxx_std_<YY>), but I'll definitely set CMAKE_CXX_STANDARD as well in order to avoid passing one extra argument to conan.
  2. Beautiful, easy!

Again, great work and support, guys!

@rturrado
Copy link
Author

Hi guys,

I have tried this today, and:

  1. In my case, setting CMAKE_CXX_STANDARD in the CMakeLists.txt file is not enough. I need to explicitly use compiler.cppstd=<YY>.
  2. Using -DCONAN_HOST_PROFILE="default;auto-cmake;/path/to/libqasm/conan/profiles/tests-debug" didn't work for me either. I can see the options in the CMake output (Input profiles, Profile host section), but then they seem not to be passed to the build (e.g. tests are not built). I am using the version 2.0.2 of the Conan's CLion plugin.

It may well be that something is wrong with my system. I work on WSL 2 and it's a bit of a headache everyday (root user, permission errors from within CLion until you reboot WSL...). But this is my real current feedback anyway.

Thanks!

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