Skip to content

Commit 52a63fa

Browse files
authored
[SYCL][CUDA] Fix CMake warning (#1301)
Stop calling target_link_libraries for a target from a different scope/ directory. Fixes CMake warning: ```sh -- Including the PI API CUDA backend. CMake Warning (dev) at /home/bjoern/Dev/stateray/wip/llvm/sycl/plugins/cuda/CMakeLists.txt:39 (target_link_libraries): Policy CMP0079 is not set: target_link_libraries allows use with targets in other directories. Run "cmake --help-policy CMP0079" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target sycl is not created in this directory. For compatibility with older versions of CMake, link library pi_cuda will be looked up in the directory in which the target was created rather than in this calling directory. This warning is for project developers. Use -Wno-dev to suppress it. ``` Signed-off-by: Bjoern Knafla <[email protected]>
1 parent d2633f6 commit 52a63fa

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,22 @@ add_dependencies(sycl-toolchain pi_cuda)
2929

3030
set_target_properties(pi_cuda PROPERTIES LINKER_LANGUAGE CXX)
3131

32-
target_include_directories(pi_cuda PRIVATE "${sycl_inc_dir}")
33-
34-
target_include_directories(pi_cuda INTERFACE ${CUDA_INCLUDE_DIRS})
32+
target_include_directories(pi_cuda
33+
PRIVATE
34+
${sycl_inc_dir}
35+
PUBLIC
36+
${CUDA_INCLUDE_DIRS}
37+
)
3538

3639
target_link_libraries(pi_cuda PUBLIC OpenCL-Headers cudadrv)
3740

38-
target_link_libraries(sycl INTERFACE pi_cuda)
39-
4041
add_common_options(pi_cuda)
4142

42-
target_compile_definitions(
43-
sycl PUBLIC USE_PI_CUDA
44-
)
45-
4643
install(TARGETS pi_cuda
4744
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_cuda
4845
RUNTIME DESTINATION "bin" COMPONENT pi_cuda
4946
)
47+
48+
# `sycl/source/CMakeLists.txt` adapted when SYCL_BUILD_PI_CUDA is defined:
49+
# target_link_libraries(sycl PUBLIC pi_cuda)
50+
# target_compile_definitions(sycl PUBLIC USE_PI_CUDA)

sycl/source/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,18 @@ function(add_sycl_rt_library LIB_NAME)
4848
target_include_directories(
4949
${LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} "${sycl_inc_dir}")
5050
target_link_libraries(${LIB_NAME}
51-
PRIVATE OpenCL::Headers
52-
PRIVATE ${OpenCL_LIBRARIES}
53-
PRIVATE ${CMAKE_DL_LIBS}
51+
PRIVATE
52+
OpenCL::Headers
53+
${OpenCL_LIBRARIES}
54+
${CMAKE_DL_LIBS}
55+
PUBLIC
56+
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:pi_cuda>
5457
)
5558

59+
target_compile_definitions(${LIB_NAME}
60+
PUBLIC
61+
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:USE_PI_CUDA>)
62+
5663
add_common_options(${LIB_NAME})
5764

5865
endfunction(add_sycl_rt_library)

0 commit comments

Comments
 (0)