-
Notifications
You must be signed in to change notification settings - Fork 981
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
Add cpack functionality to CMake build helpers #5655
Comments
Hi! Up to now, we haven't developed anything specific to packaging, we usually recommend to use the Nevertheless, that approach works only with the final artifacts, not with the CMake project, so this use-case is quite different, here we need to run it during creation of a package (stages Right now Maybe it is more natural to use the These are just ideas, not a solution. ping @SSE4, he will find this issue interesting as he's been gathering information about different packaging approaches. |
Yes, I agree that it is confusing to to call The CMake build helper can be made available in all functions, and then of course we can call the However, if it was bundled with the package, it could be later used in a deploy step, e.g. instead of collecting .so files together for a runtime, you could collect all The deployment on Linux is really still a pain point for our Conan workflow, because so far our team has not come to a good conclusion how to handle this. The last thing we want is to have a giant package with all .so files included, because it feels very unlike what you would do on Linux. It does have some overhead for creating the recipes, and we will have to make sure the libraries can be packaged with CPack. If not we might be able to fall back to using On Windows, we will just copy together all the dlls, and be done with it 😄 |
Hi @KerstinKeller ! You could use Conan hooks to run cpack after packaging your artifacts. Many time ago, when hooks was not available, I implemented the follow routine: def package(self):
...
def package_install(self):
if self.settings.os == "FreeBSD":
self.run("cpack -G TXZ")
self.copy("%s-%s.tar.xz" % (self.name, self.version), dst="package")
else:
package_type = 'RPM' if isfile('/etc/redhat-release') else 'DEB'
self.run('cpack -G %s ..' % package_type)
self.copy("%s-%s.%s" % (self.name, self.version, package_type.lower()), dst="package")
package_install() But now you try something more elaborated and safe: def post_package(output, conanfile, conanfile_path, **kwargs):
if self.settings.os == "FreeBSD":
conanfile.run("cpack -G TXZ")
conanfile.copy("%s-%s.tar.xz" % (conanfile.name, conanfile.version), dst="package")
else:
package_type = 'RPM' if os.path.isfile('/etc/redhat-release') else 'DEB'
conanfile.run('cpack -G %s ..' % package_type)
conanfile.copy("%s-%s.%s" % (conanfile.name, conanfile.version, package_type.lower()), dst="package") UPDATE: On Windows you can use Wix to generate .msi files, much better than NSIS. Reference: https://docs.conan.io/en/latest/reference/hooks.html Regards! |
Hi @uilianries, thanks for the suggestion. But I am not quite sure I fully understand. But actually changing still the package (e.g. adding the .deb) file to the package, I find a bit strange. But so far, I have not used any hooks, so not sure here. What kind of things are you generally performing with the Hooks? I have no problem implementing a hook the way you showed, but I wonder if CPack can always be called generically, without extra arguments. Also conceptionally, I wonder what to do with the And also thanks for mentioning Wix, we've already been using it on Windows. I agree it's better than NSIS, but there is way too little documentation out there for CPack integration. Expecially when performing tasks like setting Enviroment variables with the installer, adding custom icons etc. it's all trial and error 😄 |
Hi @KerstinKeller !
I agree, packaging .deb or any other installer file does not make any sense. But you can use the hook to upload to another server, like Bintray for general distribution. They offer free public repositories for organizations. About hooks, you can use to execute extra tasks which are not part of your recipe, like run a linter to check the quality of your recipe, sending an email/notification after uploading a new package version. We have a bunch of official hooks here.
I see, CPack offer a big amount of variables which can be configure in your cmake file. In my case, ALL variables were configured in my file, so I didn't need any extra definition when calling cpack. For example: # CMakeLists.txt
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_DESCRIPTION "My super project")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_VENDOR "ACME")
set(CPACK_PACKAGE_CONTACT "software@acme.com")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
include (CPack) You can find all supported variables here.
.deb or any other installer is separated from the package, because you would exporting a package in other package. So thinking again, instead of
In fact, the documentation is limited, but CMake offers a list of supported variables for CPackWIX. I remember that I spent few days configuring my first project with Wix, because I had some trouble installing Candle + Wix. The advantage is the .msi product, it's a native Windows installer, so any user can use the command line to install, much easier than a setup.exe with dialog boxes. |
I've been talking with debian and fedora package maintainers, and they strongly discourage the usage of CPack for .deb or .rpm generation. the reasons are:
source (in Russian) |
Great! Thanks @SSE4 for bringing this valuable info! |
Hi @SSE4, thanks for the info. I don't know if this thread is the correct point for discussion of this topic, but let me add a few points. So first I think you need to distinguish: do you want to create Debian packages to make contribution to official distributions, or do you want to create packages for an easy / safe way to provide your prebuild software for consumption on multiple machines inside your corporate network. Also, I know too little about traditional Debian package generation, to really argue the points. But I know, that with CMake, you can do a lot of things among which the above post claims that they aren't possible.
I think the biggest drawback with CPack Debian (or with CPack in general) is the poor documentation and the lack of examples. Unfortunately, I am not able to read / understand Russian in order to understand the original conversation 😞 |
With the new extensions points in Conan 2.0 (custom commands, deployers), this will not be implemented built-in in Conan. If any effort is done, I'd recommend doing it in the extensions repo: https://github.com/conan-io/conan-extensions. Closing this ticket, thanks! |
In our local workflow, we want to use conan for managing (build) dependencies, but (for now) we still want to create also deployment artefacts (e.g. debian packages or Windows installers).
(Similar to this ticket #3541)
So I am thinking of adding a
deploy()
functions to my recipes, which will callCPack
.For this it would be very helpful, if the
CMake
build helper also gained apackage
orcpack
method. (This is different tocmake.install()
as it will install to a specified folder.)It would be very similar to the
test
/install
methods, but instead of building theRUN_TESTS
/INSTALL
targets, it needs to build thePACKAGE
target.Also I am not quite sure if this method needs any arguments and which those would be.
(E.g. on Linux I often explicitly call
cpack -G DEB
.Would you consider adding such functionality?
However, I am not quite sure if the
deploy()
method would be the correct method to call thiscmake.package()
step, because according to the documentationdeploy()
gets executed when a dependent package callsconan install
on that package.I guess it would be "ortogonal" to the
package()
function, like anon_conan_package()
. That wouldn't be executed onconan create
, but rather for the local development workflow.The text was updated successfully, but these errors were encountered: