question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] Allow specifying an install component for the CMake helper

See original GitHub issue

One is capable of passing --component to CMake’s --install command, however the same functionality is missing from the CMake helper’s install() method: https://docs.conan.io/en/latest/reference/build_helpers/cmake.html#install

Since Conan does not package CMake configs generated by recipes, in many cases the recipe can just define the runtime component and there won’t be a need to rmdir additional files.

I suggest adding a component=None argument to this method and restructuring it in terms of the cmake generated cmake_install.cmake script. The code would look something like this:

def install(... component=None):
    if component is not None:
        if isinstance(component, str):
            component_args = [f"-DCOMPONENT={component}"]
        else:
            component_args = [f"-DCOMPONENT={c}" for c in component]
    else:
        component_args = [""]
    for comp in component_args:
        self.run(f"cmake -DBUILD_TYPE={build_type} {comp} -P cmake_install.cmake", cwd=bindir)

or maybe a new method like install_component() with a required positional argument, if such a break for v2 is not desirable.
find -name conanfile.py -exec grep -nHEe '\.install\([^)]' {} \; shows no usage for this method being used with any arguments in CCI though.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stas-neverovcommented, Nov 29, 2022

Here is a workaround that seems to work:

    def package(self):
        self.run(f"cmake --install {self.build_folder} --component component1"
                 f" --prefix {os.path.join(self.package_folder, 'component1')}")
    
    def package_info(self):
        self.cpp_info.builddirs.append("component1")
1reaction
jwillikerscommented, Oct 17, 2022

I think this is still a pertinent issue for the new CMake build helper as projects may use component-based installs and the default install component may not install the necessary files. Adding the ability to specify a component argument to the CMake.install() command would be ideal. This could just translate to cmake --install ... --component <specified_component>. I have a use case right now where this is necessary as the default component actually installs a bunch of things that should not be installed but are because they are included from various subprojects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

install — CMake 3.25.1 Documentation
This command generates installation rules for a project. Install rules specified by calls to the install() command within a source directory are executed...
Read more >
Installing Files — Mastering CMake
CMake provides the install command to specify how a project is to be installed. This command is invoked by a project in the...
Read more >
CMake 3.25.1 Documentation
Specify the installation directory, used by the CMAKE_INSTALL_PREFIX variable. ... Enable warnings for usage of deprecated functionality, that are meant for ...
Read more >
Using Dependencies Guide — CMake 3.25.1 Documentation
The FetchContent module provides functionality to download content (typically sources, but can be anything) and add it to the main project if the...
Read more >
find_package — CMake 3.25.1 Documentation
The config and version files are typically installed as part of the package, ... Alternatively, this functionality can be enabled by setting the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found