[CMake] How to start CMake from scratch
Eric Noulard
eric.noulard at gmail.com
Fri Apr 20 07:44:05 EDT 2012
2012/4/20 Christian Arnault <arnault at lal.in2p3.fr>:
> Hi
>
> [I am on windows]
>
> If I use cmake-gui to build my project, it starts asking me for the build
> directory. Which is OK!
>
> (my project is named "B", it stands in "test/B", where there is a
> "test/B/CMakeLists.txt" and I want to build into "test/B/build")
>
> Now, if I use command interface CMake as follows (with an empty build
> directory):
>
>> cd test
>> cmake B --build B\build
>
> CMake Error: The source directory "C:/Arnault/CMT2/test/B/build" does not
> appear to contain CMakeLists.txt.
> Specify --help for usage, or press the help button on the CMake GUI.
The doc says:
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
so you may only give **either** a source dir or an **EXISTING** build dir
to cmake command line.
--build <dir> = Build a CMake-generated project binary tree.
again this option supposes the build <dir> exists and contains
a previously generated binary tree.
> If I first run cmake-gui, and specify the build directory, it's OK and it
> properly populates the cache.
>
> if now, I redo (command line but with a build directory already populated) :
>
>> cmake B --build B\build
>
> it's all ok now!!
>
> Question: How to start a build from scratch, using the command line, and
> specifying a build out-the-source ?
1) you first go into your pristine build dir
cd B\build
2) Then you invoke cmake giving only 1 argument which is
the source dir
cmake ..
(or cmake /path/to/source/dir if the build dir is not relative to
source dir)
If you are new with CMake you find it useful to go through this presentation
https://github.com/TheErk/CMake-tutorial/blob/master/CMake-tutorial-8feb2012.pdf?raw=true
--
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
More information about the CMake
mailing list