CMake Interview Questions
In this post we will look at CMake Interview questions. Examples are provided with explanation.
Q: What is CMake?
A: CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment. Simple configuration files placed in each source directory (called CMakeLists.txt files) are used to generate standard build files (e.g., makefiles on Unix and projects/workspaces in Windows MSVC) which are used in the usual way. CMake can generate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can therefore support multiple builds from a single source tree. CMake also supports static and dynamic library builds. Another nice feature of CMake is that it generates a cache file that is designed to be used with a graphical editor. For example, when CMake runs, it locates files, libraries, and executables, and may encounter optional build directives. This information is gathered into the cache, which may be changed by the user prior to the generation of the native build files.
Q: In which scenario to use CMake?
A: Consider a scenario where you are working on a cross platform project for C++ code. This code base is shared among platforms like Windows, Unix etc. And each platform has its own IDE like visual studio etc. Now if want to deploy a common artifact named test.cpp to these platforms then we will need to add it to all the tools