[CMake] Problem with IMPORTED_LINK_INTERFACE_LIBRARIES_<config>

Michele Santullo michele.santullo at larian.com
Mon Jun 25 06:35:17 EDT 2012


On 06/22/2012 02:18 PM, Michele Santullo wrote:
> Thanks for the suggestion. We just tried that but unfortunately it
> doesn't change anything. Using IMPORTED_LINK_INTERFACE_LIBRARIES adds
> the library to every target build, but either
> IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG and
> IMPORTED_LINK_INTERFACE_LIBRARIES_Debug seem to be just ignored. There
> are not even cmake messages at generation time.
>
> Of course we have a target named "Debug":
> SET(CMAKE_CONFIGURATION_TYPES Debug Release Shipping CACHE TYPE INTERNAL
> FORCE)
>
> Michele
>
>
> On 06/22/2012 01:10 PM, Petr Kmoch wrote:
>> Hi Michele,
>>
>> I don't know how it is in this particular case, but some
>> configuration-specific variable, property etc. names are
>> case-sensitive. I believe the default configuraions are called "Debug"
>> and "Release". You could try setting
>> IMPORTED_LINK_INTERFACE_LIBRARIES_Debug.
>>
>> Petr
>>
>> On Fri, Jun 22, 2012 at 12:17 PM, Michele Santullo
>> <michele.santullo at larian.com> wrote:
>>> Hello, I need to add some linker dependencies to a static lib I'm
>>> importing
>>> into our project. I need to do that on a per-target basis, but the
>>> following
>>> is not working:
>>>
>>> add_library(GameNet STATIC IMPORTED) # our code built in another
>>> project and
>>> imported by the current one
>>> add_library(Library STATIC IMPORTED) # 3rd party library, source code
>>> unavailable
>>> add_library(LibraryD STATIC IMPORTED) # Debug version of the same
>>> library as
>>> above
>>>
>>> set (ALL_LIBS
>>> optimized Library
>>> debug LibraryD
>>> )
>>>
>>> set_target_properties(GameNet PROPERTIES
>>> IMPORTED_LINK_INTERFACE_LIBRARIES
>>> "${ALL_LIBS}")
>>>
>>> Running cmake gives a message about optimized/debug keyword being
>>> forbidden
>>> in this case. The same message suggests you use
>>> IMPORTED_LINK_INTERFACE_LIBRARIES_<config> in this case. However, I
>>> tried
>>> the following:
>>>
>>> set_target_properties(GameNet PROPERTIES
>>> IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG LibraryD)
>>> set_target_properties(GameNet PROPERTIES
>>> IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE Library)
>>>
>>> and it just has no effect. There is no trace of Library[D] in the
>>> generated
>>> files.
>>> I'm using cmake 2.8.8 on windows for VS 9 2008.
>>>
>>> Thanks,
>>> Michele
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>

So, the behaviour is a bit weird here. I was able to find the solution 
to my problem by stepping into cmTarget.cxx. The problem is that the 
code makes a suffix the whose value is for example "_DEBUG", then looks 
for IMPORTED_LOCATION_DEBUG. I was setting IMPORTED_LOCATION though 
(with no suffix), so the code assumed that every other variable should 
have no suffix. This is very unclear I think, because here's what cmake 
says:

   cm->DefineProperty
     ("IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET,
      "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LIBRARIES.",
      "Configuration names correspond to those provided by the project "
      "from which the target is imported.  "
      "If set, this property completely overrides the generic property "
      "for the named configuration.");

It speaks about generic properties being overridden, so I assumed 
IMPORTED_LINK_INTERFACE_LIBRARIES = 
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG + 
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE + 
IMPORTED_LINK_INTERFACE_LIBRARIES_SHIPPING. Kind of confusing but yeah, 
now it works.

So in case someone else gets the same problem, for 
IMPORTED_LINK_INTERFACE_LIBRARIES_<config> to work you need to set
IMPORTED_LOCATION_<config> first. I use a foreach to set it for every 
target we have.

mic


More information about the CMake mailing list