[CMake] Execute CMake process not working: source directory confusion

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Sep 28 12:53:17 EDT 2017


On 2017-09-28 12:18-0400 Michael Powell wrote:

> The outcome wasn't quite what I expected. How do I specify "path to
> source", where the source CMakeLists.txt is, properly. And the path to
> the build, where I want the build environment to land?
>
> With this scenario, currently things are landing "in the source
> directory", which is incorrect, not what I am expecting.
>
> Probably my confusion over, prefix directory? Or is "source" directory
> where things actually land?

The rule is the directory where you invoke cmake is always the
top-level directory of the build tree.  I would strongly advise that
should initially be an empty directory so you don't mix
cmake-generated files with anything else in that directory.

In my opinion, one of the warts of CMake is it allows you to invoke
cmake from the top-level directory of the source tree (e.g., using
"cmake ." which means the top-level directory of the build tree is
identical to the top-level directory of the source tree.  This
invocation (which unfortunately is often advocated by naive CMake
users, and, at least in the old days, by the CMake documentation
itself) scatters cmake-generated files all over your source tree which
makes it extremely difficult to restore your source tree to pristine
condition (without removing the whole source tree and starting over
with that using git clone, unpacking a tarball or whatever).  And, of
course, once you have designated the build-tree top-level, CMake
doesn't allow you to change it unless you start fresh.

In sum, to get out of this mess, you must both restore your source
tree to pristine condition, and invoke cmake from an initially empty
directory which will then become the top-level of your build tree
from then on.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list