Skip to content

Commit 487f861

Browse files
pillo79kartben
authored andcommitted
cmake: llext: avoid always compiling extensions
In CMake, unless explicitly disabled, the 'add_library()' and 'add_executable()' functions add their result to the ALL target. This is undesirable for 'add_llext_target()', since it causes the source files for all defined extensions to be compiled even when the extension is not otherwise used by the build process. Add 'EXCLUDE_FROM_ALL' where appropriate so that the object files are only built when the extension is actually used by the project. Signed-off-by: Luca Burelli <[email protected]>
1 parent 17dfafb commit 487f861

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmake/modules/extensions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5640,7 +5640,7 @@ function(add_llext_target target_name)
56405640
if(CONFIG_LLEXT_TYPE_ELF_OBJECT)
56415641

56425642
# Create an object library to compile the source file
5643-
add_library(${llext_lib_target} OBJECT ${source_files})
5643+
add_library(${llext_lib_target} EXCLUDE_FROM_ALL OBJECT ${source_files})
56445644
set(llext_lib_output $<TARGET_OBJECTS:${llext_lib_target}>)
56455645

56465646
elseif(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE)
@@ -5668,7 +5668,7 @@ function(add_llext_target target_name)
56685668
elseif(CONFIG_LLEXT_TYPE_ELF_SHAREDLIB)
56695669

56705670
# Create a shared library
5671-
add_library(${llext_lib_target} SHARED ${source_files})
5671+
add_library(${llext_lib_target} EXCLUDE_FROM_ALL SHARED ${source_files})
56725672
set_target_properties(${llext_lib_target} PROPERTIES
56735673
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/llext
56745674
)

0 commit comments

Comments
 (0)