Reputation: 221
I read that the compiler should be specified when invoking Conan's build command, or in the [settings]
section of a Profile.
However, I am building using Cmake and already provide the compiler information using a CMAKE_TOOLCHAIN_FILE
. I found I can set this in the [env]
section of the profile, using CONAN_CMAKE_TOOLCHAIN_FILE
, but it is not considered in settings
.
Now I am confused about the potential of specifying a compiler which does not match that specified in the CONAN_CMAKE_TOOLCHAIN_FILE
.
What is the correct way to specify the compiler in this case?
Is it safe to replace the standard settings section with CONAN_CMAKE_TOOLCHAIN_FILE
?
i.e. in conanfile.py:
settings = "CONAN_CMAKE_TOOLCHAIN_FILE"
(Also, why isn't source specified in settings
? Surely this is the most common change which affects the output binary?)
Upvotes: 1
Views: 2893
Reputation: 3887
CONAN_CMAKE_TOOLCHAIN_FILE it's only a env var related to CMake, not a setting by itself.
What is the correct way to specify the compiler in this case?
You need to configure your settings as usually when cross-compiling. The best idea is creating a new profile for that. For example:
[settings]
arch=armv7hf
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=7
os=Linux
[env]
CONAN_CMAKE_TOOLCHAIN_FILE=/opt/cmake/Toolchain-armhf.cmake
The profile could be directly in ${CONAN_USER_HOME}/profiles or running conan profile
command
Is it safe to replace the standard settings section with CONAN_CMAKE_TOOLCHAIN_FILE?
No! Settings is a group of properties that are part of your package id. If you change that, Conan will complain it by an invalid new property, since only some properties are accepted by default.
Regards!
Upvotes: 2