Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forward COMPONENT parametert in install instruction #715

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
./idl.cmake
./idlrtc.cmake
./install-data.cmake
./install-helpers.cmake
./julia.cmake
./kineo.cmake
./lapack.cmake
Expand All @@ -95,6 +96,8 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
./openrtm.cmake
./oscheck.cmake
./package-config.cmake
./package.xml
./pixi.py
./pkg-config.cmake
./pkg-config.pc.cmake
./portability.cmake
Expand Down
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()
41 changes: 41 additions & 0 deletions install-helpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2024 INRIA.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.

# .rst:
# ~~~
# .. command:: ADD_INSTALL_TARGET (
# NAME <name>
# COMPONENT <component>)
# ~~~
#
# This function add a custom target named install-<name> that will run cmake
# install for a specific <component>.
#
# :param name: Target name suffix (install-<name>).
#
# :param component: component to install.
function(ADD_INSTALL_TARGET)
set(options)
set(oneValueArgs NAME COMPONENT)
set(multiValueArgs)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN})
set(target_name install-${ARGS_NAME})
set(component ${ARGS_COMPONENT})

add_custom_target(
${target_name} COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${component} -P
${PROJECT_BINARY_DIR}/cmake_install.cmake)
endfunction()
57 changes: 52 additions & 5 deletions python-helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,70 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

# .rst: .. command:: PYTHON_INSTALL(MODULE FILE DEST)
# .rst:
#
# ~~~
# .. command:: PYTHON_INSTALL(<module> <file> <dest> COMPONENT <component>)
# ~~~
#
# Compile and install a Python file.
#
# :param module: Python module name.
#
# :param file: Python file name.
#
# :param file: Installation directory.
#
# :param component: Component to forward to install command.
macro(PYTHON_INSTALL MODULE FILE DEST)
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()

python_build("${MODULE}" "${FILE}")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}"
DESTINATION "${DEST}/${MODULE}")
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}"
DESTINATION "${DEST}/${MODULE}"
COMPONENT ${_COMPONENT_NAME})
endmacro()

# .rst: .. command:: PYTHON_INSTALL_ON_SITE (MODULE FILE)
# .rst:
#
# ~~~
# .. command:: PYTHON_INSTALL_ON_SITE (<module> <file> COMPONENT <component>)
# ~~~
#
# Compile and install a Python file in :cmake:variable:`PYTHON_SITELIB`.
#
# :param module: Python module name.
#
# :param file: Python file name.
#
# :param component: Component to forward to install command.
macro(PYTHON_INSTALL_ON_SITE MODULE FILE)
python_install("${MODULE}" "${FILE}" ${PYTHON_SITELIB})
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()

python_install("${MODULE}" "${FILE}" ${PYTHON_SITELIB} COMPONENT
${_COMPONENT_NAME})
endmacro()

# PYTHON_BUILD_GET_TARGET(TARGET)
Expand Down
Loading