Some good practices need to be applied when building with CMake on Linux. Assume the source files are laid out like this:
CMakeLists.txt
src
├── hello.cpp
└── hello.h
The general practice is to create a separate build
directory and build from there:
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ./hello
This keeps the files generated by CMake and the files generated by make apart from your source files. This also makes it easy to clean up files.
If you make any changes to CMakeLists.txt
, then just delete the contents of the build
directory. If you need to rebuild source files then use make clean
.
Tried with: CMake 2.8.7 and Ubuntu 12.04 LTS