myx/MyxCMake/lib/macro/InstallRelative.cmake
2022-10-05 11:35:08 +03:00

20 lines
695 B
CMake

#[=======================================================================[.rst:
install_relative
----------------
#]=======================================================================]
macro(install_relative STRIP_DIRECTORY)
set(options)
set(oneValueArgs DESTINATION)
set(multiValueArgs FILES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(FILE ${ARG_FILES})
get_filename_component(DIR ${FILE} DIRECTORY)
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
endforeach()
endmacro(install_relative STRIP_DIRECTORY)