Skip to content

Commit 6837ca8

Browse files
nlebedencocarlescufi
authored andcommitted
cmake: Revert breaking change to CMAKE_SYSTEM_NAME
This commit reverts a breaking change in CMAKE_SYSTEM_NAME introduced by "Zephyr" back to "Generic") and removes the file `cmake/modules/Platform/Zephyr`. Both changes in the aforementioned PR were only introduced to ultimately modify the value of the global CMake property TARGET_SUPPORTS_SHARED_LIBS for the special case of building for Xtensa with LLEXT. The modification of CMAKE_SYSTEM_NAME is considered a breaking change because it has the potential to alter the build of any non-trivial project that previously checked for the "Generic" system identifier as corresponding to Zephyr - for example by doing `if (CMAKE_SYSTEM_NAME STREQUAL "Generic")`. Such builds may now break in many ways including silently when there is no `else()` clause with a `message()` to alert the user that a whole configuration block had been skipped. In essence, that CMAKE_SYSTEM_NAME modification was only introduced in order to have CMake to load `cmake/modules/Platform/Zephyr.cmake` which in turn adjusted the value of TARGET_SUPPORTS_SHARED_LIBS. But the use of a CMake platform file like this is ineffective for non-trivial projects where one or more top level CMake `project()` calls may happen before the first call to `find_package(Zephyr)` because in such cases CMAKE_MODULE_PATH will not have been modified yet to contain the path to <Zephyr_ROOT>/cmake/modules and thus no platform file will be include by CMake. This patch moves the conditional override of TARGET_SUPPORTS_SHARED_LIBS needed by some archs (e.g. Xtensa) into the `kernel.cmake` module which is known to be the first call to `project()` that enables any language and thus the one that must come before any artifact target can be defined. Note commit 64e7d85 added a Kconfig to specify the object type of llext being built, so it's not tied to the arch anymore but to the CONFIG_LLEXT_TYPE_ELF_SHAREDLIB option. Signed-off-by: Nicolas Lebedenco <[email protected]>
1 parent 0408eee commit 6837ca8

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

cmake/modules/FindTargetTools.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ set(CMAKE_CXX_COMPILER_FORCED 1)
4141
# variable is used for constructing the file names of the platform files
4242
# like Linux.cmake or Windows-gcc.cmake. If your target is an embedded
4343
# system without OS set CMAKE_SYSTEM_NAME to "Generic".
44-
#
45-
# This will force CMake to load cmake/modules/Platform/Zephyr.cmake,
46-
# allowing Zephyr-specific embedded system features to be enabled.
47-
set(CMAKE_SYSTEM_NAME Zephyr)
44+
set(CMAKE_SYSTEM_NAME Generic)
4845

4946
# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html:
5047
# The name of the CPU CMake is building for.

cmake/modules/Platform/Zephyr.cmake

Lines changed: 0 additions & 13 deletions
This file was deleted.

cmake/modules/kernel.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ set(KERNEL_STRIP_NAME ${KERNEL_NAME}.strip)
168168
set(KERNEL_META_NAME ${KERNEL_NAME}.meta)
169169
set(KERNEL_SYMBOLS_NAME ${KERNEL_NAME}.symbols)
170170

171+
# Enable dynamic library support when required by LLEXT.
172+
if(CONFIG_LLEXT AND CONFIG_LLEXT_TYPE_ELF_SHAREDLIB)
173+
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
174+
endif()
175+
171176
include(${BOARD_DIR}/board.cmake OPTIONAL)
172177

173178
# If we are using a suitable ethernet driver inside qemu, then these options

0 commit comments

Comments
 (0)