Reputation: 3812
1) When using cmake, is there a standard way to make the binaries be put in /usr/local/bin
?
I'm trying to better understand cmake, especially the major phases, which I think are configure, make, and install.
I want to better understand which directories are used by default and why, for these:
I'm pretty new to Linux and started by making a fresh version of cmake, (which I need to use for another project), as follows:
Download cmake's source file: cmake-3.6.2.tar.gz
from here.
Put it's contents into /usr/local/src/cmake-3.6.2
, (Debian Jessie).
Then run sudo ./configure
, sudo make
and finally sudo make install
.
By default it seemed to:
Read source from the place you explicitly tell it, e.g. cd /usr/local/src/project; cmake .
Use /usr/local/src/cmake-3.6.2
as it's working build directory, (perhaps because it was the current directory in step 1), creating many new directories and files there, and
Create its new executables in: /usr/local/src/cmake-3.6.2/bin
So I'm confused. I would have thought that by default a sudo install
would have installed cmake in such a way into my system as to make it generally visible anywhere.
??? I'm not sure, but think the best way to make system resources visible is to either 1) locate the binaries, or 2) soft links to them, in folders somewhere in the standard PATH
. In other words, don't extend PATH with each and every new set of binaries.
Is it possible to have cmake put the binaries in /usr/local/bin
by default?
Yes I can make manual bin links:
I'm not asking this question because making these links is hard, but because I think I might be missing something that just does this without me having to. Also bin files are just one of the outputs. There are also things like man pages and how do those get hooked up?
My standard path is .:/home/<myusername>/bin:/usr/local/bin:/usr/bin:/bin
.
So I created links in /usr/local/bin
pointing to these executables (using
cd /usr/local/bin; ln -s ../src/cmake-3.6.2/bin/*
).
Now I can run cmake --version
from anywhere.
I can also see that cmake uses two main directories
I noticing that cmake had not, by default, built the gui tool, so I found instructions (ref page) and built the gui tool, (and as above created a link to use it from within my standard path).
Then I opened the GUI tool and tried to re-make cmake.
But this is confusing because the "..build the binaries.." directory you give can:
1) Overlap the source directory in which case it merges lots of new files and folders into it, or
2) If set to something like /usr/local/bin
fills that with a bunch of junk which includes a secondary /bin
with the actual binaries, or
3) If set to some other location like possibly /usr/local/projectname/output
, still does not put the output binaries where they can automatically be used.
Is there a standard way to make the binaries be put in /usr/local/bin
?, (i.e. that my PATH will automatically pick up) or failing that, is the any simple and direct way to do this?
Tip:
Upvotes: 1
Views: 711
Reputation: 66338
Build directory is UNRELATED to the place, where deliverable files will be installed.
Build directory is a working directory, where compiler, linker and other tools generate deliverable files with some other auxiliary files. E.g., object files (.o
) are auxiliary files: they are produced by compiler, used by the linker and are never installed. Also, build directory contains Makefile
s and some other files, used by make
.
When install files, make install
takes deliverable files from build directory, and place them into their final locations. After that project is ready for use, and build directory can be removed.
Place, where deliverable files are installed, is controlled by variable
CMAKE_INSTALL_PREFIX
which you can set in cmake gui tool after the first configuration occures. Normally, binary files are installed into bin/
subdirectory relative to that prefix, so you may set CMAKE_INSTALL_PREFIX to /usr/local
for get executables being installed into /usr/local/bin/
.
As for build directory, you may create it anywhere. Usually, it is created in the directory where user has write access, so neither configuration nor build requires root priveleges. E.g., you may choose /home/<user>/cmake-build
.
Upvotes: 2