Skip to content

Commit

Permalink
header: Forward COMPONENT argument to install in header_install macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Sep 19, 2024
1 parent 31e4601 commit a0da65f
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions header.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,36 @@ endfunction(GENERATE_CONFIGURATION_HEADER_V2)
macro(_SETUP_PROJECT_HEADER_FINALIZE)
# If the header list is set, install it.
if(DEFINED ${PROJECT_NAME}_HEADERS)
foreach(FILE ${${PROJECT_NAME}_HEADERS})
header_install(${FILE})
endforeach(FILE)
header_install(${${PROJECT_NAME}_HEADERS})
endif(DEFINED ${PROJECT_NAME}_HEADERS)
endmacro(_SETUP_PROJECT_HEADER_FINALIZE)

# .rst: .. ifmode:: internal
#
# .. command:: HEADER_INSTALL (FILES)
# ~~~
# .. command:: HEADER_INSTALL (COMPONENT <component> <files>...)
# ~~~
#
# Install a list of headers.
#
macro(HEADER_INSTALL FILES)
# :param component: Component to forward to install command.
#
# :param files: Files to install.
macro(HEADER_INSTALL)
set(options)
set(oneValueArgs COMPONENT)
set(multiValueArgs)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN})

if(ARGS_COMPONENT)
set(_COMPONENT_NAME ${ARGS_COMPONENT})
else()
set(_COMPONENT_NAME ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
endif()

set(FILES ${ARGS_UNPARSED_ARGUMENTS})

foreach(FILE ${FILES})
get_filename_component(DIR "${FILE}" PATH)
string(REGEX REPLACE "${CMAKE_BINARY_DIR}" "" DIR "${DIR}")
Expand All @@ -263,6 +280,7 @@ macro(HEADER_INSTALL FILES)
install(
FILES ${FILE}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DIR}"
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
COMPONENT ${_COMPONENT_NAME})
endforeach()
endmacro()

0 comments on commit a0da65f

Please sign in to comment.