[Cmake] Strange behavior of cmake

Bill Hoffman bill . hoffman at kitware . com
Mon, 23 Jun 2003 10:15:56 -0400


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.



>2. When I set the output as the project of Visual Studio 7.0 the MSVC
>(C++ .NET) linker gives my (after the correct compilation) the warning:
>
>*** LINK: warning LNK4098: defaultlib 'LIBC' conflicts with use of
>other libs; use /NODEFAULTLIB:library
>I used SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
>/nodefaultlib:libc"), but nothing has changed, because the CMake doesn't
>permit using the flags "/nodefaultlib:library" - cmake forgets it and the
>linker gives me that warning again.

This is a bug in the vs7 generator, it currently ignores many of the
flags used by other generators.   This should be fixed in the next release.
However, you can use the target properties LINK_FLAGS, like this:

 SET_TARGET_PROPERTIES(foo PROPERTIES LINK_FLAGS "/nodefaultlib:library")

This should work with all the generators, but the downside is that it
has to be done for each executable in the project.

>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?

-Bill


>I feel quite confused.
>
>-David
>
>_______________________________________________
>Cmake mailing list
>Cmake at www . cmake . org
>http://www . cmake . org/mailman/listinfo/cmake