You got it pretty much right. The write CMakeLists.txt
> cmake
> make
sequence is correct.
Regarding different configurations (Debug vs. Release), you have to differentiate between multi-config generators (Visual Studio, XCode), and single-config generators (everything else). With the multi-config generators, you generate one buildsystem (e.g. solution file) which contains all configurations, and choosing between them happens at build time.
With single-config generators, different configurations are obtained by generating different buildsystems, that is, by running CMake multiple times in different directories (and with a different value of the CMAKE_BUILD_TYPE
CMake variable).
So you'd do something like this:
> cd my_project/bld/debug
> cmake ../../src -DCMAKE_BUILD_TYPE=Debug
> cd ../release
> cmake ../../src -DCMAKE_BUILD_TYPE=Release
Regarding editing the cache (usually through CMake GUI or ccmake
): you're right again, this largely corresponds to passing options to ./configure
from AutoMake world. This would be the typical workflow with a freshly downloaded project (using CMake GUI):
- Run CMake GUI, point it to the source directory (input) and binary directory (output) you want
- Configure. This will fill the cache with project-specified defaults. If CMake cannot find some dependencies of the project automatically, this will end with an error.
- Inspect the cache, change any values you don't like (such as compilation options), fill in any missing options (paths to libraries CMake couldn't find etc.)
- Repeat steps 2 & 3 until you're satisfied with the project's setup.
- Generate the buildsystem.
- Exit CMake GUI and build using the appropriate build tool.