Difference between revisions of "CMake"
(→) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
== General == | == General == | ||
− | CMake is especially useful if an application depends on several other directories (e.g. libraries) in addition to code or if certain parts need to be compiled and linked in a specific order. The build process is controlled by CMakeLists.txt files which consist of commands and arguments and must be present in all directories, including subdirectories. It is possible to use both predefined and custom commands. | + | CMake is especially useful if an application depends on several other directories (e.g. libraries) in addition to code or if certain parts need to be compiled and linked in a specific order. The build process is controlled by ''CMakeLists.txt'' files which consist of commands and arguments and must be present in all directories, including subdirectories. It is possible to use both predefined and custom commands. |
== Interactive usage == | == Interactive usage == | ||
+ | |||
+ | In a typical compile/build prcedure, you create a new build directory, change into it, and call 'cmake' pointing to the directory where the ''CMakeLists.txt'' file is in: | ||
+ | |||
+ | mkdir Build; cd Build; cmake .. | ||
In order to modify the settings for the build process in an interactive GUI, change to the "build" directory of your project and execute the following command: | In order to modify the settings for the build process in an interactive GUI, change to the "build" directory of your project and execute the following command: |
Latest revision as of 09:23, 12 June 2020
CMake is an open-source cross-platform build system generator.
General
CMake is especially useful if an application depends on several other directories (e.g. libraries) in addition to code or if certain parts need to be compiled and linked in a specific order. The build process is controlled by CMakeLists.txt files which consist of commands and arguments and must be present in all directories, including subdirectories. It is possible to use both predefined and custom commands.
Interactive usage
In a typical compile/build prcedure, you create a new build directory, change into it, and call 'cmake' pointing to the directory where the CMakeLists.txt file is in:
mkdir Build; cd Build; cmake ..
In order to modify the settings for the build process in an interactive GUI, change to the "build" directory of your project and execute the following command:
ccmake .
This will give you an overview of all arguments for the build process in alphabetical order. You can edit an option by pressing [enter]. Afterwards, make sure to configure your settings by pressing [c] and then [g] to generate, so that your changes will go into effect during the next build process.
Pitfalls
- CMake save very detailed and specialized information about software used. In case of any version of software (e.g. compiler) changed this may result in strance errors even in case of minor version update. Re-run CMake configuration from scratch if any software component/version changed.
- If multiple versions of a kind of a software may be found on a system (e.g. a system compiler - gcc from Linux distribution - and a compiler of choise set up in $CC, $FC, $CXX envvars), CMake not always choose the one you would assume. Always check all components found by CMake about this is the version you would like to use.
- CMake evolve quite fast. New versions may resolve old issues and new ones. Stay tuned!
- If in doubt what's going on, verbosity can help: compile using 'make VERBOSE=1'