[CMake] Question about add_library with IMPORTED

Michael Wild themiwi at gmail.com
Tue Mar 9 13:54:04 EST 2010


On 9. Mar, 2010, at 18:27 , Benoit Thomas wrote:

> Hello,
> 
> I have a library which is a Visual Studio project only (which will be converted to cmake in the future).
> 
> In my current cmake project, I try adding this library using the following code:
> 
> set (IMPORTED_LOCATION "../farfaraway/lib")
> add_library ("mylib" STATIC IMPORTED)
> 
> When I run cmake using:
> 
> cmake . -G "Visual Studio 9 2008"
> 
> I don't see the imported library in my visual studio solution. I do not know what I'm missing.
> 
> Thank you,
> Ben.

You are setting a variable IMPORTED_LOCATION, not the target property. Do this instead:


add_library (mylib STATIC IMPORTED)
set_target_properties(mylib PROPERTIES
  IMPORTED_LOCATION "../farfaraway/lib/something.lib")


HTH

Michael


More information about the CMake mailing list