[CMake] Import libraries prefix bug under windows?

Ronan Collobert collober at nec-labs.com
Wed Nov 7 11:18:39 EST 2007


Hey Brandon...

    You will find the stuff in attachment.

Cheers,
Ronan.

Brandon Van Every wrote:
> Please provide a reproducer script so others of us can test your claim.
> 
> Cheers,
> Brandon Van Every
> 
> On Nov 6, 2007 6:04 PM, Ronan Collobert <collober at nec-labs.com> wrote:
>> Hi,
>>
>>    I have been using CMake for quite a while now under
>> Linux/MacOSX/Cygwin for a large project.
>>
>> Recently I have been trying to make it work under Windows, using the
>> freely available to download Windows SDK. (cmake -G "NMake Makefiles")
>>
>> I encountered a small problem, which might be a CMake bug. (I am using
>> the latest cmake 2.4.7)
>>
>> I ask CMake to produce a dll (let say foo.dll), and then I want to link
>> this dll to produce an executable bar.exe.
>>
>> I also changed the prefixes of the dll using:
>>   SET(CMAKE_SHARED_LIBRARY_PREFIX "lib")
>>   SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
>>
>> So in fact, the dll generated is libfoo.dll (which is right). An import
>> library is also generated (libfoo.lib) (which is still right).
>>
>> But then when the makefile generated by CMake wants to link and produce
>> bar.exe, the linker complains that it did not find "foo.lib". It seems
>> it completely ignore the given prefix of the dll here.
>>
>> Moving "libfoo.lib" to "foo.lib" and resuming the compilation works.
>> Not having a prefix also works.
>> So I would say it is a bug.
>>
>> In fact, I am not sure at all of this CMAKE_IMPORT_LIBRARY_PREFIX:
>> whatever I put there is ignored for the production of libfoo.lib (it is
>> always libfoo.lib which is produced, according to what it is given by
>> CMAKE_SHARED_LIBRARY_PREFIX)
>>
>> Ronan.
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bar.c
Type: text/x-csrc
Size: 52 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20071107/2fa1f0f5/bar.c
-------------- next part --------------
# Works perfectly under Cygwin,Linux,MacOSX
# Sux under Windows (cmake -G "NMake Makefiles" followed by nmake)
# If you comment these 3 lines, it works
# If after the generation of libfoo.lib you rename it in foo.lib and do nmake again, it works
SET(CMAKE_SHARED_LIBRARY_PREFIX "lib")
SET(CMAKE_STATIC_LIBRARY_PREFIX "lib")
SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") # seems useless

# Shared library foo
ADD_LIBRARY(foo SHARED foo.c)

# Executable bar
ADD_EXECUTABLE(bar bar.c)
TARGET_LINK_LIBRARIES(bar foo)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 160 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20071107/2fa1f0f5/foo.c


More information about the CMake mailing list