question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Why does the CMake generator define INTERFACE IMPORTED targets rather than only IMPORTED?

See original GitHub issue

My understanding is that INTERFACE targets are for when an actual library file does not exist on disc and you just want to group together and add a logical set of flags, sources, headers etc. in the compile/link process of another target.

However, in some cases the dependencies resolved through Conan do have an actual library file. And in these cases I might like to know where this library file is stored on disc (in my particular use case I want to extract symbols from it). For IMPORTED targets I would normally use something like the IMPORTED_LOCATION property or the $<TARGET_FILE:tgt> generator expression, but this is not possible for INTERFACE targets which only support ā€œwhitelistedā€ INTEFRACE_ properties.

Maybe there a reason for this I’m not aware of. If so, can you suggest any other way I might be able to get the location of these INTERFACE IMPORTED library files? If not, I’d like to propose that dependencies which have a library are defined as IMPORTED only.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lasotecommented, Dec 9, 2021

I think, at least in theory šŸ˜… , we will have that information thanks to the proposed package types https://github.com/conan-io/tribe/pull/27 and requirements traits https://github.com/conan-io/tribe/pull/26 so the generators could be improved. I don’t know if changing the targets that way could have other unexpected results but we should try, so I’m assigning the ā€œlook intoā€ tag and milestone to take a look.

2reactions
SpaceImcommented, Feb 8, 2021

A CMake imported target must have a type (STATIC, SHARED, INTERFACE or UNKNOWN): https://cmake.org/cmake/help/latest/command/add_library.html#imported-libraries Maybe conan should first provide a mechanism in package_info() to indicate if a specific lib file is shared or static, then generators could use this information to create proper imported targets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the differences between IMPORTED target and ...
The fundamental difference is that interface libraries are not backed by anything on disk, they're just a set of requirements/properties.
Read more >
Importing and Exporting Guide
In this guide, we will present the concept of IMPORTED targets and demonstrate how to import existing executable or library files from disk...
Read more >
It's Time To Do CMake Right | Pablo Arias
Not so long ago I got the task of rethinking our build system. The idea was to evaluate existing components, dependencies,Ā ...
Read more >
CMake Properties Reference
The property allows multiple add_custom_target() command calls in different directories to specify the same target name. However, setting this property will ...
Read more >
man page cmakeprops section 1
Makefile generators are capable of supporting duplicate custom target names. ... Instead consider defining the macro in a (configured) header file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found