Skip to content

Conversation

@kesyog
Copy link
Contributor

@kesyog kesyog commented Jun 5, 2025

zephyr_append_cmake_library attempts to warn the user if a user calls it to create a Zephyr library while the build is in application mode. At that stage of the build, the list of Zephyr libraries has already been processed so the function is effectively a no-op. This warning originated from #35887.

This heuristic used to determine if the build was in kernel mode or application mode checked for the presence of the zephyr_prebuilt target. This check was broken by a previous commit (#39959) that renamed this target.

This commit fixes the heuristic by checking for the zephyr_pre0 target instead of the zephyr_prebuilt target.

This was tested by calling zephyr_append_cmake_library from some application build files, building the application, and seeing the warning only for the call I added. No warnings were printed for any Zephyr internal libraries.

zephyr_append_cmake_library attempts to warn the user if a user calls it
to create a Zephyr library while the build is in application mode. At
that stage of the build, the list of Zephyr libraries has already been
processed so the function is effectively a no-op.

This heuristic used to determine if the build was in kernel mode or
application mode checked for the presence of the zephyr_prebuilt target.
This check was broken by a previous commit that renamed this target.

This commit fixes the heuristic by checking for the zephyr_pre0 target.

This was tested by calling zephyr_append_cmake_library from some
application build files, building the application, and seeing the
warning only for the call I added. No warnings were printed for any
Zephyr internal libraries.

Link: zephyrproject-rtos#35887
Link: zephyrproject-rtos#39959

Signed-off-by: Kesavan Yogeswaran <hikes@google.com>
@github-actions github-actions bot added area: Build System size: XS A PR changing only a single line of code labels Jun 5, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 5, 2025

@dkalowsk dkalowsk merged commit d5fc087 into zephyrproject-rtos:main Jun 9, 2025
27 checks passed
@kesyog kesyog deleted the zephyr-append-cmake-library-warning branch June 9, 2025 22:02
copybara-service bot pushed a commit to pigweed-project/pigweed that referenced this pull request Jun 11, 2025
zephyr_append_cmake_library is effectively a no-op in the "application
stage" of the Zephyr build. It is only useful inside of Zephyr and in
Zephyr modules.

References
* zephyrproject-rtos/zephyr#35887
* zephyrproject-rtos/zephyr#91143

Change-Id: Ie766d8d720e3e9cb1c4282cc7fa04517f9904055
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/296772
Commit-Queue: Kesavan Yogeswaran <hikes@google.com>
Pigweed-Auto-Submit: Kesavan Yogeswaran <hikes@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Yuval Peress <peress@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Docs-Not-Needed: Kesavan Yogeswaran <hikes@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
@thorsten-klein
Copy link
Contributor

With this change, we are now receiving warnings in our CMake build when using the zephyr_library_named function.
I believe it is appropriate to create static libraries as part of our application build.

Is this warning expected for our use case, or is there an exception that should be applied to prevent the warning when using zephyr_library_named?

Or what is the recommended way to build static libraries (without using zephyr modules)?

@nordicjm
Copy link
Contributor

With this change, we are now receiving warnings in our CMake build when using the zephyr_library_named function. I believe it is appropriate to create static libraries as part of our application build.

Can you explain what you mean, you are using a zephyr build to generate static libraries that you then use somewhere else in a different project?

@thorsten-klein
Copy link
Contributor

Can you explain what you mean, you are using a zephyr build to generate static libraries that you then use somewhere else in a different project?

I have created a separate discussion for my question in order to not abuse this PR for discussions:
See #93579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Build System size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants