AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Cmake create list9/22/2023 ![]() Since we don’t check if it is defined in the function, this means that it is not mandatory, but the string "Bad name" is consider a wrong argument when associated with this keyword.įinally, the keyword ARRAY_OF_PARAM is used to pass several arguments to the function. The keyword NAME is used to pass only one argument to the function. This means that, if it is passed to the function, then, the variable MY_FUNCTION_IS_ACTIVATED will be set to TRUE, else it will be set to FALSE. The keyword IS_ACTIVATED is actually a flag that can be omit and can be used to trigger some code in the function or modify its behavior, for example. Let’s dive in ! In this sample of code, we create a function which can be called like that : my_function(NAME "John Doe" ARRAY_OF_PARAM "First param" "Second Param" IS_ACTIVATED). Moreover, it even allow us to handle an infinity of parameters even more easily □ Indeed, they have given us the ability to add keywords in our functions parameters so that we could group them by type, and check their validity more easily. To face function with a big number of parameters and with different "kinds" of parameters, the CMake developers have created a new feature very interesting. Moreover, since the CMake functions tends to have a lot of parameters, it can become a lot of pain to check all of them that way. I have also added some other variables, ARGN and ARGV, so that you can have some knowledge about them, if you want to be able to manipulate or to extract more informations about the parameters passed to your own Cmake functions □.Įven if this function is simple to explain, it requires you to write a lot of code to each check each parameter, and to make sure that they are all what you function expects. Indeed, with the variable ARGC, we are able to see the number of arguments and we can control it by using some conditions, for example. With the previous sample of code, we will be able to display some very interesting informations about the numbers of arguments. This first solution consists of using a CMake variable available to us giving us the number of arguments used when the function is called.Įnter fullscreen mode Exit fullscreen mode To make sure that your function has the right number of arguments when called, we have two solutions (two that I am aware of □). Indeed, you can call a function, declared as taking only one arguments, with three arguments without having CMake preventing you.Įven if this behavior is wanted by CMake developers and allows some nice features, if you don’t know about it, it can be the origin of a lot of bugs and unwanted behaviors in your CMake scripts. Unlike in other languages, the number of arguments when calling a CMake function is actually not checked by the system. In CMake, like in many other languages, it is possible to create and use functions. Self promotion: You can find other articles on my website □ I’m Xavier Jouvenot and in this small post, we are going to see how to correctly create a CMake function with proper arguments. ROOT_GENERATE_DICTIONARY( dictionary headerfiles. Generate dictionary for a set of header files (convenient wrapper on top of rootcling command). ![]() ROOT provides a number of CMake macros/functions that are used internally but can also be used by projects layered on top of ROOT. For example to add the RooStats library the user can specify it as an extra component (the name of the component is the name of the library without any library prefix or suffix). The user can force additional ROOT libraries in the ROOT_LIBRARIES variable using the COMPONENTS option in find_package(.) command. Path to a CMake module which makes use of the previous variables and loads modules with useful macros or functions such as ROOT_GENERATE_DICTIONARY The actual list of libraries is composed using the COMPONENTS listed in the find_package(…)įull path for each of the ROOT libraries listed in COMPONENTSįull path for each ROOT executable (rootcling, root, hadd, etc.) Include directories for the ROOT installation
0 Comments
Read More
Leave a Reply. |