cmake: conditionally enable shared library support
When CONFIG_LLEXT is enabled, the Zephyr platform needs to enable dynamic library support. This is done by setting the `TARGET_SUPPORTS_SHARED_LIBS` property to `TRUE` in the global property scope. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
parent
b5b5291df2
commit
f61b003b07
2 changed files with 20 additions and 3 deletions
|
@ -31,7 +31,8 @@ endif()
|
||||||
set(CMAKE_C_COMPILER_FORCED 1)
|
set(CMAKE_C_COMPILER_FORCED 1)
|
||||||
set(CMAKE_CXX_COMPILER_FORCED 1)
|
set(CMAKE_CXX_COMPILER_FORCED 1)
|
||||||
|
|
||||||
# No official documentation exists for the "Generic" value, except their wiki.
|
# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html:
|
||||||
|
# The name of the operating system for which CMake is to build.
|
||||||
#
|
#
|
||||||
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling:
|
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling:
|
||||||
# CMAKE_SYSTEM_NAME : this one is mandatory, it is the name of the target
|
# CMAKE_SYSTEM_NAME : this one is mandatory, it is the name of the target
|
||||||
|
@ -40,7 +41,10 @@ set(CMAKE_CXX_COMPILER_FORCED 1)
|
||||||
# variable is used for constructing the file names of the platform files
|
# variable is used for constructing the file names of the platform files
|
||||||
# like Linux.cmake or Windows-gcc.cmake. If your target is an embedded
|
# like Linux.cmake or Windows-gcc.cmake. If your target is an embedded
|
||||||
# system without OS set CMAKE_SYSTEM_NAME to "Generic".
|
# system without OS set CMAKE_SYSTEM_NAME to "Generic".
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
#
|
||||||
|
# This will force CMake to load cmake/modules/Platform/Zephyr.cmake,
|
||||||
|
# allowing Zephyr-specific embedded system features to be enabled.
|
||||||
|
set(CMAKE_SYSTEM_NAME Zephyr)
|
||||||
|
|
||||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html:
|
# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html:
|
||||||
# The name of the CPU CMake is building for.
|
# The name of the CPU CMake is building for.
|
||||||
|
@ -74,7 +78,7 @@ else()
|
||||||
set(CMAKE_CXX_BYTE_ORDER LITTLE_ENDIAN)
|
set(CMAKE_CXX_BYTE_ORDER LITTLE_ENDIAN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# We are not building dynamically loadable libraries
|
# Do not build dynamically loadable libraries by default
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
|
||||||
# Custom targets for compiler and linker flags.
|
# Custom targets for compiler and linker flags.
|
||||||
|
|
13
cmake/modules/Platform/Zephyr.cmake
Normal file
13
cmake/modules/Platform/Zephyr.cmake
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024, Arduino SA
|
||||||
|
|
||||||
|
# Perform the same initialization as the Generic platform, then enable
|
||||||
|
# dynamic library support if CONFIG_LLEXT is enabled.
|
||||||
|
|
||||||
|
include(Platform/Generic)
|
||||||
|
|
||||||
|
# Enable dynamic library support when CONFIG_LLEXT is enabled.
|
||||||
|
if(CONFIG_LLEXT)
|
||||||
|
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS true)
|
||||||
|
endif()
|
Loading…
Add table
Add a link
Reference in a new issue