[CMake] CMake 3.x not respecting IMPORTED_LOCATION_<CONFIG> properties
Parag Chandra
parag at ionicsecurity.com
Mon Nov 17 14:43:51 EST 2014
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/20141117/cab41a9b/attachment-0001.html>
More information about the CMake
mailing list