cmake-conan
cmake-conan copied to clipboard
ERROR: Invalid setting '6' is not a valid 'settings.compiler.version' value
cmaker version: 3.24.0 conan version: 2.2.2
profiles/default [settings] os=Linux arch=x86_64 compiler=clang compiler.version=6.0 compiler.libcxx=libstdc++11 build_type=Release
Running cmake generates an error:
-- CMake-Conan: Installing single configuration Release
-- CMake-Conan: conan install /home/chl/coding/rbk4-to-conan2 -of=/home/chl/coding/rbk4-to-conan2/cmake-build-release/conan --profile:host=default;--profile:host=/home/chl/coding/rbk4-to-conan2/cmake-build-release/conan_host_profile;--profile:build=default;--build=missing;-g;CMakeDeps
ERROR: Invalid setting '6' is not a valid 'settings.compiler.version' value.
Possible values are ['3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4.0', '5.0', '6.0', '7.0', '7.1', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18']
Read "http://docs.conan.io/2/knowledge/faq.html#error-invalid-setting"
CMake Error at cmake/conan_provider.cmake:459 (message):
Conan install failed='1'
Call Stack (most recent call first):
cmake/conan_provider.cmake:567 (conan_install)
cmake/GetThirdPartyLibs.cmake:10 (find_package)
CMakeLists.txt:70 (include)
-- Configuring incomplete, errors occurred!
See also "/home/chl/coding/rbk4-to-conan2/cmake-build-release/CMakeFiles/CMakeOutput.log".
See also "/home/chl/coding/rbk4-to-conan2/cmake-build-release/CMakeFiles/CMakeError.log".
[Failed to reload]
There is a detect_compiler() function in the conan_provider.cmake file
function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUNTIME_TYPE)
# ...
message(STATUS "CMake-Conan: CMake compiler=${_COMPILER}")
message(STATUS "CMake-Conan: CMake compiler version=${_COMPILER_VERSION}")
# ...
elseif(_COMPILER MATCHES Clang)
set(_COMPILER "clang")
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
# ...
endfunction()
In the detect_compiler function():
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) changes 6.0.0 to 6;0;0
list(GET VERSION_LIST 0 _COMPILER_VERSION) takes the 0th element of VERSION_LIST, so _COMPILER_VERSION is equal to 6
So an ERROR ERROR: Invalid setting '6' is not a valid value. 'settings.com piler. Version'.
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
Change the above two lines of code to the following line
string(REGEX MATCHALL "[0-9]+\\.[0-9]+" _COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
This changes' 6.0.0 'to' 6.0 'and assigns' CMAKE_CXX_COMPILER_VERSION', which runs successfully.
Is there a bug here?
Hi @chl1123
Thanks for reporting.
There is indeed a gap in the version detection for Linux clang in cmake-conan.
As you can see the versioning approach in clang changed, and while the Conan settings contain X.0 for older versions, the newer versions are just the clang major. But cmake-conan mapping didn't implement it, and we didn't realize because clang 6 is nowadays a bit too old, so nobody was using it and nobody reported yet.
As you already did the investigation (good work, thanks!), would you like to contribute a PR yourself? The logic would be, for versions <8 include the minor, but only the major for >=8. Don't worry if you can't, we will try to fix it ourselves if not.
I am willing to contribute a PR, I think I need some time to try to submit at the end of this week