Home/Support/Support Forum/Digi embedded yocto: Why is executable generated by CMake recipe larger than compiling by gcc
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Digi embedded yocto: Why is executable generated by CMake recipe larger than compiling by gcc

0 votes
I have a simple CMake recipe like this:

###########################
SUMMARY = "Simple helloworld cmake application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://CMakeLists.txt \
file://helloworld.c"

S = "${WORKDIR}"
inherit cmake
EXTRA_OECMAKE = ""
##########################

and the content of the CMakelists.txt is:

##########################
cmake_minimum_required(VERSION 2.8.10)

project("Test" C)

add_executable(HelloWorldCMake helloworld.c)

install(TARGETS HelloWorldCMake RUNTIME DESTINATION bin)
##########################

I have another recipe does the same thing but i don't use CMake

##########################
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://helloworld.c"

S = "${WORKDIR}"

TARGET_CC_ARCH += "${LDFLAGS}"

do_compile() {
${CC} helloworld.c -o helloworld
}

do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
##########################

Both recipes compile and install successfully but the executable generated by CMake recipe is much larger than that of the normal recipe.
asked Oct 20, 2017 in Linux by phammanh New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
perhaps optimization is not enabled:
https://cmake.org/Wiki/CMake_Performance_Tips
answered Oct 22, 2017 by LeonidM Veteran of the Digi Community (3,363 points)
Following the instructions, I add this line before inheriting cmake:

EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=Release"

And still get the same reusult
...