[question] PUBLIC / PRIVATE Link Libraries Separation
See original GitHub issueLet’s take following simplified example:
find_package(Boost REQUIRED)
find_package(OpenSSL REQUIRED)
add_library(Foo)
target_link_libraries(${PROJECT_NAME}
PUBLIC
Boost::Boost
PRIVATE
OpenSSL::OpenSSL
)
#...
include(CMakePackageConfigHelpers)
configure_package_config_file(...)
install(...)
Now, let’s assume we want to consume Foo
:
find_package(Foo REQUIRED)
add_executable(App)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Foo::Foo
)
Now, having OpenSSL
defined as a private dependency of Foo
means that App
can link against it, but cannot include any API of it. Instead, in case of Boost
, App
can use it within the application.
CMake, when generating the Package Configuration Files, uses $<LINK_ONLY:...>
to specify private link dependencies without other usage requirements.
My question is, how can I describe the PUBLIC / PRIVATE separation within package_info()
?
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
cmake target_link_libraries PRIVATE or PUBLIC on CuteLogger
PUBLIC linkage affects both on ${library_target} target and targets linked with it. Non-keyword variant of target_link_libraries has no exact ...
Read more >Modern CMake is like inheritance - Kuba Sejdak
This means, that if other libraries call only target_link_libraries() to both get include paths and link with library, then no private header ...
Read more >3. Shared Libraries - The Linux Documentation Project
The key to managing shared libraries is the separation of these names. Programs, when they internally list the shared libraries they need, should...
Read more >CMake: Public VS Private VS Interface - Lei Mao's Log Book
CMake Include and Link Keywords from the Perspective of Inheritance. ... apple_size by PUBLIC or PRIVATE linking with the apple library.
Read more >Enhanced source file handling with target_sources() - Crascit -
If you want to take full advantage of the PUBLIC, PRIVATE and ... and any target that links to it also needs to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @lucabonifacio
at the moment (Conan 1.X), all
requires
are by default public, and linkage requirements are propagated to the consumers. This is because Conan graph model hasrequires
andbuild_requires```, but there is nothing inside
requires`` that allows to define the visibility of the transitive requirements.Conan 2.0 introduces a new model that does exactly this. Check this Tribe 2.0 proposal: https://github.com/conan-io/tribe/pull/26
Hi @dornbirndevelops
Please don’t use undocumented things in your recipe code, those will easily break, and if you do it, it is at your own risk. Specifically this one has already been removed in the new model, it will not exist via the
self.dependencies
model