[feature] Allow specifying an install component for the CMake helper
See original GitHub issueOne 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.
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Here is a workaround that seems to work:
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 acomponent
argument to theCMake.install()
command would be ideal. This could just translate tocmake --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.