9
9
#TODO: remove dependency on pi.hpp in sycl project.
10
10
#TODO: Currently, the pi.hpp header is common between sycl and plugin library sources.
11
11
#This can be changed by copying the pi.hpp file in the plugins project.
12
- configure_file (
13
- ${CMAKE_CURRENT_SOURCE_DIR} /../../source/version.rc.in
14
- ${CMAKE_CURRENT_BINARY_DIR} /version.rc
15
- @ONLY )
16
12
17
13
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
18
- add_library (pi_opencl SHARED
14
+
15
+ # We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target.
16
+ # MODULE will limit this library to be used to load symbols via dllopen only
17
+ add_library (pi_opencl MODULE
19
18
"${sycl_inc_dir} /CL/sycl/detail/pi.h"
20
19
"pi_opencl.cpp"
21
- ${CMAKE_CURRENT_BINARY_DIR} /version.rc
22
20
)
23
21
24
22
add_dependencies (pi_opencl
@@ -33,13 +31,14 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX)
33
31
#preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl
34
32
target_include_directories (pi_opencl PRIVATE "${sycl_inc_dir} " )
35
33
34
+ target_link_libraries ( pi_opencl
35
+ PRIVATE OpenCL::Headers
36
+ PRIVATE ${OpenCL_LIBRARIES}
37
+ )
36
38
if (MSVC )
39
+ # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
40
+ # which are individually tagged for all pi* symbols in pi_opencl.cpp
37
41
target_compile_definitions (pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL )
38
- target_link_libraries (pi_opencl PRIVATE shlwapi )
39
- target_link_libraries ( pi_opencl
40
- PRIVATE OpenCL::Headers
41
- PRIVATE ${OpenCL_LIBRARIES}
42
- )
43
42
else ()
44
43
# we set the visibility of all symbols 'hidden' by default.
45
44
# In *.cpp files, we set exported symbols with visibility==default individually
51
50
52
51
#link pi_opencl with OpenCL headers and ICD Loader.
53
52
target_link_libraries ( pi_opencl
54
- PRIVATE OpenCL::Headers
55
- PRIVATE ${OpenCL_LIBRARIES}
56
53
# Filter symbols based on the scope defined in the script file,
57
54
# and export pi* function symbols in the library.
58
55
PRIVATE "-Wl,--version-script=${linker_script} "
@@ -61,9 +58,6 @@ endif()
61
58
62
59
add_common_options (pi_opencl )
63
60
64
- set_target_properties (pi_opencl PROPERTIES
65
- VERSION ${SYCL_VERSION_STRING}
66
- SOVERSION ${SYCL_MAJOR_VERSION} )
67
61
install (TARGETS pi_opencl
68
62
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX} " COMPONENT pi_opencl
69
63
RUNTIME DESTINATION "bin" COMPONENT pi_opencl )
0 commit comments