Skip to content

Commit b4e851e

Browse files
tarun292facebook-github-bot
authored andcommitted
Check if dl library is available and only then link it in for executorch in CMake. (#657)
Summary: The dl library might not be available on embedded platforms. Before we link it in for executorch core lib we check if it exists for the toolchain we are using and then link it in if it does. Reviewed By: larryliu0820 Differential Revision: D50001473
1 parent 09e60a0 commit b4e851e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ add_subdirectory(schema)
259259

260260
add_library(executorch ${_executorch__srcs})
261261
target_link_libraries(executorch PRIVATE program_schema)
262-
target_link_libraries(executorch PRIVATE dl) # For dladdr()
262+
# Check if dl exists for this toolchain and only then link it.
263+
find_library(DL_LIBRARY_EXISTS NAMES dl)
264+
# Check if the library was found
265+
if(DL_LIBRARY_EXISTS)
266+
target_link_libraries(executorch PRIVATE dl) # For dladdr()
267+
endif()
263268
target_include_directories(executorch PUBLIC ${_common_include_directories})
264269
target_compile_options(executorch PUBLIC ${_common_compile_options})
265270
if(MAX_KERNEL_NUM)

0 commit comments

Comments
 (0)