Background
I am trying to build a custom software inside Yocto build. Software is built by CMake.
The following is my recipe - customsoftware.bb
:
SRCBRANCH = "master"
SRCREV = "master"
MY_SRC = "OMITTED"
SRC_URI = "${MY_SRC};branch=${SRCBRANCH}"
# libraries dependencies
DEPENDS += "boost"
S = "${WORKDIR}/git"
B = "${WORKDIR}/build"
PARALLEL_MAKE ?= "-j 1"
inherit cmake
# My CMake Options
EXTRA_OECMAKE+=" -DSOME_OPTION=ON"
# I want unix makefiles instead on ninja build
OECMAKE_GENERATOR="Unix Makefiles"
The following is a watered down version of my cmake project - CMakeLists.txt
Please note: I have omitted irrelevant parts for brevity
cmake_minimum_required(VERSION 3.0.0)
#---------------------------------------------------------------------------------------
# set default build to release
#---------------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/dist/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/dist/bin)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
${BoldRed}Error:${ColourReset} In-source builds are not allowed. You should create separate directory for build files.
${Magenta}CMAKE_BINARY_DIR${ColourReset}(${CMAKE_SOURCE_DIR}) must be different from ${Magenta}CMAKE_SOURCE_DIR${ColourReset}(${CMAKE_BINARY_DIR})
")
endif ()
project(myapp)
find_package(Boost REQUIRED COMPONENTS thread)
add_executable(${PROJECT_NAME}
${HEADERS}
${SOURCES}
)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
#Copy entire contents of dist/ to /opt/myapp
install(DIRECTORY ${CMAKE_BINARY_DIR}/dist/
DESTINATION /opt/myapp
)
I have appended my recipe to image.
Issue
When I ran du -h tmp/work/.../<customsoftware>/build/dist/bin
binary size is 80MB. Also, after deploying to target system binary size is 80MB.
UPDATE
As suggested in comments, binaries at tmp/work/.../<customsoftware>/image
are not stripped. However, binaries at tmp/work/.../<customsoftware>/packages-split
are stripped.
If I ran make
in source of app - not through recipe and outside yocto - binary size is 1.7MB
Question
If I remember correctly, OE build will strip debug symbols from resulting binaries.
Why does my binary still get deployed with debug symbols? What have I missed?
How can I make sure only stripped - Release type - binary is deployed?
Explicitly specifying package types and inheriting pkgconfig solved my issue. Updated recipe:
SRCBRANCH = "master"
SRCREV = "master"
MY_SRC = "OMITTED"
SRC_URI = "${MY_SRC};branch=${SRCBRANCH}"
DEPENDS += "boost"
S = "${WORKDIR}/git"
PARALLEL_MAKE ?= "-j 1"
inherit pkgconfig cmake
EXTRA_OECMAKE+=" -DSOME_OPTION"
OECMAKE_GENERATOR="Unix Makefiles"
# Specify package types
PACKAGES = "${PN}-dbg ${PN}"
FILES_${PN}-dbg += "\
<INSTALL_PATH>/.debug \
"
FILES_${PN} += "\
<INSTALL_PATH>/* \
"