You are not logged in.
add_custom_target(makepkg_and_install
COMMAND cd ${CONFIGURED_FILES_ROOT}/installer/aur/for-cmake
COMMAND makepkg -i)
In vscode, error as below
[build] ==> Installing package cppjieba with pacman -U...
[build] sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
[build] sudo: a password is required
[build] ==> WARNING: Failed to install built package(s).
If manually run as in the custom target makepkg_and_install, it freezes after the zst file is genereated.
Question:
Is there anyway for cmake to ask for password just when installing in this case?
BTW, I think OS native pkg manger is the most robust and clean way for installation & uninstallation.
CMake's offical way for uninstallation using `install_manifest.txt` doesn't remove empty folders, and CMAKE_BINARY_DIR tends to change after installation, especially when developing.
Now CMake doesn't provide a universal way for clean uninstallation, so I choose to use aur for archlinux, is there any better alternative?
Last edited by followait (2021-08-21 03:50:17)
Offline
The whole concept sounds to me like a really really bad idea. Would you mind explaining the reason behind?
Offline
The whole concept sounds to me like a really really bad idea. Would you mind explaining the reason behind?
Because I want a clean uninstallation, and it's better not to depend on what's in CMAKE_BINARY_DIR, which is temporary.
I've posted the drawbacks for the cmake offical method (https://gitlab.kitware.com/cmake/commun … with-cmake).
A standalone PKGBUILD works, but it needs a new build.
Last edited by followait (2021-08-20 10:18:07)
Offline
Normally, you set up cmake to install directly into the filesystem, but with an install prefix. then you write a pkgbuild that calls cmake and sets the prefix to the packaging directory.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
Normally, you set up cmake to install directly into the filesystem, but with an install prefix. then you write a pkgbuild that calls cmake and sets the prefix to the packaging directory.
It works, but it can't utilize the already built results, it takes extra time, cpu and disk spaces.
When developing, it is common to install/uninstall a package, clean unstallation and efficient makepkg is more important.
Offline
It works, but it can't utilize the already built results,
Enabling ccache in makepkg.conf helps a lot with that and works with all build systems, not just cmake .
Also check https://wiki.archlinux.org/title/Makepk … and_tricks .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
It works, but it can't utilize the already built results,
Enabling ccache in makepkg.conf helps a lot with that and works with all build systems, not just cmake .
Also check https://wiki.archlinux.org/title/Makepk … and_tricks .
Good tool, but still needs to call makepkg -i manually.
Offline
calling makepkg -i inside cmake makes no sense
Offline
For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
calling makepkg -i inside cmake makes no sense
trying to encapluate it by cmake
Offline
For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).
I have already use configure_file to generate PKGBUILD to utilize things in CMAKE_BINARY_DIR
Do you mean cmake -E? It's mainly for crossplatform command like copy / copy_directory / echo, it might not help.
Last edited by followait (2021-08-20 13:21:35)
Offline
It seems that cpack supports aur pkg since version 3.16, https://cmake.org/cmake/help/git-stage/ … chive.html, hope .tar.zst in the doc is the same for aur pkg.
Last edited by followait (2021-08-20 14:49:21)
Offline
progandy wrote:For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).
I have already use configure_file to generate PKGBUILD to utilize things in CMAKE_BINARY_DIR
Do you mean cmake -E? It's mainly for crossplatform command like copy / copy_directory / echo, it might not help.
Not cmake -e, makepkg -e so sources are not extracted and prepare is skipped. build() calls make / ninja which should then only rebuild what has changed.
Offline
makepkg -e so sources are not extracted and prepare is skipped. build() calls make / ninja which should then only rebuild what has changed.
It is convenient, thanks.
Offline
A way in cmake is to use CPack External Generator (https://cmake.org/cmake/help/latest/cpa … -generator).
I think it'll save extra build times.
Offline
It's a bit confusing what you're trying to do, but why do you need to call `makepkg -i`? Did you consider breaking that down into two steps?
1) call `makepkg`
2) call `pacman -U <pkgname>` (or `sudo pacman -U <pkgname>`)
You can't use sudo with `makepkg` but you can with `pacman`.
Still, it seems better (cleaner responsibilities) not to mix and match package manager (pacman) with build system (cmake). I'd say, either:
1) fully use cmake to manage your installation (i.e. `cmake .` then `make` then `make install`)
2) OR use pacman to manage your installation (i.e. `cmake` + `make` in `build()` in your `PKGBUILD` then `make install` in `install()` in the `PKGBUILD`).
Last edited by thiagowfx (2021-08-21 02:16:47)
Offline
It's a bit confusing what you're trying to do, but why do you need to call `makepkg -i`? Did you consider breaking that down into two steps?
1) call `makepkg`
2) call `pacman -U <pkgname>` (or `sudo pacman -U <pkgname>`)You can't use sudo with `makepkg` but you can with `pacman`.
I've considered breaking `makepkg -i` down, but the <pkgname> varies.
Still, it seems better (cleaner responsibilities) not to mix and match package manager (pacman) with build system (cmake). I'd say, either:
1) fully use cmake to manage your installation (i.e. `cmake .` then `make` then `make install`)
2) OR use pacman to manage your installation (i.e. `cmake` + `make` in `build()` in your `PKGBUILD` then `make install` in `install()` in the `PKGBUILD`).
Yes, should not mix. My first idea is to override `cmake --install .`, but it can't be done by interface of cmake, and the native implementation for `cmake --install` might still be executed accidentally, anyway it is always there, I'm going to treat it as an internal function and never for real installation.
I'll try to use CPack External Generator.
Thanks
Last edited by followait (2021-08-21 03:47:21)
Offline
As a note, a better solution is to use a package manager like conan to solve the problem.
Offline
The simplest, most robust and most portable way is use -DCMAKE_INSTALL_PREFIX=/opt/mylib when installing,
layout after installation as below
/opt/mylib/include/...
/opt/mylib/lib/...
/opt/mylib/share/...
cmake's sophisticated search path should find it, at least when CMAKE_PREFIX_PATH contains /opt
uninstallation is as easy as delete a folder
Last edited by followait (2021-08-31 05:12:46)
Offline