1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-09 01:07:16 +01:00
SqMod/module/Vendor/MDBC/cmake/symlink.cmake
2020-03-22 14:54:40 +02:00

38 lines
1.3 KiB
CMake

#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
MACRO(create_symlink symlink_name target install_path)
# According to cmake documentation symlinks work on unix systems only
IF(UNIX)
# Get target components
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
GET_FILENAME_COMPONENT(target_path ${target_location} PATH)
GET_FILENAME_COMPONENT(target_name ${target_location} NAME)
ADD_CUSTOM_COMMAND(
OUTPUT ${target_path}/${symlink_name}
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${target_path}/${symlink_name}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink ${target_name} ${symlink_name}
WORKING_DIRECTORY ${target_path}
DEPENDS ${target}
)
ADD_CUSTOM_TARGET(SYM_${symlink_name}
ALL
DEPENDS ${target_path}/${symlink_name})
SET_TARGET_PROPERTIES(SYM_${symlink_name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(CMAKE_GENERATOR MATCHES "Xcode")
# For Xcode, replace project config with install config
STRING(REPLACE "${CMAKE_CFG_INTDIR}"
"\${CMAKE_INSTALL_CONFIG_NAME}" output ${target_path}/${symlink_name})
ENDIF()
INSTALL(FILES ${target_path}/${symlink_name} DESTINATION ${install_path})
ENDIF()
ENDMACRO()