diff --git a/CMakeLists.txt b/CMakeLists.txt index b1075c458..16793a431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ./idl.cmake ./idlrtc.cmake ./install-data.cmake + ./install-helpers.cmake ./julia.cmake ./kineo.cmake ./lapack.cmake @@ -101,6 +102,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 @@ -114,7 +117,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ./release.cmake ./relpath.cmake ./ros.cmake - ./ros2.cmake ./sdformat.cmake ./setup.cfg ./shared-library.cmake diff --git a/header.cmake b/header.cmake index 79a782e94..56ad62a21 100644 --- a/header.cmake +++ b/header.cmake @@ -170,11 +170,16 @@ function( EXPORT_SYMBOL ) generate_configuration_header_v2( - INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include - HEADER_DIR ${HEADER_DIR} - FILENAME ${FILENAME} - LIBRARY_NAME ${LIBRARY_NAME} - EXPORT_SYMBOL ${EXPORT_SYMBOL} + INCLUDE_DIR + ${CMAKE_CURRENT_BINARY_DIR}/include + HEADER_DIR + ${HEADER_DIR} + FILENAME + ${FILENAME} + LIBRARY_NAME + ${LIBRARY_NAME} + EXPORT_SYMBOL + ${EXPORT_SYMBOL} ) endfunction(GENERATE_CONFIGURATION_HEADER) @@ -271,19 +276,41 @@ 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 ...) +# ~~~ # # 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}") @@ -293,6 +320,7 @@ macro(HEADER_INSTALL FILES) FILES ${FILE} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DIR}" PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + COMPONENT ${_COMPONENT_NAME} ) endforeach() endmacro() diff --git a/install-helpers.cmake b/install-helpers.cmake new file mode 100644 index 000000000..ced94ca8c --- /dev/null +++ b/install-helpers.cmake @@ -0,0 +1,49 @@ +# 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 . + +# .rst: +# ~~~ +# .. command:: ADD_INSTALL_TARGET ( +# NAME +# COMPONENT ) +# ~~~ +# +# This function add a custom target named install- that will run cmake +# install for a specific . +# +# :param name: Target name suffix (install-). +# +# :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() diff --git a/python-helpers.cmake b/python-helpers.cmake index a8050e3be..13b5a6a9f 100644 --- a/python-helpers.cmake +++ b/python-helpers.cmake @@ -13,25 +13,82 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see . -# .rst: .. command:: PYTHON_INSTALL(MODULE FILE DEST) +# .rst: +# +# ~~~ +# .. command:: PYTHON_INSTALL( 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}" + COMPONENT ${_COMPONENT_NAME} ) endmacro() -# .rst: .. command:: PYTHON_INSTALL_ON_SITE (MODULE FILE) +# .rst: +# +# ~~~ +# .. command:: PYTHON_INSTALL_ON_SITE ( 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)