Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable hip-clang with cmake changes to link -lpthread and -lm #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ foreach(test_src ${rocRAND_TEST_SRCS})
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_link_libraries(${test_name} --amdgpu-target=${amdgpu_target})
endforeach()
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$")
# hip-clang needs specific flag to turn on pthread and m
target_link_libraries(${test_name} -lpthread -lm)
Copy link
Contributor

@jszuppe jszuppe Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be target_link_libraries(${test_name} m). As for pthread:

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)

should be in cmake/Dependencies.cmake (if it's needed only for tests then it should be in test dependencies section) and later target_link_libraries(${test_name} Threads::Threads). See https://cmake.org/cmake/help/latest/module/FindThreads.html

endif()
endif()
set_target_properties(
${test_name}
Expand Down Expand Up @@ -122,6 +126,10 @@ foreach(test_src ${hipRAND_TEST_SRCS})
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_link_libraries(${test_name} --amdgpu-target=${amdgpu_target})
endforeach()
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$")
# hip-clang needs specific flag to turn on pthread and m
target_link_libraries(${test_name} -lpthread -lm)
endif()
endif()
set_target_properties(${test_name}
PROPERTIES
Expand Down
8 changes: 8 additions & 0 deletions test/linkage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function(add_rocrand_link_test TEST_SOURCES)
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_link_libraries(${TEST_TARGET} --amdgpu-target=${amdgpu_target})
endforeach()
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$")
# hip-clang needs specific flag to turn on pthread and m
target_link_libraries(${TEST_TARGET} -lpthread -lm)
endif()
endif()
set_target_properties(
${TEST_TARGET}
Expand Down Expand Up @@ -106,6 +110,10 @@ function(add_hiprand_link_test TEST_SOURCES)
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_link_libraries(${TEST_TARGET} --amdgpu-target=${amdgpu_target})
endforeach()
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$")
# hip-clang needs specific flag to turn on pthread and m
target_link_libraries(${TEST_TARGET} -lpthread -lm)
endif()
endif()
set_target_properties(${TEST_TARGET}
PROPERTIES
Expand Down