1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-12 10:44:58 +03:00

Fix wrapper script generation

This commit is contained in:
Ron Isaacson
2020-06-29 23:04:35 -04:00
parent 853b4a57bc
commit 6fe678fe84
5 changed files with 21 additions and 12 deletions

View File

@ -1,17 +1,26 @@
if(UNIX)
# Creates wrapper scripts and installs them in the user's binaries directory, which is usually "/usr/local/bin".
# This is required because symlinks use the folder they are in as working directory.
macro(install_wrapper_script component target)
get_filename_component(file_name ${target} NAME)
#
# The actual wrapper script needs to be generated at install time, not build time, because it depends on the
# installation prefix. This is especially important when generating packages (rpm/deb) where the prefix is
# changed from /usr to /usr/local for the install step.
#
# The placeholder is needed to satisfy the "install" dependency scanner which runs early.
#
macro(install_wrapper_script component)
file(GENERATE OUTPUT ${BUILD_DIRECTORY}/${component}.sh
CONTENT "# placeholder\n"
)
file(WRITE ${TOP_DIRECTORY}/tmp/script/${file_name} "#!/bin/sh\n")
file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "${target} \"$@\"\n")
file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "exit $?\n")
install(CODE "file(WRITE ${BUILD_DIRECTORY}/${component}.sh \"#!/bin/sh\nexec \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/softether/${component}/${component} \\\"$@\\\"\n\")"
COMPONENT ${component}
)
install(FILES ${TOP_DIRECTORY}/tmp/script/${file_name}
install(PROGRAMS ${BUILD_DIRECTORY}/${component}.sh
COMPONENT ${component}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION bin
RENAME ${component}
)
endmacro(install_wrapper_script)
endif()