question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Does Conan take any step regarding the 'compiler' setting with CMake helper

See original GitHub issue

We have a simple library, whose build is managed by CMake.

After adding a Conan test package, we are now observing surprising behaviours when calling conan create -s compiler=clang with a compiler setting that is not the value in the default profile (gcc):

CMake Error at build/22a957f739c44641d9703aa35ab1d4431991e8cf/conanbuildinfo.cmake:585 (message):
  Incorrect 'clang', is not the one detected by CMake: 'GNU'

Which raises the question: when providing a compiler setting, does the CMake build helper take any measure to use said compiler? If not, what is the best practice for the recipe implementers to forward this setting to the CMake helper?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jgsogocommented, Oct 17, 2019

Hi, @Adnn. We are working on a POC to start using toolchains for CMake (follow the issue here: https://github.com/conan-io/conan/issues/5737) as it is the best way to avoid this kind of errors.

Right now, the best thing you can do is to use profiles and add the environment variables CXX and CC to your profiles, and CMake will use them to populate CMAKE_CXX_COMPILER and CMAKE_C_COMPILER.

For example, a profile for Clang:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=6.0
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
CXX=clang++
CC=clang

Other option is to populate the CMAKE_<LANG>_COMPILER variables yourself inside the recipe, using cmake.definitions, but I wouldn’t recommend this way over the profiles one.

0reactions
jgsogocommented, Nov 29, 2019

Thanks a lot! 😊

With the effort in #5919 CMake integration in Conan should be easier to handle:

  • the toolchain will take care of the compiler, flags,…
  • the toolchain, via CMAKE_PROJECT_INCLUDE, will adjust some flags (like VS runtime)
  • the information about dependencies will be consumed using a generator like find_package or find_package_multi,… or even cmake_paths if you just want the paths.

Decoupling the settings from the dependencies will make it more clear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

conan Documentation
Conan is a decentralized package manager with a client-server architecture. This means that clients can fetch packages.
Read more >
c++ - Github Actions using CMake, conan and Vulkan SDK fail ...
Why can't it find conanfile.py ? It is in the same directory? For now I just want gcc on Linux to work. Thank...
Read more >
2017-August.txt - CMake
The problem is that this code: https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0/Modules/Platform/Windows-GNU.cmake#L117-127 inserts use of the archiver ...
Read more >
Trying Conan with Modern CMake: Packaging - John Freeman
Generally, all of the Conan packages being linked together in a single library or application should have the same settings, and settings are ......
Read more >
Build systems - pybind11 documentation
An example of a setup.py using pybind11's helpers: ... In addition, it will take care of all the Python-specific compiler and linker flags...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found