Can you configure CMake to automatically install apt deb dependencies? - cmake

A debian package is built using CMake/CPack (CPACK_GENERATOR = "DEB")
The built package contains an executable and some shared objects.
One of the shared objects has a dependency on libjpeg.so.62, which should be installed in the system.
Is it possible to configure CMake to install libjepeg automatically via apt,
when my product is installed by running sudo apt install ./my.deb?

Related

How to create RPM package that uses setcap and works on both dnf/yum (fedora/redhat) and zypper (openSuse)

I'm developing an RPM package for a service that requires the command setcap for setting capabilities. The purpose of using setcap is to listen to port numbers below 1024.
RPM packages have a 'Requires' section that is a comma-separated list of other required packages, and in theory I can use that to make sure the target system installs the packages needed.
Now here's the problem:
setcap is available for Fedora in package libcap and for openSUSE in package libcap-progs.
the package libcap is not available on openSUSE, and libcap-progs is not available on Fedora.
Is it possible to create a single RPM package that installs setcap and works on both Fedora and openSUSE?
It's possible to write the following:
Requires: /usr/sbin/setcap
This will resolve on both Fedora and openSUSE to their corresponding library

How to build RPM for fedora/RH and DEB for debian/ubuntu with cpack on one machine

I want to generate .deb and .rpm packages from multiple CMake C++ projects with CPack.
This works, if i build .deb packages on debian and .rpm packages on Fedora. But if i build them cross-distro, they get the paths wrong.
Have a look at one of my libraries where i tried to set this up: https://github.com/tfc/pprintpp
My workflow is:
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr <src>
make
cpack -G DEB/RPM
The package contains:
headers
pkg-config file
cmake config file
When pkg-config and cmake are installed, they usually come with tools-specific search paths that are set distro-specific
If i use DEB on Fedora, the package installs libraries and pkgconfig/cmake files in /usr/lib64/... whereas cmake and pkg-config are configured to expect them in /usr/lib/<pkgconfig/cmake>.
If i use RPM on Debian, the package installs them in /usr/lib/... which is where Fedora doesn't look for them.
I need some way to generate such packages from one single distro, ideally even any distro.
Is there a way to instruct CMake and/or CPack to "do it right" without hardcoding too many things into my cmake files or calls?

CLion make install globally

I would like to build and install my project using CLion, however it must be installed globally (i.e. to /usr/local/lib/cmake/).
In bash I build with
make -j$(nproc)
sudo make install
and then run sudo ldconfig so that another app (gnuradio-companion) can find my project binaries.
When I run CLion as a regular user (non-root) and click Run > Install, I get
file INSTALL cannot set permissions on
"/usr/local/lib/cmake/
Is there any way to sudo make install and sudo ldconfig in CLion without starting CLion as root?

Yum install package and all its dependencies from local directory

I have downloaded a package and all of its dependencies using yum's download only option into a local directory. I want to then install the package and its dependencies from that directory by passing yum the name of the rpm that contains the primary package in a manner similar to how pip lets you install wheel packages from local directories (provided the wheel files for the dependencies are also present). I DO NOT want yum to try and download the dependencies from a remote repo.
Basically I want this only for yum:
pip install --no-index --find-link=/directory-with-wheel-files primary_package.whl
I have used these links to try and solve my problem:
How to make rpm auto install dependencies
https://unix.stackexchange.com/questions/281715/how-can-i-install-a-local-rpm-using-only-the-local-dependency-rpm-files?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
https://wiki.centos.org/HowTos/CreateLocalRepos
https://www.ostechnix.com/install-packages-specific-repository-linux/
My repo file looks like this:
[basemap]
name=Basemap
baseurl=file:///var/tmp/install/basemap
enabled=1
gpgcheck=0
and my folder /var/tmp/install/basemap has been turned into a repo using yum's createrepo. Yet when I run yum --enablerepo=basemap install primary_package.rpm yum still tries to download the dependencies from the internet. How do I force it to look in my local repo for the dependencies?
Figured it out. I had one option missing from my yum command. I had to disable other repos and then enable only my repo. This command worked:
yum --disablerepo='*' --enablerepo=myrepo install primary_package.rpm

How do I install libudev with cmake

I have a binary (c++) and I want to link against the libudev library. But I want my cmake file verified if the udev library it's installed. If not, download the package and install it. But the only away to install udev library (I think) it's by using sudo apt-get install libudev-dev package or something like that.
My question is: is possible, using a cmake file, download the libudev-dev package ?