Conan: Incorrect 'clang', is not the one detected by CMake: 'GNU'

Created on 17 Apr 2017  路  4Comments  路  Source: conan-io/conan

Not sure if this belongs here or at bzip@Lasote

CMake Error at /home/username/.conan/data/bzip2/1.0.6/lasote/stable/build/064bfb4bb850f870351557c8fb99664c54b0f84f/conanbuildinfo.cmake:264 (message):
  Incorrect 'clang', is not the one detected by CMake: 'GNU'
Call Stack (most recent call first):
  /home/username/.conan/data/bzip2/1.0.6/lasote/stable/build/064bfb4bb850f870351557c8fb99664c54b0f84f/conanbuildinfo.cmake:43 (conan_check_compiler)
  CMakeLists.txt:4 (CONAN_BASIC_SETUP)
question

Most helpful comment

You can use conan profiles (http://docs.conan.io/en/latest/mastering/profiles.html) to help configuring clang as the "main" compiler:

~/.conan/profiles/clang

[settings]
compiler=clang
compiler.version=3.5
compiler.libcxx=libstdc++11

[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++

And then conan install ***** --profile clang

All 4 comments

That error is a conan check to ensure that the specified settings and your compiler are matching.
In that case it seems you have gcc compiler in the path but you passed a "-s compiler=clang" or you have this default setting in your conan.conf file.

If you want to build with clang you need to make sure that clang is installed and in the path, you can manage the CC and CXX environment variables to point CMake to a different compiler from the default (gcc).

You can use conan profiles (http://docs.conan.io/en/latest/mastering/profiles.html) to help configuring clang as the "main" compiler:

~/.conan/profiles/clang

[settings]
compiler=clang
compiler.version=3.5
compiler.libcxx=libstdc++11

[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++

And then conan install ***** --profile clang

After some inspection it looks like the problem is that the CMakeLists.txt was setting the compiler settings itself such that they didn't match CC and CXX env vars.

I'm guessing this is not a supported use case?

Yes, you are right. Conan does not interfere at all with the build system, it is orthogonal. If the build system defines some compiler, that will be used. However, I think hardcoding the compiler in CMakeLists.txt is not a recommended practice. In case of cmake, conanbuildinfo.cmake will try to check that the current compiler matches the one used for conan install, but it will not try to change the compiler, not try to install dependencies with different settings.

Was this page helpful?
0 / 5 - 0 ratings