Files
rocm-systems/rdc-backward-compat.cmake
T
Ranjith Ramakrishnan 52a3463147 File reorganization with backward compatibility
SWDEV-291455 -  Binary , header files and libraries installed in bin,include and lib folder under /opt/rocm-ver
Prebuilt ras library with updated search path
cmake config files in lib/cmake/rdc
grpc,sp3,hsaco and private libraries installed in lib/rdc
config  installed in share/rdc
authentication and python_binding installed in libexec/rdc
Backward compatibility added for header files and libraries

Depends-On: I3f3d192935923f71737b3fe55ded536654a73dd7
Change-Id: Ia1a6cadc59034b155631a1ee5fdbe692d2a8a71b
2022-08-04 23:42:42 -07:00

81 lines
4.1 KiB
CMake

# Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
cmake_minimum_required(VERSION 3.16.8)
set(RDC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(RDC_WRAPPER_DIR ${RDC_BUILD_DIR}/wrapper_dir)
set(RDC_WRAPPER_INC_DIR ${RDC_WRAPPER_DIR}/include/rdc)
set(RDC_WRAPPER_LIB_DIR ${RDC_WRAPPER_DIR}/lib)
set(RDC_SRC_INC_DIR ${RDC_SRC_ROOT}/include/rdc)
#use header template file and generate wrapper header files
function(generate_wrapper_header)
file(MAKE_DIRECTORY ${RDC_WRAPPER_INC_DIR})
#Only rdc.h header file used in packaging
# set include guard
set(include_guard "RDC_WRAPPER_INCLUDE_RDC_H")
#set #include statement
set(file_name "rdc.h")
set(include_statements "#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/rdc/${file_name}\"\n")
configure_file(${RDC_SRC_ROOT}/header_template.hpp.in ${RDC_WRAPPER_INC_DIR}/${file_name})
endfunction()
#function to create symlink to libraries
function(create_library_symlink)
file(MAKE_DIRECTORY ${RDC_WRAPPER_LIB_DIR})
set(LIB_RDC "librdc.so")
set(LIB_RDC_BOOTSTRAP "librdc_bootstrap.so")
set(LIB_RDC_CLIENT "librdc_client.so")
set(MAJ_VERSION "${VERSION_MAJOR}")
set(SO_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}")
set(library_files "${LIB_RDC}" "${LIB_RDC}.${MAJ_VERSION}" "${LIB_RDC}.${SO_VERSION}")
set(library_files "${library_files}" "${LIB_RDC_BOOTSTRAP}" "${LIB_RDC_BOOTSTRAP}.${MAJ_VERSION}" "${LIB_RDC_BOOTSTRAP}.${SO_VERSION}" )
set(library_files "${library_files}" "${LIB_RDC_CLIENT}" "${LIB_RDC_CLIENT}.${MAJ_VERSION}" "${LIB_RDC_CLIENT}.${SO_VERSION}" )
foreach(file_name ${library_files})
add_custom_target(link_${file_name} ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink
../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RDC_WRAPPER_LIB_DIR}/${file_name})
endforeach()
# Symlink for private libraries
set(LIB_RDC_ROCR "librdc_rocr.so")
set(LIB_RDC_RAS "librdc_ras.so")
set(LIB_RDC_CLIENT_SMI "librdc_client_smi.so")
set(library_files "${LIB_RDC_ROCR}" "${LIB_RDC_ROCR}.${MAJ_VERSION}" "${LIB_RDC_ROCR}.${SO_VERSION}" )
set(library_files "${library_files}" "${LIB_RDC_CLIENT_SMI}" "${LIB_RDC_CLIENT_SMI}.${MAJ_VERSION}" "${LIB_RDC_CLIENT_SMI}.${SO_VERSION}" )
set(library_files "${library_files}" "${LIB_RDC_RAS}")
foreach(file_name ${library_files})
add_custom_target(link_${file_name} ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink
../../${CMAKE_INSTALL_LIBDIR}/${RDC}/${file_name} ${RDC_WRAPPER_LIB_DIR}/${file_name})
endforeach()
endfunction()
#Use template header file and generate wrapper header files
generate_wrapper_header()
install(DIRECTORY ${RDC_WRAPPER_INC_DIR} DESTINATION DESTINATION ${RDC_CLIENT_INSTALL_PREFIX}/${RDC}/include COMPONENT ${CLIENT_COMPONENT})
# Create symlink to library files
create_library_symlink()
install(DIRECTORY ${RDC_WRAPPER_LIB_DIR} DESTINATION ${RDC_CLIENT_INSTALL_PREFIX}/${RDC} COMPONENT ${CLIENT_COMPONENT})