Skip to content

Commit 0f0f5b3

Browse files
authored
[onert] Replace hardcoded dl library with CMAKE_DL_LIBS (#16248)
This commit replaces hardcoded 'dl' library references with CMAKE_DL_LIBS variable across multiple CMakeLists.txt files to improve cross-platform compatibility. It includes removing meaningless 'dl' library linking which is not using dlopen/dlclose in the code. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
1 parent 653dd16 commit 0f0f5b3

File tree

14 files changed

+14
-15
lines changed

14 files changed

+14
-15
lines changed

runtime/contrib/gpu_cl/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ endif ()
2222

2323
target_compile_definitions(${LIB_ONERT_BACKEND_GPU_CL} PRIVATE CL_TARGET_OPENCL_VERSION=220 EGL_NO_X11)
2424

25-
target_link_libraries(${LIB_ONERT_BACKEND_GPU_CL} PRIVATE dl)
2625
target_link_libraries(${LIB_ONERT_BACKEND_GPU_CL} PRIVATE tflite-gpu-delegate)
2726
target_link_libraries(${LIB_ONERT_BACKEND_GPU_CL} PRIVATE onert_core)
2827
target_link_libraries(${LIB_ONERT_BACKEND_GPU_CL} PRIVATE ${LIB_ONERT_BACKEND_CL_COMMON})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
add_executable(tflite_conv_example "src/conv.cpp")
2-
target_link_libraries(tflite_conv_example tensorflow-lite Threads::Threads dl nnfw_lib_tflite)
2+
target_link_libraries(tflite_conv_example tensorflow-lite Threads::Threads nnfw_lib_tflite)

runtime/contrib/npud/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ target_include_directories(npud_core PUBLIC ${DBUS_INCLUDE_DIRS})
1313
target_link_libraries(npud_core PRIVATE nnfw_lib_misc)
1414
target_link_libraries(npud_core PRIVATE ${GLIB2.0_LIBRARIES})
1515
target_link_libraries(npud_core PRIVATE Threads::Threads)
16-
target_link_libraries(npud_core PRIVATE dl)
16+
target_link_libraries(npud_core PRIVATE ${CMAKE_DL_LIBS})
1717
target_link_libraries(npud_core PRIVATE npud_dbus)
1818

1919
if(ENVVAR_NPUD_CONFIG)

runtime/contrib/npud/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ target_include_directories(npud_gtest PUBLIC ${GLIB2.0_INCLUDE_DIRS})
1212
target_link_libraries(npud_gtest PRIVATE ${GLIB2.0_LIBRARIES})
1313
target_link_libraries(npud_gtest PRIVATE Threads::Threads)
1414
target_link_libraries(npud_gtest PRIVATE npud_core)
15-
target_link_libraries(npud_gtest PRIVATE gtest_main dl)
15+
target_link_libraries(npud_gtest PRIVATE gtest_main)
1616

1717
install(TARGETS npud_gtest DESTINATION npud-gtest)

runtime/contrib/style_transfer_app/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(JPEG_FOUND)
2626
target_include_directories(style_transfer_app PRIVATE ${JPEG_INCLUDE_DIRS})
2727
endif(JPEG_FOUND)
2828

29-
target_link_libraries(style_transfer_app Threads::Threads dl)
29+
target_link_libraries(style_transfer_app Threads::Threads)
3030
target_link_libraries(style_transfer_app nnfw-dev)
3131
target_link_libraries(style_transfer_app arser)
3232
if(JPEG_FOUND)

runtime/contrib/tflite_classify/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${ROOTFS_DIR}/usr/lib/ar
1414

1515
add_executable(tflite_classify ${SOURCES})
1616
target_include_directories(tflite_classify PRIVATE src)
17-
target_link_libraries(tflite_classify tensorflow-lite Threads::Threads dl nnfw_lib_tflite)
17+
target_link_libraries(tflite_classify tensorflow-lite Threads::Threads nnfw_lib_tflite)
1818
target_link_libraries(tflite_classify ${OpenCV_LIBRARIES})
1919

2020
install(TARGETS tflite_classify DESTINATION ${CMAKE_INSTALL_BINDIR})

runtime/infra/cmake/packages/TensorFlowLite/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ target_compile_options(tensorflow-lite
301301
PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS}
302302
)
303303
set_property(TARGET tensorflow-lite PROPERTY POSITION_INDEPENDENT_CODE ON)
304-
target_link_libraries(tensorflow-lite eigen flatbuffers::flatbuffers ruy abseil farmhash oourafft::fftsg2d pthreadpool Threads::Threads dl)
304+
target_link_libraries(tensorflow-lite eigen flatbuffers::flatbuffers ruy abseil farmhash oourafft::fftsg2d pthreadpool Threads::Threads ${CMAKE_DL_LIBS})
305305
if(NOT ANDROID)
306306
target_link_libraries(tensorflow-lite rt)
307307
endif()

runtime/onert/backend/cpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ target_link_libraries(${TEST_ONERT_CPU_BACKEND} ${LIB_ONERT_BACKEND_CPU})
4343
# Requires linking nnfw_coverage: check header coverage
4444
target_link_libraries(${TEST_ONERT_CPU_BACKEND} nnfw_common nnfw_coverage)
4545
target_link_libraries(${TEST_ONERT_CPU_BACKEND} onert_core)
46-
target_link_libraries(${TEST_ONERT_CPU_BACKEND} gtest gtest_main dl Threads::Threads)
46+
target_link_libraries(${TEST_ONERT_CPU_BACKEND} gtest gtest_main Threads::Threads)
4747

4848
# Set install rpath to find onert_core, onert_backend_cpu, etc
4949
set_target_properties(${TEST_ONERT_CPU_BACKEND} PROPERTIES

runtime/onert/backend/train/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ target_link_libraries(${TEST_ONERT_TRAIN_BACKEND} ${LIB_ONERT_BACKEND_TRAIN})
3131
# Requires linking nnfw_coverage: check header coverage
3232
target_link_libraries(${TEST_ONERT_TRAIN_BACKEND} nnfw_common nnfw_coverage)
3333
target_link_libraries(${TEST_ONERT_TRAIN_BACKEND} onert_core)
34-
target_link_libraries(${TEST_ONERT_TRAIN_BACKEND} gtest gtest_main dl Threads::Threads)
34+
target_link_libraries(${TEST_ONERT_TRAIN_BACKEND} gtest gtest_main Threads::Threads)
3535

3636
# Set install rpath to find onert_core, onert_backend_train, etc
3737
set_target_properties(${TEST_ONERT_TRAIN_BACKEND} PROPERTIES

runtime/onert/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target_link_libraries(onert_core PRIVATE jsoncpp half)
3333
target_link_libraries(onert_core PRIVATE nnfw_lib_misc nnfw_lib_cker)
3434
target_link_libraries(onert_core PRIVATE nnfw_common)
3535
target_link_libraries(onert_core PRIVATE nnfw_coverage)
36-
target_link_libraries(onert_core PRIVATE dl Threads::Threads)
36+
target_link_libraries(onert_core PRIVATE ${CMAKE_DL_LIBS} Threads::Threads)
3737

3838
# Ruy
3939
nnfw_find_package(Ruy REQUIRED)
@@ -74,7 +74,7 @@ add_executable(${TEST_ONERT_CORE} ${TESTS})
7474
target_link_libraries(${TEST_ONERT_CORE} onert_core)
7575
# Requires linking nnfw_coverage: check header coverage
7676
target_link_libraries(${TEST_ONERT_CORE} nnfw_common nnfw_coverage)
77-
target_link_libraries(${TEST_ONERT_CORE} gtest gtest_main dl Threads::Threads)
77+
target_link_libraries(${TEST_ONERT_CORE} gtest gtest_main ${CMAKE_DL_LIBS} Threads::Threads)
7878

7979
add_test(${TEST_ONERT_CORE} ${TEST_ONERT_CORE})
8080
set_target_properties(${TEST_ONERT_CORE} PROPERTIES

0 commit comments

Comments
 (0)