

It is however only recommended for development use.Ĭmake_print_variables(MYVAR CMAKE_MAJOR_VERSION DOES_NOT_EXIST) The only thing you need to do is include the module and it will expose a function named cmake_print_variables where you list the names of the variables you want to debug. While you could use the message command, CMake provides a handy module named CMakePrintHelpers which makes this process a bit easier. You might find yourself needing to debug the value of variables. set(NUMBER_LIST 1 2 "3 4") # Results in NUMBER_LIST="1 2 3 4" list(APPEND NUMBER_LIST 1) # Results in NUMBER_LIST="1 2 3 4 1" list(REMOVE_DUPLICATES NUMBER_LIST 1) # Results in NUMBER_LIST="1 2 3 4" set(NOT_A_LIST "a\ b") # Results in NOT_A_LIST="a\ b" CMakePrintHelpers

Such variables can then be considered as lists and can be more easily manipulated through the list command. Note that if you have multiple values in the set command, they will be concatenated into a single string and seperated by which means that if you pass the variable to a list aware command, you need to escape any unless you want to split your string. The PARENT_SCOPE parameter lets you set the value of a variable in the parent scope (parent function or parent directory), which can serve as an output parameter. The signature of the set function is the following: set(.
#CMAKE COMMAND HOW TO#
We will see how to use variables, build configurations and then generator expressions so that you can provide flexible options to your users. Those can be based on the target platform, compiler, or simply based on the user choice. This is an important part of CMake as every project has its own set of requirements. We will now dive deeper and look into more advanced features so that you can customize your project. If you are not familiar with CMake, please read the previous article first. In the previous article we saw the basics of CMake and how to handle targets.
