Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake imported library behaviour

Tags:

c++

c

cmake

I've a strange problem with CMake.

I'm importing Curl into my project, so I write for you a simplified summary of my CMakeLists.txt file.

ADD_LIBRARY (libcurl SHARED IMPORTED)

SET_PROPERTY(TARGET libcurl PROPERTY IMPORTED_LOCATION ../lib/libcurl.lib)

When I run CMake it generates the project files for MS VC++ (also for Linux). Then into the project file I find a wrong reference to curl library (libcurl-NOTFOUND)!

If I change my code into static import:

ADD_LIBRARY (libcurl STATIC IMPORTED)

SET_PROPERTY(TARGET libcurl PROPERTY IMPORTED_LOCATION ../lib/libcurl.lib)

I find the right reference to ../lib/libcurl.lib.

Do you have any idea why this happens?

Thank you very much!

like image 642
Antonio Petricca Avatar asked Feb 13 '13 09:02

Antonio Petricca


1 Answers

For a shared library, the IMPORTED_LOCATION must point to the DLL, not the import lib. See the documentation. You might also want to set the IMPORTED_IMPLIB property.

BTW, CMake also has a find package for Curl; perhaps you could use that?

like image 167
Angew is no longer proud of SO Avatar answered Nov 13 '22 05:11

Angew is no longer proud of SO