Skip to content

Commit 4418dfd

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: Pull Request resolved: #657 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 fbshipit-source-id: defdeae6b47ae0f5cca0b0fe34859171ed449f18
1 parent 51d6afa commit 4418dfd

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
@@ -239,7 +239,12 @@ add_subdirectory(schema)
239239

240240
add_library(executorch ${_executorch__srcs})
241241
target_link_libraries(executorch PRIVATE program_schema)
242-
target_link_libraries(executorch PRIVATE dl) # For dladdr()
242+
# Check if dl exists for this toolchain and only then link it.
243+
find_library(DL_LIBRARY_EXISTS NAMES dl)
244+
# Check if the library was found
245+
if(DL_LIBRARY_EXISTS)
246+
target_link_libraries(executorch PRIVATE dl) # For dladdr()
247+
endif()
243248
target_include_directories(executorch PUBLIC ${_common_include_directories})
244249
target_compile_options(executorch PUBLIC ${_common_compile_options})
245250
if(MAX_KERNEL_NUM)

0 commit comments

Comments
 (0)