Remove project name from headers dir if it already starts with it

This is useful if the repo contains headers in a directory called like the
project itself and should not have any effect on other projects.
This commit is contained in:
Martchus 2022-03-22 22:02:50 +01:00
parent f88ca7d16d
commit 28a35e9673
1 changed files with 7 additions and 0 deletions

View File

@ -514,6 +514,13 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
if (NOT META_IS_PLUGIN)
foreach (HEADER_FILE ${HEADER_FILES} ${ADDITIONAL_HEADER_FILES})
get_filename_component(HEADER_DIR "${HEADER_FILE}" DIRECTORY)
string(FIND "${HEADER_DIR}" "${META_PROJECT_NAME}/" HEADER_DIR_PRO)
if (HEADER_DIR STREQUAL META_PROJECT_NAME)
unset(HEADER_DIR)
elseif (HEADER_DIR_PRO EQUAL 0)
string(LENGTH "${META_PROJECT_NAME}/" HEADER_DIR_BEGIN)
string(SUBSTRING "${HEADER_DIR}" "${HEADER_DIR_BEGIN}" -1 HEADER_DIR)
endif ()
install(
FILES "${HEADER_FILE}"
DESTINATION "${INCLUDE_SUBDIR}/${META_PROJECT_NAME}/${HEADER_DIR}"