[Cmake] Strange behavior of cmake

David Svoboda xsvobod2 at informatics . muni . cz
Tue, 24 Jun 2003 08:51:48 +0200


On Mon, 23 Jun 2003, Bill Hoffman wrote:

> At 09:28 AM 6/23/2003, you wrote:
> >Hello,
> >
> >I tried to link my library (+ its testing examples), but there are some
> >bugs, which I don't know how to solve.
> >
> >1. When I set the output as "nmake Makefiles", linking of library failed
> >with the fact, that cmake cuts the names of libraries, i.e. libtiff.lib
> >is cut to tiff.lib. If I try to link my library against libtiff.lib, the
> >cmake cuts the name of libtiff.lib to tiff.lib. The file tiff.lib does not
> >exits thereforce the linkage fails. How to avoid this? (Without renaming
> >the library)
> 
> If on windows your library name is libtiff.lib, then the name of the library
> is libtiff and not tiff.   Unix has a special prefix lib that is not used
> as part of the library name, so if the file on disk is libtiff.a, then -ltiff
> links the library.   Windows has no special prefix, so tiff.lib would be the equivalent
> library on Windows, but if you have a libtiff.lib on windows, then you have
> to use the name libtiff or the linker will not find it.

Well, the problem is quite different. I know that UNIX uses lib<name>.a
naming convence, therefore UNIX linker needs -l<name> only. But on Windows
the name of library, I mentioned, is libtiff.lib. Therefore I used 

	FIND_LIBRARY(TIFF_LIB libtiff)

and cmake found the correct path (e.g. "c:/libs/libtiff.lib"). But when I
saw the makefile created by cmake I found the following line:

	... /GX /nologo ... -LIBPATH:c:\libs tiff.lib jpeg.lib

Why cmake cut the names from libtiff.lib, that it really found, to
tiff.lib? The file tiff.lib does not exist.

> >3. Above facts doesn't appear when choosing the different output. I.e.,
> >setting the output as nmake makefiles handles the flag "/nodefaultlib" ok
> >and setting the output as Visual Studio 7.0 project handles the names of
> >libraries the right way.
> 
> I am not sure why the names of the library works for VS 7.0.
> Is libtiff being built by cmake?

When setting output as VS 7.0 project - the linking process consists of
full path and name of each library i.e.

	... odbc32.lib c:\libs\libtiff.lib c:\libs\libjpeg.lib

When setting NMake makefiles as the output - the linking process creates
makefiles containing e.g.

	... -LIBPATH:c:\lib tiff.lib jpeg.lib


-David