Cmake Interview Questions & Answers

4 avg. rating (80% score) - 1 votes

Cmake Interview Questions

    1. Question 1. What Is Cmake?

      Answer :

      CMake is a cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform-independent and compiler-independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice.

      CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, preprocessor generation, code generation, and template instantiation.

    2. Question 2. I Want A New Feature In Cmake. What Should I Do?

      Answer :

      Report a feature request in our Bug tracker Please make sure to look at the old feature requests not to include duplicates, include detailed instructions of the feature and proposed implementation.

    3. Question 3. I Want A New Feature In Cmake. What Should I Do?report A Feature Request In Our Bug Tracker?

      Answer :

      Please make sure to look at the old feature requests not to include duplicates, include detailed instructions of the feature and proposed implementation.

    4. Question 4. What Is The Most Recent Version Covered By The Mastering Cmake Book?

      Answer :

      A new edition of the Mastering CMake book has been released which documents CMake 2.6.

      The following features have been added since printing the book:

      1. New INSTALL command (cmake --help-command INSTALL)
      2. New LIST command (cmake --help-command LIST)
      3. Updated FIND_PATH, FIND_PROGRAM, and FIND_FILE commands to be
      4. more powerful (cmake --help-command FIND_PATH)
      5. RPATH and Mac OS X install_name support (cmake --help-command
      6. SET_TARGET_PROPERTIES)
      7. CPack Beta (not finished or documented)
      8. EXECUTE_PROCESS was added and replaces EXEC_PROGRAM
      9. Other changes have been bug fixes and internal CMake restructuring.

    5. Question 5. I Set A Cmake Variable In My Environment, But It Didn't Change Anything. Why?

      Answer :

      CMake build settings are stored in the CMake cache corresponding to a project's build tree. They are called CMake "cache entries" and have no relation to your command shell's environment variables. Use a CMake GUI (CMakeSetup on Windows or ccmake on UNIX) or the wizard mode (cmake -i) to edit cache entries. Initial values may also be specified for a build by using the -D command line argument to cmake when it is first run to produce a new build tree.

    6. Question 6. I Change Cmake_c_compiler In The Gui But It Changes Back On The Next Configure Step. Why?

      Answer :

      Once a build tree is created with a given compiler it cannot be changed. There are a variety of implementation reasons for this policy.

    7. Question 7. I Run An Out-of-source Build But Cmake Generates In-source Anyway. Why?

      Answer :

      This means that there is a CMakeCache.txt file in the source tree,possibly as part of an existing in-source build. If CMake is given the path to a directory with a CMakeCache.txt file, it assumes the directory is a build tree. Therefore if one runs "cmake ../mysrc" to build out-of-source but there is a mysrc/CMakeCache.txt file then cmake will treat mysrc as the build tree. This is a side-effect of the feature that allows "cmake ." to be used to regenerate a build tree. The behavior will not be changed because mixing in-source and out-of-source builds is not safe anyway (configured headers may be found in the wrong place).

    8. Question 8. Why Does Cmake Use Full Paths, Or Can I Copy My Build Tree?

      Answer :

      CMake uses full paths because:

      configured header files may have full paths in them, and moving those files without re-configuring would cause upredictable behavior. because cmake supports out of source builds, if custom commands used relative paths to the source tree, they would not work when they are run in the build tree because the current directory would be incorrect.on Unix systems rpaths might be built into executables so they can find shared libraries at run time. If the build tree is moved old executables may use the old shared libraries, and not the new ones.

    9. Question 9. How Do I Get The Current Source Or Binary Directory?

      Answer :

      The variable CMAKE_CURRENT_SOURCE_DIR contains the absolute path to your current source directory, while CMAKE_CURRENT_BINARY_DIR points to the equivalent binary directory.

    10. Question 10. Why Do I Have Unwanted Semicolons ; In My Compiler Flags?

      Answer :

      CMake has a list data type. A list is stored as a string of semicolon-separated list elements. Whitespace separated arguments to a SET statement are interpreted as list elements. For instance, SET(var a b c d e) will give "var" a value of a;b;c;d;e and this list can be used by other CMake commands. However, if you pass ${var} to a non-CMake external tool, such as a compiler's command line, you are passinga;b;c;d;e which is not what you want. Instead you either need to pass "${var}", so that the list will be converted to a whitespace-separated string, or you need to SET(var "a b c d e") in the 1st place so that you're working with a string, not a list.

    11. Question 11. Can I Build Both Shared And Static Libraries With One Add_library Command?

      Answer :

      No. Each library you build must have a unique target name, i.e. the "libname" field of the ADD_LIBRARY command. That way, CMake can trackdependencies separately for each library. Libraries can have the same OUTPUT_NAME, see the SET_TARGET_PROPERTIES command, but this is not the default.

    12. Question 12. Does Cmake Support "convenience" Libraries?

      Answer :

      CMake does not currently support convenience libraries. A "convenience" library, as GNU libtool calls it, is an archive of objects to be mixed into other libraries. Other libraries "link" to the convenience library, but the convenience library does not export any symbols; GNU libtool never installs the convenience library; no programs ever link to the convenience library. This does not mean that a project using convenience libraries cannot be converted to CMake. Instead the source files may be listed in each target that needs them. They will be built for each target separately using all the preprocessor definitions and flags configured for that target.

    13. Question 13. What Is The Best Way To Distribute Source Code Or Binaries For A Cmake-based Project?

      Answer :

      For creating source or binary packages there is now CPack coming with CMake, see the documentation. Of course you can also use any other ways to create packages.

    14. Question 14. Can Cmake Set The Debugging/working Directory Property In Visual Studio Projects?

      Answer :

      Not directly. The value of this property is not stored in the project files. It is stored in extra files created by the IDE when a solution is loaded (VS .NET 2003 uses a hidden .suo file next to the .sln solution file). The format of these files is not known to CMake and cannot be generated. In some versions of VS the files are binary and not human readable. However, for Visual Studio versions at least 2005 and newer, Ryan Pavlik maintains CMake modules that can create these files: main  script, also requires this directory.

    15. Question 15. What Is Cmakelists.txt?

      Answer :

      Input Text Files that contain the project parameters and describe the flow control of the build process in cmake language. 

    16. Question 16. What Is Cmake Cache?

      Answer :

      CMake uses the cache when it's re-running itself during a build because a CMakeList file changed, or when you make rebuild_cache . It also loads the cache at start of a normal configure run. 

    17. Question 17. What Is Cmake Generator?

      Answer :

      A CMake Generator is responsible for writing the input files for a native build system. Exactly one of the CMake Generators must be selected for a build tree to determine what native build system is to be used. Optionally one of the Extra Generators may be selected as a variant of some of the Command-Line Build Tool Generators to produce project files for an auxiliary IDE. 

Popular Interview Questions

All Interview Questions

All Practice Tests

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Tutorial