[CMake] How to link a library?

Andreas Pakulat apaku at gmx.de
Wed Feb 2 14:32:23 EST 2011


On 02.02.11 13:18:49, Enrique Izaguirre wrote:
> Hello,
> 
> I have tried several ways to link an Api library to my project, but
> everything I've done so far is unsuccessful.
> 
> I have a .lib file named AdbWinApi.lib in the address
> ${myProject_SOURCE_DIR}/android/development/windows/usb/api
> 
> I am trying to link this library to myProject, first I used the following:
> 
> find_library(AdbWin_LIBRARY
>      AdbWinApi.lib

Remove the .lib here

>      ${myProject_SOURCE_DIR}/android/development/windows/usb/api

There is at least PATHS missing here, see the cmake manual for details.

>      )
> then I used a simple way to assert it was found:
> 
> if (${AdbWin_LIBRARY})
>     message (STATUS "AdbWin library found")
>     target_link_library (myproj ${AdbWin_LIBRARY})

This should be target_link_libraries.

> endif ()
> 
> but always it is unsuccessful.
> 
> Even though it looks pretty straight forward, I have not been able to link
> it.

If you know the full path already, simply pass that to
target_link_libraries, there's no need for the find_library call.

Andreas

-- 
You are number 6!  Who is number one?


More information about the CMake mailing list