12/20/2023 0 Comments Cmake variables link libraries![]() ![]() PUBLIC - the Tool can do both: get doThingy() functionality of Dependency through doTheThing() function of AnotherLibrary and get doThingy() function directly from Dependency: INTERFACE - the Tool gets doThingy() function directly from Dependency, while AnotherLibrary does not ( and so it no longer has doTheThing() function available): PRIVATE - the Tool gets doThingy() functionality of Dependency through doTheThing() function of AnotherLibrary and cannot get doThingy() function directly from Dependency: In this case that Dependency library will be a direct dependency for our Project and a transitive dependency for the Tool:Īpplying to this example, my understanding of the scopes would be the following: This Project is used by some Tool ( so Tool depends on Project) and also it has a dependency of its own ( so Project depends on Dependency). So if you only deal with direct dependencies and don’t have consumers upper in the dependency chain, then you probably don’t need to care about all that, as this is really about transitive dependencies ( dependencies of dependencies).įor example, let’s say we have a Project, which is a collection of libraries. What are these scopesīefore reading my interpretation, do read the documentation and this post from Craig Scott ( author of Professional CMake).Īs I understood it, scopes define how dependencies of a library will affect consumers of that library. ![]() If anything, I am now on CMake v3.26.4, which might be important to state, as ( much) older versions had different policies for things like include directories propagation, and newer versions might have something different too. So when do I need to deliver 3rd-party dependencies to my customers.What if transitive dependency is also SHARED.The CMake’s target_link_libraries() function has different scopes ( PRIVATE/ INTERFACE/ PUBLIC), and I never understood what exactly each one of them means and how do they actually affect the final result.Īs there is a limit for how long one can postpone one’s ignorance, it finally came a time for me to investigate the matter, which I did by ( reading the documentation and) conducting a small experiment of my own. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |