[CMake] Cmake and Win32 plugin linking issues.

Jamie Jones hentai_yagi at yahoo.com.au
Sun Aug 20 09:53:34 EDT 2006


G'day List,

I've been happily cmakifing my opensource project and after a good
success on *NIX (Yay! no more autotools) have run into a snag.

We use a plugin system where our main binary loads a plugin eg an opengl
renderer. On *NIX this is fine because you can have undefined symbols
when you link, and on OSX I can pass some flags to gcc to achieve the
same effect. Windows on the other hand has a whinge and refuses to link.

As a result, I've been unable to switch from a hand crafted .bat file to
useing cmake on Win32. (OSX has problems of it's own, but I'll save that
for another mail)

The "magic" build script for Win32 contain this fragment of the build
line for MSVC

/DEF:"./../../engine/api/doomsday.def" /IMPLIB:"./%BIN_DIR
%/Doomsday.lib"

(Full script is here ->
http://svn.sourceforge.net/viewvc/deng/trunk/doomsday/build/win32/vcbuild.bat?revision=3509&view=markup )

Somehow it produces a .lib file from the main executable that makes the
Windows linker happy.

I tried to emulate this in cmake with this:

## Work around for Win32 wanting something for the plugins to link to
IF (WIN32)
ADD_LIBRARY (deng STATIC ${DENG_SOURCES} engine/api/doomsday.def)
TARGET_LINK_LIBRARIES (deng ${SDL_LIBRARY} ${SDLNET_LIBRARY}
${ZLIB_LIBRARIES}
${CURSES_LIBRARIES} ${PNG_LIBRARIES} wsock32 winmm gdi32 ole32 user32
${CMAKE_SOURCE_DIR}/external/lzss/win32/lzss )
ENDIF (WIN32)

(Full source here ->
http://svn.sourceforge.net/viewvc/deng/trunk/doomsday/CMakeLists.txt?revision=3654&view=markup )

To me it looks like it generates a lib like the "magic" vcbuild.bat (Yes
- I'm not a windows programmer) however in my tests (mingw at this
stage) the plugins fail to link. Apparently the deng.lib that I create
has extra sections that confuse the linker, so my question is this, and
I hope the list can help me:

How can I achieve the behaviour in the vcbuild.bat file with cmake wih
both msvc and mingw compilers so I can build and link on Win32 and get a
successful adoption of cmake within my project ?

Thank you for your help :)

(Feel free to comment on the monstrosity that is my CMakeLists.txt,
there is always room for improvement of it)

Regards,
Yagisan
-- 
GPG/PGP signed mail preferred. No HTML mail. No MS Word attachments
PGP Key ID 0x4B6E7209
Fingerprint E1FD 9D7E 6BB4 1BD4 AEB9 3091 0027 CEFA 4B6E 7209
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://public.kitware.com/pipermail/cmake/attachments/20060820/75425e26/attachment.pgp


More information about the CMake mailing list