multiple CMakeLists.txt files and preferred build location

345 views
Skip to first unread message

Trey Hunner

unread,
Oct 27, 2011, 12:03:48 PM10/27/11
to editor...@googlegroups.com
Once checking out the code our project can either be built from the top level directory or the src directory.

This works:
cmake src
make install

And so does this:
cd src
cmake .
make install

I'm not very familiar with how cmake projects usually work so I'm not sure which of these is preferred.  The README says to use the second method but the first one seems simpler.

Also the first method complains that cmake_minimum_required is not present (a warning, not an error).  This option is already in the top CMakeLists.txt file.  Do we need to add it to the one in src as well?

--
Trey Hunner

H Xu

unread,
Oct 27, 2011, 12:10:02 PM10/27/11
to editor...@googlegroups.com

It's not correct to run "cmake src" in the root directory of the
project. cmake should use the CMakeLists in the root directory but not
in the src. You should cd to the root dir of the project (not src) and
run "cmake .".

If you do not want a in-source build, you could do something like this:

$ cd /path/to/root/of/editorconfig
$ mkdir build
$ cd build
$ cmake ..

Maybe my words in INSTALL is misleading, I'll correct that.

Hong

Trey Hunner

unread,
Oct 27, 2011, 12:33:36 PM10/27/11
to editor...@googlegroups.com
That worked for me but only after I manually removed the make and cmake files generated by running cmake.

Is there anything like "cmake clean" that would remove the Makefile and all other files generated by cmake in the current directory?

--
Trey Hunner

H Xu

unread,
Oct 27, 2011, 10:39:25 PM10/27/11
to editor...@googlegroups.com

Currently I don't know any good way to make a "make distclean" feature
on cmake. Just remove the CMakeCache.txt is OK, you do not have to
remove so many files.

Hong

Reply all
Reply to author
Forward
0 new messages