![]() ![]() Linking flags are automatically passed to the linker, when this target is being linked. ![]() For example, include directories property is automatically added to the compilation flags when the target is being compiled. Here is a list of the most popular ones:Īll of the above properties are stored in the special CMake variables and are automatically used by the build system, when the given target appears in the certain context. But in my opinion, it is less elegant.Įach target can have its own set of properties, that will be used in proper contexts. We could also skip the line with DEPENDS and add add_dependencies(firmware.bin firmware) instead as a separate statement. This is natural, because in order to convert firmware file it must be already built! Here we explicitly say, that firmware.bin depends on firmware. In the snippet above we are defining a custom target named firmware.bin, whose only objective is to create a BIN file from the original executable using GNU objcopy (if you are not familiar with objcopy, then think of this as some conversion of the binary file). We can create also custom targets, whose only role is to invoke some command: add_custom_target(firmware.binĬOMMAND $/bin" Let’s keep in mind, that those are not the only possible targets that can be defined in CMake. For now we know, that in order to build myExecutable we have to link with libA, for building libA we have to link with libB and for building libB we have to link with libC. Here we have an executable called myExecutable and three libraries libA, libB and libC. This is a classic way of creating targets. ![]() Let’s see the syntax for creating and using them: add_executable(myExecutable Most commonly used targets are executables and libraries. It generally represents one “job” of the building process. Target is a fundamental concept in CMake.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |