Skip to content

Commit

Permalink
Use linker scripts instead of symlink. (#472)
Browse files Browse the repository at this point in the history
* Use linker scripts instead of symlink.

* Use same VERSION and SOVERSION

Since Python (or dlopen) is not able to follow chained linker scripts
set both properties to be the same, and use one linker script for .so
file which redirectes to .so.MAJOR.MINOR

* Execute linker script on Unix only

Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com>
  • Loading branch information
diptorupd and oleksandr-pavlyk authored May 26, 2021
1 parent 612fe24 commit 368911d
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,36 @@ target_link_libraries(DPCTLSyclInterface
PRIVATE ${IntelSycl_OPENCL_LIBRARY}
)

include(GetProjectVersion)
# the get_version function is defined in the GetProjectVersion module and
# defines: VERSION, SEMVER, MAJOR, MINOR, PATCH. These variables are populated
# by parsing the output of git describe.
get_version()
set_target_properties(DPCTLSyclInterface
PROPERTIES
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}
SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}
)

if(UNIX)
set(linker_script1
"INPUT(libDPCTLSyclInterface.so.${VERSION_MAJOR}.${VERSION_MINOR})"
)
add_custom_command(TARGET DPCTLSyclInterface POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E remove "libDPCTLSyclInterface.so"
COMMAND "${CMAKE_COMMAND}"
-E echo "${linker_script1}" > "libDPCTLSyclInterface.so"
VERBATIM
)
endif()

if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
target_include_directories(DPCTLSyclInterface
PRIVATE
${LEVEL_ZERO_INCLUDE_DIR}
)
endif()

# FIXME: Turning off for release until conda build can be packaging symbolic links
# NOTE: Till we hit 1.0.0 we will keep using the MINOR version to set the API
# version of the library.
# include(GetProjectVersion)
# the get_version function is defined in the GetProjectVersion module and
# defines: VERSION, SEMVER, MAJOR, MINOR, PATCH. These variables are populated
# by parsing the output of git describe.
# get_version()
# set_target_properties(DPCTLSyclInterface PROPERTIES VERSION ${VERSION_MINOR})
# set_target_properties(DPCTLSyclInterface PROPERTIES SOVERSION 1)

install(TARGETS
DPCTLSyclInterface
LIBRARY
Expand Down

0 comments on commit 368911d

Please sign in to comment.