[CMake] Why does find_library prefer xxx.dll

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Dec 29 12:34:56 EST 2006


On 2006-12-29 17:13+0100 Werner Smekal wrote:

> Hi,
>
> I use find_library() to check if a library exists. If the libxxx.dll and the 
> libxxx.a files are in the same directory, find_library() returns libxxx.dll - 
> but I can't link against this library (windows case).
>
> I could regex replace the dll with the the correct suffix, but is there a way 
> to tell find_library() to return the correct filename?
>

Hi Werner:

I will attempt an answer using my Linux experience just in case nobody gives
you the definitive windows answer.

For Linux, TARGET_LINK_LIBRARIES transforms the specific find_library result
(say /path/libname.so) into the most general form of library specification
(-L/path and -lname options).  This general form has no suffix which allows
you complete control (using additional link flags) of which form of library
(*.so or *.a in the Linux case) you use for linking.  On the other hand, my
experience is no such general transformation of linking options occurs if
you specify the linking options some other way (e.g.,
SET_TARGET_PROPERTIES(... PROPERTIES LINK_FLAGS ...)).

Are you using the TARGET_LINK_LIBRARIES command?

Can you provide the simplest complete project (simplest CMakeLists.txt file
and simplest "Hello World" style source code) that produces the problem?
This should help others to reproduce the problem and understand the
specifics you have used.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list