Think you're a CMake pro? Dive into this quiz to test your understanding of CMake usage, syntax, and best practices. Perfect for developers who want to ensure they know CMake inside out.
1. Which command type in CMake has its own scope, making its variables invisible in the parent scope?
Modules
Targets
Macros
Functions
2. Which feature of modern find modules in CMake improves their usability and robustness?
Reduced size
Global variables
Exported targets
Custom macros
3. What is the recommended way to specify the C++ standard in CMake?
target_include_directories
set_target_properties
target_compile_features
compile_definitions
4. What is the best practice for integrating third-party libraries in a CMake project?
find_library and find_path
Global path variables
Hardcoding paths
Copying files manually
5. How can you make CMake variable settings configurable by the user?
Using CMake options
Embedding in scripts
Hardcoding values
Using environment variables
6. Which aspect of functions makes them preferable to macros in most cases?
Memory usage
Execution speed
Scope isolation
Syntax simplicity
7. What advantage does using target_compile_features in CMake offer?
Speeds up compilation
Reduces binary size
Simplifies syntax
Manages compiler compatibility
8. When configuring target_compile_options in CMake, what should be avoided?
PUBLIC -Wall flag
PRIVATE -pthread
INTERFACE -O3
PUBLIC -lstdc++
9. What is one key benefit of modular design in CMake projects?
Centralizes dependencies
Increases speed
Reduces code size
Improves reusability
10. To maintain readable and maintainable CMakeLists files, what should be avoided?
Mixing old and new practices
Following naming conventions
Modularizing scripts
Using clear comments
11. What does the CMake command add_executable help you achieve?
Defines executables
Defines libraries
Links dependencies
Sets compile flags
12. Why should you use cmake-format for CMake code formatting?
Ensures consistent formatting
Reduces code size
Speeds up build time
Simplifies syntax
13. What main advantage does using modern CMake practices provide?
Simpler syntax
Relocatable packages
Faster execution
Smaller binaries
14. What is the minimum required version of CMake to use modern CMake features effectively?
Version 4.0.0
Version 2.8.0
Version 3.0.0
Version 3.10.0
15. What command can help you debug flag or file issues in CMake?