Using Yocto (Scarthgap version) to build a SDK, I am trying to use mbedtls recipe from meta-openembedded (bb file) to have static lib and headers to the standrad SDK (with TOOLCHAIN_TARGET_TASK += " mbedtls-staticdev mbedtls-dev"
. Using that I would expect to be able to use find_package(MbedTLS CONFIG REQUIRED)
to then use target_link_libraries(${PROJECT_NAME} PRIVATE MbedTLS::mbedtls_static)
but I got an error:
CMake Error at /opt/sdk/5.0.7+snapshot/sysroots/armv8a-poky-linux/usr/lib/cmake/MbedTLS/MbedTLSTargets.cmake:133 (message):
The imported target "MbedTLS::everest" references the file
"/usr/lib/libeverest.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/opt/sdk/5.0.7+snapshot/sysroots/armv8a-poky-linux/usr/lib/cmake/MbedTLS/MbedTLSTargets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/opt/sdk/5.0.7+snapshot/sysroots/armv8a-poky-linux/usr/lib/cmake/MbedTLS/MbedTLSConfig.cmake:27 (include)
src/project/CMakeLists.txt:6 (find_package)
It seems that cmake is searching the file from the 'host' (means wsl here) instead of SDK path.
I saw that when cloning the mbedTLS repo the path is "${_IMPORT_PREFIX}/lib/libeverest.a"
instead of just "/usr/lib/libeverest.a"
This value seems linked to LIB_INSTALL_DIR
which is set to ${libdir}
from the recipe.
I want to have the library only to the SDK to avoid installing it on target while it used only as static.
Does the SDK should manage this case ?
What do I miss ?
Well, I created a bbappend for this recipe:
PACKAGECONFIG:remove = "programs"
PACKAGES:remove = " ${PN}-programs"
EXTRA_OECMAKE = "\
-DCMAKE_INSTALL_PREFIX=${exec_prefix} \
-DCMAKE_INSTALL_LIBDIR=lib \
"
Which seems to fix the issue (it will add ${_IMPORT_PREFIX}
to the cmake config) but it looks like a workarround