Open Stadik opened 1 month ago
adding before or after line 89
set_target_properties(${_LIB_NAME} PROPERTIES IMPORTED_LOCATION ${CONAN_FOUND_LIBRARY} IMPORTED_NO_SONAME ${no_soname_mode})
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 https://github.com/conan-io/conan/issues/14606
With conan 2.0.4 it is working, seems this was changed in https://github.com/conan-io/conan/commit/113cf5a2875ff3f9e77981aa178772090f4680f4
Some remarks in the connected issue https://github.com/conan-io/conan/issues/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):
Imported Targets for library files and executables require that their location on disk is specified in a target property such as IMPORTED_LOCATION, IMPORTED_IMPLIB, or a per-configuration equivalent.
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
1) When IMPORTED_LOCATION is set as explained above.
2) If the available CONFIGURATIONS_TYPES are set, above line 89
set_property(TARGET ${_LIB_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS <config>)
As explained in https://github.com/conan-io/conan/issues/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
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?