How can you pass conan command line options when using CLion's conan plugin?
rturrado opened this issue · comments
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!
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!
Hi @jcar87,
Many thanks to you for your great work and support!
A couple of questions:
- Can I also set
compiler.cppstd=20
as a setting in my custom Conan profile? - 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!
Hi @rturrado -
Wow! Many thanks for your answer!
- Knowing this is highly valuable. I was using at the moment
target_compile_features(<target> PUBLIC cxx_std_<YY>)
, but I'll definitely setCMAKE_CXX_STANDARD
as well in order to avoid passing one extra argument to conan. - Beautiful, easy!
Again, great work and support, guys!
Hi guys,
I have tried this today, and:
- In my case, setting
CMAKE_CXX_STANDARD
in theCMakeLists.txt
file is not enough. I need to explicitly usecompiler.cppstd=<YY>
. - 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!