I am trying to make a Yocto recipe for an application (application_1.0.0.bb). Here is a (simplified) CMake for that application:
cmake_minimum_required(VERSION 3.14)
project(
server
VERSION 0.1.0
DESCRIPTION "Main application"
HOMEPAGE_URL "https://gitlab.123.com/software/projects/server"
LANGUAGES CXX
)
message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# ---- Poco::Util ----
find_package(Poco REQUIRED COMPONENTS Util)
find_package(unofficial-libmariadb CONFIG REQUIRED)
find_package(Poco REQUIRED COMPONENTS Data DataMySQL)
# ---- Declare executable ----
add_executable(server_exe
src/main.cpp
)
add_executable(server::exe ALIAS server_exe)
set_property(TARGET server_exe PROPERTY OUTPUT_NAME server)
target_compile_features(server_exe PRIVATE cxx_std_17)
target_link_libraries(server_exe
PRIVATE
Poco::Util
Poco::DataMySQL
)
Both poco and mariadb are in the DEPENDS
of application.bb recipe. The important parts of their CMake process (a bit patched from the original projects) are:
target_link_libraries(DataMySQL PUBLIC Poco::Data ${MYSQL_LIBRARIES})
with set(MYSQL_LIBRARIES unofficial::libmariadb)
and a find_package(unofficial-libmariadb CONFIG REQUIRED)
called right before. Oh, and the Poco library is built the -DBUILD_SHARED_LIBS=OFF (so it builds static libraries)TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS})
with SYSTEM_LIBS
withSET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
(Both OPENSSL_SSL_LIBRARY and OPENSSL_CRYPTO_LIBRARY being variables coming out FIND_PACKAGE(OPENSSL)
). It is exported as unofficial::libmariadb.Configuration step is successful but at the start of the compile step, bitbake gives me this error:
ERROR: application-1.0+gitAUTOINC+ebcaa0785-r0 do_compile: ExecutionError('/home/buildbot/oe-core/build/cortexa53-tdx-linux/application/1.0+gitAUTOINC+ebcaa0785-r0/temp/run.do_compile.368082', 1, None, None)
ERROR: Logfile of failure stored in: ...
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: VERBOSE=1 cmake --build /home/buildbot/oe-core/build/tmp/work/cortexa53-tdx-linux/application/1.0+gitAUTOINC+ebcaa0785-r0/build --target all --
| ninja: error: '/home/buildbot/oe-core/build/tmp/work/cortexa53-tdx-linux/mariadb/10.7.4-r0/recipe-sysroot/usr/lib/libssl.so' needed by 'application', missing and no known rule to make it
| WARNING: exit code 1 from a shell command.
ERROR: Task (/home/.../application_1.0.0.bb:do_compile) failed with exit code '1'
The error say libssl.so is needed but missing. You need to add in your .bbappend file a build dependency (and maybe runtime dependency?)
DEPENDS += "openssl"
RDEPENDS += "openssl"