[CMake] CMake 3.x not respecting IMPORTED_LOCATION_<CONFIG> properties

Parag Chandra parag at ionicsecurity.com
Tue Nov 18 10:40:57 EST 2014


I figured it out, and it's a case-sensitivity issue. I have named my configuration "Custom", so I was expecting the corresponding property to be IMPORTED_LOCATION_Custom, but in fact CMake is expecting IMPORTED_LOCATION_CUSTOM. So it's an easy fix on my part.


Parag Chandra
Software Engineer, Mobile Team
Mobile: +1.919.824.1410

[https://www.ionicsecurity.com/IonicSigHz.png]<https://ionic.com>

Ionic Security Inc.
1170 Peachtree St. NE STE 2285, Atlanta, GA 30309











From: Parag Chandra <parag at ionicsecurity.com<mailto:parag at ionicsecurity.com>>
Date: Monday, November 17, 2014 at 2:43 PM
To: "cmake at cmake.org<mailto:cmake at cmake.org>" <cmake at cmake.org<mailto:cmake at cmake.org>>
Subject: CMake 3.x not respecting IMPORTED_LOCATION_<CONFIG> properties

Hello,

Until recently, I was making use of the 'debug' and 'optimized' keywords to select the config-specific versions of external dependencies to link in, i.e. if I wanted to link Bar into Foo, I would use:

target_link_libraries (Foo DEBUG ${Bar_Debug} OPTIMIZED ${Bar_Release})

Now I have added my own custom configuration to CMAKE_CONFIGURATION_TYPES, let's call it "Custom", and I want Foo, when built in Custom config, to link against the Custom variant of Bar. I did some reading and came across IMPORTED targets, which seem designed for this purpose, so I added new lines like the following:

add_library (Bar STATIC IMPORTED GLOBAL)
set_property (TARGET Bar PROPERTY IMPORTED_LOCATION_DEBUG "/path/to/Debug/Bar.lib")
set_property (TARGET Bar PROPERTY IMPORTED_LOCATION_RELEASE "/path/to/Release/Bar.lib")
set_property (TARGET Bar PROPERTY IMPORTED_LOCATION_CUSTOM "/path/to/Custom/Bar.lib")
target_link_libraries (Foo Bar)

However, when I open the generated Visual Studio project, I see "Bar-NOTFOUND" in the linker inputs. If I add the line:

set_property (TARGET Bar PROPERTY IMPORTED_LOCATION "/path/to/Release/Bar.lib")

Then the linker inputs are resolved correctly, but of course all of my configurations of Foo are now going to link against the same Release configuration of Bar.

Is this a bug, or am I simply not using this feature correctly? I tried both 3.0.1 and 3.1rc2 on Windows.

Thanks,

Parag Chandra

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141118/645d09ca/attachment-0001.html>


More information about the CMake mailing list