-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] Is IMPORTED_LOCATION missing for conan_package_library_targets? #16688
Comments
adding before or after line 89
Fixes the issue. I guess this means IMPORTED_LOCATION needs to be set for any IMPORTED target, and setting its _CONFIG specification does not cancel the need to set it? Or am I missing a method of choosing the IMPORTED_CONFIGURATION? Edit: this seems to be related to #14606 |
With conan 2.0.4 it is working, seems this was changed in Some remarks in the connected issue #13504 seem to be wrong on linux, like "The right thing is to not set IMPORTED_LOCATION at all. Instead IMPORTED_LOCATION_DEBUG or IMPORTED_LOCATION_RELEASE shall be set to the Library for LIBRARY targets and to the dll (or so) for a shared library. For the latter IMPORTED_IMPLIB_DEBUG or IMPORTED_IMPLIB_RELEASE has to be set to the library. IMPORTED_LOCATION and IMPORTED_IMPLIB will then be automatically determined by cmake." This is not happening, but cmake complains about IMPORTED_LOCATION being undefined. 13504 is about windows but it seems to create a problem on Linux, could this be due to single-target generator on linux and multi-target-generator on windows? |
You misread the explanation of CMP0111 in the CMake documentation. To quote (emphasis mine):
If configuration-specific locations are set, IMPORTED_LOCATION doesn't have to be set. I don't know why you're getting the CMake warning, it might be due to a conan bug, but setting IMPORTED_LOCATION isn't the correct fix even if it is a conan bug. |
"or a per-configuration equivalent." this seems to be only true under certain conditions. After some testing I observed cmake won't throw CMP0111 when
As explained in #14606 Following this it seems only when a target has its IMPORTED_CONFIGURATIONS property set will cmake accept IMPORTED_LOCATION_CONFIG instead of the configuration-less IMPORTED_LOCATION, otherwise one is getting CMP0111 |
Some frameworks use the property in order to find libraries, e.g. like https://github.com/ros/catkin/blob/noetic-devel/cmake/catkin_libraries.cmake#L150 In order to support these kind of usages, this commit adds the property to all targets. This should solve conan-io#14606 and conan-io#16688.
Some frameworks use the property in order to find libraries, e.g. like https://github.com/ros/catkin/blob/noetic-devel/cmake/catkin_libraries.cmake#L150 In order to support these kind of usages, this commit adds the property to all targets. This should solve conan-io#14606 and conan-io#16688.
Hi @Stadik I am trying to understand where the warning comes from, trying to reproduce, but I don't get it, even if my Could you please provide fully reproducible details to get that warning? What I have done so far:
Should I see that warning too? |
I couldn't fully analyse this issue until know, but I explained roughly in #16705 (comment) the process of how it generates issues. Following this, most important is that it needs to be a real physical object e.g. what I could reproduce it by this ... the hdf5 package is a random package one of our repos generated via conan, but it should work with any package which should have a physical library
|
The warning simply comes because the CONAN_LIB::${package_name}_${_LIBRARY_NAME}${config_suffix} target seems to be a faulty target, there is no need to link it in any way. |
Typically the main purposes of target abstractions in CMake is to avoid precisely having to be aware of the files at all. so We would be very interested in learning what the use cases are for querying the target properties at configure time. We don't typically see this in Conan Center (1700+ recipes), as it would be an anti-pattern as it breaks the encapsulation that imported targets provide. It's may also not be robust to multi-config generators - hence these sort of thing is best handled with generator expressions instead (different files for different configurations). For the use case of gathering shared library dependencies to copy them - CMake's own built in functionality should work, e.g.
These other two variations, either:
These two may benefit from improved But otherwise, if you could provide more insights as to why it may be needed to query the location property of targets at configure time, that would be great |
We have a cmake based dependency walker from a time before any of the options you mentioned existed, for this we probe IMPORTED_LOCATION, LOCATION or IMPORTED_LOCATION_CONFIG if CONFIGURATION_TYPES / IMPORTED_CONFIGURATIONS are defined. We tried in the past modernizing this code by said built in functionalities, but all proved to have conditional bugs / miss some important logic or something similar, so they generate faulty packages under certain conditions without additional effort and workarounds. So it seems not worth the effort as long as any of the functionalities used are not fully deprecated. But apart from the reason why, did I make it clear that the failure comes from simple get_target_property of a base property LOCATION? I explained our reason why IMPORTED_CONFIGURATIONS for the current definition of the CONAN_LIB targets in #16705 (comment) |
We are releasing in Conan 2.9 a completely new
Current known pending functionality (to be added soon):
The new Your feedback is very importantAs this is a major change, we will only remove the conf gate when we get confirmation from users that it works and solve the issues. Please try the new generator for your project, and let us know if it works. If it doesn't, please re-open this ticket and let us know what failed. Thanks very much! |
What is your question?
I am not sure if this a bug but in conan_package_library_targets or if I am missing something
https://github.com/conan-io/conan/blob/develop2/conan/tools/cmake/cmakedeps/templates/macros.py
line 86 an imported target is generated
line 89 specifies its IMPORTED_LOCATION_RELEASE
But per CMP0111 an imported target always needs to define its IMPORTED_LOCATION, why is it not set?
Now I am getting a warning in my case due to cmake_minimum_required being smaller then 3.19
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: