CGold
latest
  • 1. Overview
  • 2. First step
  • 3. Tutorials
    • 3.1. CMake stages
    • 3.2. Out-of-source build
    • 3.3. Workflow
    • 3.4. Version and policies
    • 3.5. Project declaration
    • 3.6. Variables
      • 3.6.1. Regular variables
      • 3.6.2. Cache variables
      • 3.6.3. Environment variables
    • 3.7. CMake listfiles
    • 3.8. Control structures
    • 3.9. Executables
    • 3.10. Tests
    • 3.11. Libraries
    • 3.12. Pseudo targets
    • 3.13. Collecting sources
    • 3.14. Usage requirements
    • 3.15. Build types
    • 3.16. configure_file
    • 3.17. Install
    • 3.18. Toolchain
    • 3.19. Generator expressions
    • 3.20. Properties
    • 3.21. Packing
    • 3.22. Continuous integration
  • 4. Platforms
  • 5. Generators
  • 6. Compilers
  • Contacts
  • Rejected
  • Glossary
CGold
  • 3. Tutorials
  • 3.6. Variables
  • Edit on GitHub

3.6. Variables¶

There are only two kinds of languages: the ones people complain about and
the ones nobody uses.
– Bjarne Stroustrup

We have touched already some simple syntax like dereferencing variable A by ${A} in message command: message("This is A: ${A}"). Cache variables was mentioned in CMake stages. Here is an overview of different types of variables with examples.

CMake documentation

  • Language: variables

Examples on GitHub

  • Repository

  • Latest ZIP

  • 3.6.1. Regular variables
    • 3.6.1.1. Regular vs cache
    • 3.6.1.2. Scope of variable
    • 3.6.1.3. New scope
    • 3.6.1.4. Same scope
    • 3.6.1.5. Parent scope
    • 3.6.1.6. From cache
    • 3.6.1.7. Cache unset regular
    • 3.6.1.8. Confusing
    • 3.6.1.9. Names
    • 3.6.1.10. Quotes
    • 3.6.1.11. Dereferencing
    • 3.6.1.12. Nested dereferencing
    • 3.6.1.13. Types of variable
    • 3.6.1.14. Create list
    • 3.6.1.15. Operations with list
    • 3.6.1.16. List with one empty element
    • 3.6.1.17. Recommendation
    • 3.6.1.18. Summary
  • 3.6.2. Cache variables
    • 3.6.2.1. No scope
    • 3.6.2.2. Double set
    • 3.6.2.3. -D
    • 3.6.2.4. Initial cache
    • 3.6.2.5. Force
    • 3.6.2.6. Force as a workaround
    • 3.6.2.7. Cache type
    • 3.6.2.8. Enumerate
    • 3.6.2.9. Internal
    • 3.6.2.10. Advanced
    • 3.6.2.11. Use case
    • 3.6.2.12. Option
    • 3.6.2.13. Unset
    • 3.6.2.14. Recommendation
    • 3.6.2.15. Summary
  • 3.6.3. Environment variables
    • 3.6.3.1. Read
    • 3.6.3.2. Set
    • 3.6.3.3. Unset
    • 3.6.3.4. Inheriting
    • 3.6.3.5. Configure step
    • 3.6.3.6. No tracking
    • 3.6.3.7. Summary
Previous Next

© Copyright 2015-2019, Ruslan Baratov. Revision 89dee651.

Built with Sphinx using a theme provided by Read the Docs.