Skip to content

Commit

Permalink
cmake: use IMPORTED target for the threads library (ROCm#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
apwojcik authored Aug 6, 2023
1 parent 3499bc2 commit ae4cdf5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ project(migraphx LANGUAGES C CXX)
include(CTest)

find_package(ROCM REQUIRED)
find_package(Threads REQUIRED)

find_path(HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half)
if (NOT HALF_INCLUDE_DIR)
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ endif()
target_link_libraries(migraphx PRIVATE -ldl)

target_include_directories(migraphx SYSTEM PUBLIC $<BUILD_INTERFACE:${HALF_INCLUDE_DIR}>)

find_package(Threads)
target_link_libraries(migraphx PUBLIC Threads::Threads)

find_package(nlohmann_json 3.8.0 REQUIRED)
Expand Down
8 changes: 1 addition & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,11 @@ endfunction()

function(add_test_executable TEST_NAME)
add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
target_link_libraries(${TEST_NAME} ${CMAKE_THREAD_LIBS_INIT})

# Cmake does not add flags correctly for gcc
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set_target_properties(${TEST_NAME} PROPERTIES COMPILE_FLAGS -pthread LINK_FLAGS -pthread)
endif()
set(TEST_COMMAND ${TEST_NAME})
add_test_command(${TEST_NAME} ${TEST_COMMAND})
add_dependencies(tests ${TEST_NAME})
add_dependencies(check ${TEST_NAME})
target_link_libraries(${TEST_NAME} migraphx migraphx_onnx migraphx_ref)
target_link_libraries(${TEST_NAME} Threads::Threads migraphx migraphx_onnx migraphx_ref)
target_include_directories(${TEST_NAME} PUBLIC include)
endfunction(add_test_executable)

Expand Down

0 comments on commit ae4cdf5

Please sign in to comment.