cmake doesn't find library: toolset clang, detected clang8
I'm using cmake to cross-compile a library for Android that uses boost. I've compiled and installed boost with
./build-android.sh --with-libraries=filesystem --prefix=/opt/boost_arm --arch=arm64-v8a $NDK
which worked fine.
However, when my project tries to find_package(Boost), it fails:
-- Scanning /opt/boost_arm/arm64-v8a/lib/cmake/boost_filesystem-1.70.0/libboost_filesystem-variant*.cmake
-- Including /opt/boost_arm/arm64-v8a/lib/cmake/boost_filesystem-1.70.0/libboost_filesystem-variant-clang-mt-a64-1_70-static.cmake
-- ... skipped libboost_filesystem-clang-mt-a64-1_70.a (clang, detected clang8, set Boost_COMPILER to override)
CMake Error at /opt/boost_arm/arm64-v8a/lib/cmake/Boost-1.70.0/BoostConfig.cmake:95 (find_package):
Found package configuration file:
/opt/boost_arm/arm64-v8a/lib/cmake/boost_filesystem-1.70.0/boost_filesystem-config.cmake
but it set boost_filesystem_FOUND to FALSE so package "boost_filesystem" is
considered to be NOT FOUND. Reason given by package:
No suitable build variant has been found.
The relevant check that fails is in /opt/boost_arm/arm64-v8a/lib/cmake/boost_filesystem-1.70.0/libboost_filesystem-variant-clang-mt-a64-1_70-static.cmake:19:
if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL "clang")
_BOOST_SKIPPED("libboost_filesystem-clang-mt-a64-1_70.a" "clang, detected ${BOOST_DETECTED_TOOLSET}, set Boost_COMPILER to override")
return()
endif()
It seems like /opt/arm64-v8a/lib/cmake/BoostDetectToolset-1.70.0.cmake appends the compiler version number to BOOST_DETECTED_TOOLSET.
I'm not sure where the "clang" comes from. Maybe this is an issue with boost itself? Maybe I just configured something wrong? https://boostorg.github.io/build/manual/master/index.html#bbv2.reference.tools.compilers doesn't even list clang as a builtin tool.
https://github.com/boostorg/boost/issues/310 looks like a similiar issue
Maybe it's enough to set "--layout=system" instead of "--layout=versioned" in build-android.sh. cmake (3.15.1, Linux version) recognized boost 1.70 on my system when executing cmake in QtCreator after changing the above mentioned. But I can't guarantee it because I just rework my qmake project to a cmake one and didn't compiled it yet.
--layout=system indeed works, thank you!
I still think this is a bug tough, as I'm using the same toolchain to compile boost and to build my project, so it shouldn't fail due to different compiler versions.
configs/user-config-boost-1_70_0-common.jam uses %ARCH% as the Clang version, which is not numeric and is therefore ignored by the mangling. That's why the toolset is encoded as just clang and not clang8 as it would have been if the version was either left empty or specified as f.ex. 8.0.1.
@pdimov So should i change
using clang : %ARCH%
to
using clang : clang8 ?
No, just remove %ARCH, it should autodetect the version. clang8 is not a valid numeric version either.
No, just remove
%ARCH, it should autodetect the version.clang8is not a valid numeric version either.
It will look like this -
using clang :
:
$(AndroidBinariesPath)/clang++
:
<archiver>$(AndroidBinariesPath)/llvm-ar
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-O2
<compileflags>-g