Skip to content

Commit aa27c35

Browse files
author
aidan.belton
committed
Update CMake based on feedback
1 parent d250087 commit aa27c35

File tree

5 files changed

+34
-86
lines changed

5 files changed

+34
-86
lines changed

sycl/plugins/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,37 @@ if (NOT MSVC)
2222
add_subdirectory(esimd_cpu)
2323
endif()
2424
endif()
25+
26+
set( SYCL_PLUGIN_TARGETS
27+
pi_opencl
28+
pi_level_zero)
29+
30+
if(SYCL_BUILD_PI_ESIMD_CPU)
31+
list(APPEND SYCL_PLUGIN_TARGETS pi_esimd_cpu)
32+
endif()
33+
34+
if(SYCL_BUILD_PI_CUDA)
35+
list(APPEND SYCL_PLUGIN_TARGETS pi_cuda)
36+
endif()
37+
38+
foreach(pi_plugin ${SYCL_PLUGIN_TARGETS})
39+
if (MSVC)
40+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
41+
# which are individually tagged for all pi* symbols in pi.h
42+
target_compile_definitions(${pi_plugin} PRIVATE __SYCL_BUILD_SYCL_DLL)
43+
else()
44+
# we set the visibility of all symbols 'hidden' by default.
45+
# In pi.h file, we set exported symbols with visibility==default individually
46+
target_compile_options(${pi_plugin} PUBLIC -fvisibility=hidden)
47+
48+
# This script file is used to allow exporting pi* symbols only.
49+
# All other symbols are regarded as local (hidden)
50+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
51+
52+
# Filter symbols based on the scope defined in the script file,
53+
# and export pi* function symbols in the library.
54+
target_link_libraries(${pi_plugin} PRIVATE "-Wl,--version-script=${linker_script}")
55+
endif()
56+
57+
endforeach()
58+

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,6 @@ target_link_libraries(pi_cuda
4545
cudadrv
4646
)
4747

48-
if (MSVC)
49-
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
50-
# which are individually tagged for all pi* symbols in pi.h
51-
target_compile_definitions(pi_cuda PRIVATE __SYCL_BUILD_SYCL_DLL)
52-
else()
53-
# we set the visibility of all symbols 'hidden' by default.
54-
# In pi.h file, we set exported symbols with visibility==default individually
55-
target_compile_options(pi_cuda PUBLIC -fvisibility=hidden)
56-
57-
# This script file is used to allow exporting pi* symbols only.
58-
# All other symbols are regarded as local (hidden)
59-
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
60-
61-
# Filter symbols based on the scope defined in the script file,
62-
# and export pi* function symbols in the library.
63-
target_link_libraries(pi_cuda PRIVATE "-Wl,--version-script=${linker_script}")
64-
endif()
65-
6648
add_common_options(pi_cuda)
6749

6850
install(TARGETS pi_cuda

sycl/plugins/esimd_cpu/CMakeLists.txt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,6 @@ add_library(pi_esimd_cpu SHARED
101101
"pi_esimd_cpu.cpp"
102102
)
103103

104-
if (MSVC)
105-
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
106-
# which are individually tagged for all pi* symbols in pi.h
107-
target_compile_definitions(pi_esimd_cpu PRIVATE __SYCL_BUILD_SYCL_DLL)
108-
else()
109-
# we set the visibility of all symbols 'hidden' by default.
110-
# In pi.h file, we set exported symbols with visibility==default individually
111-
target_compile_options(pi_esimd_cpu PUBLIC -fvisibility=hidden)
112-
113-
# This script file is used to allow exporting pi* symbols only.
114-
# All other symbols are regarded as local (hidden)
115-
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
116-
117-
# Filter symbols based on the scope defined in the script file,
118-
# and export pi* function symbols in the library.
119-
target_link_libraries( pi_esimd_cpu
120-
PRIVATE "-Wl,--version-script=${linker_script}"
121-
)
122-
endif()
123-
124104
add_dependencies(pi_esimd_cpu OpenCL-Headers)
125105
add_dependencies(pi_esimd_cpu cm-emu)
126106
add_dependencies(sycl-toolchain pi_esimd_cpu)

sycl/plugins/level_zero/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)
5858
DEPENDEES install
5959
)
6060

61-
if (WIN32)
62-
# Copy DLL into binary directory
63-
ExternalProject_Add_Step(level-zero-loader llvmbininstall
64-
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/bin/ ${LLVM_BINARY_DIR}/bin
65-
COMMENT "Installing level-zero-loader into the LLVM binary directory"
66-
DEPENDEES install
67-
)
68-
endif()
69-
7061
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/"
7162
DESTINATION "."
7263
COMPONENT level-zero-loader
@@ -119,26 +110,6 @@ add_library(pi_level_zero SHARED
119110
"${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.hpp"
120111
)
121112

122-
if (MSVC)
123-
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
124-
# which are individually tagged for all pi* symbols in pi.h
125-
target_compile_definitions(pi_level_zero PRIVATE __SYCL_BUILD_SYCL_DLL)
126-
else()
127-
# we set the visibility of all symbols 'hidden' by default.
128-
# In pi.h file, we set exported symbols with visibility==default individually
129-
target_compile_options(pi_level_zero PUBLIC -fvisibility=hidden)
130-
131-
# This script file is used to allow exporting pi* symbols only.
132-
# All other symbols are regarded as local (hidden)
133-
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
134-
135-
# Filter symbols based on the scope defined in the script file,
136-
# and export pi* function symbols in the library.
137-
target_link_libraries( pi_level_zero
138-
PRIVATE "-Wl,--version-script=${linker_script}"
139-
)
140-
endif()
141-
142113
if (TARGET level-zero-loader)
143114
add_dependencies(pi_level_zero level-zero-loader)
144115
endif()

sycl/plugins/opencl/CMakeLists.txt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,6 @@ target_link_libraries(pi_opencl
2828
OpenCL-Headers
2929
OpenCL-ICD
3030
)
31-
if (MSVC)
32-
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
33-
# which are individually tagged for all pi* symbols in pi.h
34-
target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL)
35-
else()
36-
# we set the visibility of all symbols 'hidden' by default.
37-
# In pi.h file, we set exported symbols with visibility==default individually
38-
target_compile_options(pi_opencl PUBLIC -fvisibility=hidden)
39-
40-
# This script file is used to allow exporting pi* symbols only.
41-
# All other symbols are regarded as local (hidden)
42-
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
43-
44-
# Filter symbols based on the scope defined in the script file,
45-
# and export pi* function symbols in the library.
46-
target_link_libraries( pi_opencl
47-
PRIVATE "-Wl,--version-script=${linker_script}"
48-
)
49-
endif()
5031

5132
add_common_options(pi_opencl)
5233

0 commit comments

Comments
 (0)