Set package_folder attribute of ConanFile instance before build #316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some of the C++ projects which use CMake as a build system have an install target. Their listsfiles already contain the definition of what and how should be installed. Defining the installation steps of the project in the
package
method of theConanFile
duplicates this information. Ideally I would like to maintain the code for installation at only one place.So for projects with an install target, in the
package
method of the ConanFile we can build the install target instead of defining again which files need to be copied.For this packaging method to work, the CMAKE_INSTALL_PREFIX of the project should be set at the CMake configuration step, when the
build
method is called, but at the moment thepackage_folder
attribute of theConanFile
instance is set only before thepackage
method is called.This PR fixes this issue by setting the
package_folder
attribute before thebuild
method is called. So in thebuild
method, the project can be configured with the right CMAKE_INSTALL_PREFIX and by building the install target in thepackage
method all the required files of the project would get installed in the package directory.