cmake-conan
cmake-conan copied to clipboard
How can you pass conan command line options when using CLion's conan plugin?
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
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
Hi @rturrado - thanks for your questions.
We have recently merged: https://github.com/conan-io/cmake-conan/pull/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 -
-
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). -
In the CLion plugin you can refresh to pull the latest version of
cmake-conan
:
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!