Repository clean up - cmake

I am adding Conan support to my CMake projects. I followed Recipe and sources in the same repo tutorial and I end up with the expected package. Exploring the local repository folder, I found out that my source files are copied in 3 different folders (source, build and export_source) so the repo is growing fast even with small projects.
Is there a way to clean repository folders where sources are duplicated, after package creation (keeping only the folder needed for "dependency build from sources")?

Sure, you can remove things from the cache with the conan remove command. In this case you probably want to do:
conan remove "*" -s -b -f
* to match all packages in your local cache
-s to remove the source folders
-b to remove the build folders
-f to not ask for confirmation
The sources stored together with the conanfile.py in the cache, can't be removed, cause they are stored with the conanfile to be able to rebuild from sources when conan install --build is done.

Related

CMake support "make uninstall"?

I am trying to find some sudo-free solution to enable my users install and unistall my application. Using
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/opt/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}/")
SET(CMAKE_INSTALL_RPATH "$ENV{HOME}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}/")
I can direct the files to the user's home directory, and
make install
works fine. With reference to
What's the opposite of 'make install', ie. how do you uninstall a library in Linux?
I did not find any idea, which is sudo-free and is not complex for a non-system-admin person.
Is anyhow make uninstall supported by CMake?
My uninstall is quite simple: all files go in a subdirectory of the user's home. In principle, removed that new subdirectory could solve the problem. Has make install, with parameters above, any side effect, or I can write in my user's guide that the newly produced subdirectory can be removed as 'uninstall'?
If you want to add an uninstall target you can take a look to the official CMake FAQ at:
https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
If you just want a quick way to uninstall all files, just run:
xargs rm < install_manifest.txt
install_manifest.txt file is created when you run make install.
No there is not. See in the FAQ from CMake wiki:
By default, CMake does not provide the "make uninstall" target, so you
cannot do this. We do not want "make uninstall" to remove useful files
from the system.
If you want an "uninstall" target in your project,
then nobody prevents you from providing one. You need to delete the
files listed in install_manifest.txt file. [followed by some example code]
Remove files and folders (empty only) added by make install from a cmake project:
cat install_manifest.txt | sudo xargs rm
cat install_manifest.txt | xargs -L1 dirname | sudo xargs rmdir -p
The second command will print a bunch of errors because it recursively deletes folders until it finds one that is not empty. I like seeing those errors to know which folders are left. If you want to hide these errors you can add --ignore-fail-on-non-empty to rmdir.
From the source folder:
open install_manifest.txt (created by make install)
remove all the directories/files listed
remove any remaining files you missed:
xargs rm < install_manifest.txt
remove any hidden directories/files:
$rm -rf ~/.packagename
Remove the source folder.
# make uninstall
add_custom_target("uninstall" COMMENT "Uninstall installed files")
add_custom_command(
TARGET "uninstall"
POST_BUILD
COMMENT "Uninstall files with install_manifest.txt"
COMMAND xargs rm -vf < install_manifest.txt || echo Nothing in
install_manifest.txt to be uninstalled!
)
Add this to CMakeLists.txt, then an uninstall target is made by hand.
One solution is to use packaging with CPack. In Linux, that will create a package that can be installed/uninstalled by your package manager. In Windows with the NSIS generator, you'll get an installer which also deploys uninstall.exe to your program files.
Here's a basic example of creating a debian package:
$ touch file
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
install(FILES file DESTINATION etc)
set(CPACK_PACKAGE_NAME foo)
set(CPACK_PACKAGE_CONTACT "me <me#example.com>")
set(CPACK_GENERATOR DEB)
include(CPack)
$ cmake .
$ cpack
Then instead of make install DESTDIR=/usr/local use sudo dpkg -i foo-0.1.1-Linux.deb.
To uninstall use sudo dpkg -P foo or sudo apt purge foo.
The advantage of using a package manager over make install are numerous. Here are a few:
If you lose the source code, you can still uninstall the software.
If you dpkg -S /etc/foo, it will tell you which package "owns" this file.
If you want to install a new version of the software, you won't need to manually uninstall the previous version. It's all automatic.
You can publish the package so others can install it.
If your package deploys a file that is also owned by another package, it will fail to install. That's good because it prevents you from accidentally destroying other packages.
You have the ability to add scripts to the installation. Instead of simply copying files, you can add system users, enable serves, or perform compatibility operations on old databases during upgrade.

CMake error not providing FindGnuradio.cmake

Getting the following error when running cmake and am unsure how to fix it. It seems like it's telling me exactly what to do, but not very familiar with Linux.
CMake Error at CMakeLists.txt:153 (find_package):
By not providing "FindGnuradio.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Gnuradio",
but CMake did not find one.
Could not find a package configuration file provided by "Gnuradio"
(requested version 3.7.3) with any of the following names:
GnuradioConfig.cmake
gnuradio-config.cmake
Add the installation prefix of "Gnuradio" to CMAKE_PREFIX_PATH or set
"Gnuradio_DIR" to a directory contaning one of the above files. If
"Gnuradio" provides a separate development package or SDK, be sure it has
been installed.
EDIT: So I've located something called FindGnuradioRuntime.cmake but am still unsure what to do with it. The error message makes me think it was looking for something named "FindGnuradio.cmake" when it was actually called "FindGnuradioRuntime.cmake"
Commands that were run on a fresh Ubuntu install:
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr/
mkdir build
cd build/
cmake ../ (here is where I ran into a the problem above)
Install / build GNU Radio.
Remove the CMakeCache.txt
When you call cmake .. you can pass arguments. Add the path to the parent directory of GnuradioConfig.cmake or FindGnuRadio.cmake as in
cmake -DCMAKE_PREFIX_PATH=/gnu/radio/path ..
Making my somewhat hidden response an actual answer:
Just found out that the install script provided on GNURadio's website not only installs GNURadio, but also the RTL SDR requirements as well, so I wiped my VM and started over and was successful. It takes a few hours, but it is complete and automated so definitely the best way to install GNURadio. Script is here http://www.sbrac.org/files/build-gnuradio
As previous answers noted you didn't describe where you ran into this problem. I'm going to assume it happened when creating an Out Of Tree (OOT) module.
On the OOT Module Page, see the "Notes" Section. They note that you need to install gr-dev. That package will install GnuradioConfig.cmake. You can find it in the standard yum repos, and install it with sudo yum install gnuradio-devel.

Where are makepkg outputs packages built?

I'm trying to install a AUR package.
It seems easy, and I follow the Wiki description for it.
I downloaded the tarball, did makepkg -S to download the source and build it.
Apparently no error messages at output.
The process created some tar.gz files, that I tried to target when I use pacman -U
But none of them is the file expected by this command,
'missing metadata package in' ....
I did a research on web. I found that the place that makepkg output the package for Pacman is set in makepkg.conf, using PKGDEST item.
I changed that in /etc/makepkg.conf. It didn't create any file in that place when I tried to make that AUR package again (makepkg -S -f).
How to find the package for Pacman? Did the build go wrong and have no obvious message?
--Well .. after hours of search.. i give up and installed yaourt.. using that this to insall my package
According to https://wiki.archlinux.org/index.php/Makepkg and my firsthand experience, they are put into the working directory by default:
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where makepkg is run by default.

To install matplotlib from source, what is the source tree

I am trying to use the module "plot_trisurf()" in matplotlib. My python compile gives an error that axes3D does not contain the module. I want to install the latest version of matplotlib.
I would like to use the steps provided here: http://matplotlib.org/faq/installing_faq.html
In source install, step 2 is "delete the build directory in source tree". What is the source tree and where do i find the right build directory to delete?
Any suggestions are appreciated. Thank you for your time.
The source tree is under what ever directory you clone the git repo into or unpack the tarball into. It will contain a whole bunch (~30) of folders and files including lib, CXX, and INSTALL. If you have previously built matplotlib there will be a folder build where the results of the build are stored, if you have not yet run your first build it will not exist.
If you have cloned the git repo the following:
git clean -f -d -x
will remove any untracked files for you.

Adding files to .gitignore doesn't remove them from "untracked files"?

I recently started using git-svn, and tried to tell Git to ignore any files that the Subversion repo ignores (mostly binaries and object files), by running "git svn show-ignore >> .gitignore"
Then I ran git status, and saw that many of those files that are now on my .gitignore list, are still showing up under "untracked files". Why? What do I need to do to fix this?
Or am I going about this the wrong way? I just want to be able to run "git add ." without it adding in all that junk to the commit.
Thanks.
If you already imported those files in the Git repo, they won't be ignored until you git rm --cached them.
You need to remove those file from the Git index (hence the --cached option), before seeing the .gitignore working.