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

[FEA] Provide ability to setup default install name components per sub-project #582

Open
robertmaynard opened this issue Apr 11, 2024 · 0 comments
Labels
? - Needs Triage Need team to review and classify feature request New feature or request

Comments

@robertmaynard
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Most RAPIDS projects bring in thirdparty projects via rapids_cpm and either have them as part of the default ALL install set, or mark them EXCLUDE_FROM_ALL and therefore become uninstallable unless they have existing install(COMPONENT rules setup.

rapids-cmake can resolve these issues by marking each sub-project with default component names ( based on the project name ), and controls to overridable this default name when needed ( e.g. when we want all testing libraries to go into the testing component ).

Describe the solution you'd like

The solution is rather ingenious and proposed by Craig Scott.

What we have is a user function with the following call signature:

rapids_cmake_default_install_component(DEFAULT_USE_PROJECT_NAME)
rapids_cmake_default_install_component(PROJECT <name> INSTALL_COMPONENT_NAME <install_name>)

Which would have roughly the following implementation:

function(rapids_cmake_default_install_component )
  set(options DEFAULT_USE_PROJECT_NAME)
  set(one_value PROJECT INSTALL_COMPONENT_NAME)
  set(multi_value )
  cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})

  # Need to make sure we only install our project hook once
  get_property(already_hooked GLOBAL PROPERTY rapids_cmake_default_install_component_hook)
  if(NOT already_hooked)
    list(APPEND CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/default_install_component_hook.cmake")
    set(CMAKE_PROJECT_INCLUDE "${CMAKE_PROJECT_INCLUDE}" PARENT_SCOPE)

    set_property(GLOBAL PROPERTY rapids_cmake_default_install_component_hook ON)
  endif()

  if(_RAPIDS_DEFAULT_USE_PROJECT_NAME)
    set_property(GLOBAL PROPERTY rapids_cmake_default_install_component_names ON)
  endif()
  if(_RAPIDS_PROJECT AND _RAPIDS_INSTALL_COMPONENT)
    # Should only be set if the property doesn't already exist
    string(TOLOWER ${_RAPIDS_PROJECT} project)
    set_property(GLOBAL PROPERTY rapids_cmake_install_component_${project} ${_RAPIDS_INSTALL_COMPONENT})
  endif()
endfunction()

default_install_component_hook.cmake

string(TOLOWER ${PROJECT_NAME} project)

get_property(_rapids_install_default_name GLOBAL PROPERTY rapids_cmake_default_install_component_names)
get_property(_rapids_install_project_name GLOBAL PROPERTY rapids_cmake_install_component_${project})

if(_rapids_install_project_name)
  set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${_rapids_install_project_name}")
elseif(_rapids_install_default_name)
  set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${project}")
endif()

This would allow rapids-cmake users to have all projects have a component name that matches the project name, and the ability to override this when we need to move projects into collective groups like testing.

@robertmaynard robertmaynard added feature request New feature or request ? - Needs Triage Need team to review and classify labels Apr 11, 2024
@bdice bdice changed the title [FEA] Provide ability to setup default install name componens per sub-project [FEA] Provide ability to setup default install name components per sub-project Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant