Change the way of linking dl lib

This commit is contained in:
Changming Sun 2019-03-07 10:51:55 -08:00
parent b183df7143
commit 93bbb42e75
3 changed files with 6 additions and 8 deletions

View file

@ -535,7 +535,7 @@ else()
if(onnxruntime_USE_NSYNC)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync_cpp)
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES Threads::Threads)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} Threads::Threads)
set(onnxruntime_EXTERNAL_LIBRARIES_DEBUG ${onnxruntime_EXTERNAL_LIBRARIES})
endif()

View file

@ -37,11 +37,9 @@ source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_common_src})
add_library(onnxruntime_common ${onnxruntime_common_src})
if(NOT WIN32)
target_link_libraries(onnxruntime_common dl)
endif()
onnxruntime_add_include_to_target(onnxruntime_common gsl date)
target_include_directories(onnxruntime_common PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public")
target_include_directories(onnxruntime_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT}
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public")
if(onnxruntime_USE_NSYNC)
target_compile_definitions(onnxruntime_common PUBLIC USE_NSYNC)
endif()

View file

@ -9,7 +9,6 @@ endif()
set(disabled_warnings)
set(extra_includes)
function(AddTest)
cmake_parse_arguments(_UT "DYN" "TARGET" "LIBS;SOURCES;DEPENDS" ${ARGN})
if(_UT_LIBS)
@ -30,9 +29,10 @@ function(AddTest)
add_dependencies(${_UT_TARGET} ${_UT_DEPENDS} eigen)
endif(_UT_DEPENDS)
if(_UT_DYN)
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest gmock onnxruntime Threads::Threads)
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest gmock onnxruntime ${CMAKE_DL_LIBS} Threads::Threads)
else()
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest gmock debug ${onnxruntime_EXTERNAL_LIBRARIES_DEBUG} optimized ${onnxruntime_EXTERNAL_LIBRARIES})
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest gmock debug ${onnxruntime_EXTERNAL_LIBRARIES_DEBUG}
optimized ${onnxruntime_EXTERNAL_LIBRARIES})
endif()
onnxruntime_add_include_to_target(${_UT_TARGET} gsl eigen)
target_include_directories(${_UT_TARGET} PRIVATE ${TEST_INC_DIR})